Skip to content

Noetic release cannot find coroAction node #209

@yimenghou

Description

@yimenghou

Hi,
I try to port my code from ROS Melodic to ROS Noetic.
I used several types of action nodes (Sync, Coro, etc.. ) They all works just fine in Melodic.
But when I port the same code in Noetic. The compiler complains about missing 'CoroActionNode'.
Then I write a very simple code to test if coroAction work or not in Noetic.
The code has no compile/link error in Melodic, Ubuntu 18.04 but when switch to Noetic, Ubuntu 20.04. The compiler outputs the following:

/usr/bin/ld: CMakeFiles/test_foo.dir/src/test_foo.cpp.o: in function `FooActionNode::FooActionNode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, BT::NodeConfiguration const&)':
test_foo.cpp:(.text._ZN13FooActionNodeC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKN2BT17NodeConfigurationE[_ZN13FooActionNodeC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKN2BT17NodeConfigurationE]+0x2b): undefined reference to `BT::CoroActionNode::CoroActionNode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, BT::NodeConfiguration const&)'
/usr/bin/ld: CMakeFiles/test_foo.dir/src/test_foo.cpp.o: in function `FooActionNode::~FooActionNode()':
test_foo.cpp:(.text._ZN13FooActionNodeD2Ev[_ZN13FooActionNodeD2Ev]+0x14): undefined reference to `BT::CoroActionNode::~CoroActionNode()'
/usr/bin/ld: CMakeFiles/test_foo.dir/src/test_foo.cpp.o:(.rodata._ZTV13FooActionNode[_ZTV13FooActionNode]+0x20): undefined reference to `BT::CoroActionNode::executeTick()'
/usr/bin/ld: CMakeFiles/test_foo.dir/src/test_foo.cpp.o:(.rodata._ZTI13FooActionNode[_ZTI13FooActionNode]+0x10): undefined reference to `typeinfo for BT::CoroActionNode'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/test_foo.dir/build.make:92: /home/yimeng/ws_ws/devel/.private/foo_project/lib/foo_project/test_foo] Error 1
make[1]: *** [CMakeFiles/Makefile2:276: CMakeFiles/test_foo.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

Here is my CmakeList.txt file:

cmake_minimum_required(VERSION 3.0.2)
project(foo_project)

if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

find_package(catkin REQUIRED COMPONENTS
  behaviortree_cpp_v3
)

catkin_package(
  CATKIN_DEPENDS behaviortree_cpp_v3
)

include_directories(
  ${catkin_INCLUDE_DIRS}
)

add_executable(test_foo
  src/test_foo.cpp
)
target_link_libraries(test_foo ${BEHAVIOR_TREE_LIBRARY}  ${catkin_LIBRARIES})

install(TARGETS test_foo
  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

and my test code

#include "behaviortree_cpp_v3/bt_factory.h"

// clang-format off
static const char* xml_text = R"(
<root main_tree_to_execute="BehaviorTree">
  <BehaviorTree ID="BehaviorTree">
    <SequenceStar name="root">
      <Action ID="FooActionNode"/>
    </SequenceStar>
  </BehaviorTree>
</root>
 )";

// clang-format on

class FooActionNode : public BT::CoroActionNode {
 public:
  FooActionNode(const std::string& name, const BT::NodeConfiguration& cfg) : BT::CoroActionNode(name, cfg) {}

  virtual BT::NodeStatus tick() override {
    return BT::NodeStatus::SUCCESS;
  };

  virtual void halt() override {};

  // Any subclass of BtActionNode that accepts parameters must provide a
  // providedPorts method
  static BT::PortsList providedPorts() { return {}; }
};

int main(int argc, char** argv) {
  BT::BehaviorTreeFactory factory;
  factory.registerNodeType<FooActionNode>("FooActionNode");
  auto tree = factory.createTreeFromText(xml_text);
  BT::NodeStatus status = BT::NodeStatus::IDLE;
  while(status == BT::NodeStatus::IDLE || status == BT::NodeStatus::RUNNING) {
    status = tree.tickRoot();
    using namespace std::chrono_literals;
    std::this_thread::sleep_for(50ms);
  }
  return 0;
}

I get behaviortree_cpp_v3 via 'apt install ros-noetic-behaviortree_cpp_v3', it outputs the following

ros-noetic-behaviortree-cpp-v3 is already the newest version (3.5.0-1focal.20200529.055742).

The 'uname -a' output:

Linux yimeng-lenovo 5.4.0-39-generic #43-Ubuntu SMP Fri Jun 19 10:28:31 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

The 'printenv | grep ROS' output:

ROS_DISTRO=noetic
ROS_ETC_DIR=/opt/ros/noetic/etc/ros
ROS_PACKAGE_PATH=/opt/ros/noetic/share
ROS_PYTHON_VERSION=3
ROS_VERSION=1
ROS_ROOT=/opt/ros/noetic/share/ros
ROS_MASTER_URI=http://localhost:11311
ROSLISP_PACKAGE_DIRECTORIES=

And 'cat /etc/lsb-release' output:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04 LTS"

Thanks ahead for help.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions