ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I copied your code to give it a try and it did compile for me. I however then get the following error when trying to run a node:

$ ros2 run pubsub talker 
/home/sander/install/pubsub/lib/pubsub/talker: symbol lookup error: /home/sander/install/autodrive_msgs/lib/libautodrive_msgs__rosidl_typesupport_fastrtps_cpp.so: undefined symbol: _ZN13geometry_msgs3msg24typesupport_fastrtps_cpp27max_serialized_size_Vector3ERbm

I could get it working with the following pointers:

  • Have you sourced the whole of the ROS 2 environment? If perhaps you only do source install/local_setup.bash, only packages in your local workspace will be available, but not the base ROS 2 packages. So autodrive_msgs can be found, but geometry_msgs not, which looks like what you get. If this is the case, you need to either source install/setup.bash, or source the base environment first. See also: https://answers.ros.org/question/292566/what-is-the-difference-between-local_setupbash-and-setupbash/
  • Your autodrive_msgs package is the one with the direct dependency on geometry_msgs, so you should specify that in that package. I am slightly surprised the autodrive_msgs package built without doing so and thought that that was your issue, but I guess the generation process doesn't actually need to work with the base messages. You should still specify the dependency though to enable easier use of your msgs package. For this, you should add this to auodrive_msgs/CMakeLists.txt:

    find_package(geometry_msgs)
    

    And then specify the dependency in the rosidl_generate_interface call:

    rosidl_generate_interfaces(${PROJECT_NAME}
      "msg/AccelCommand.msg"
      DEPENDENCIES geometry_msgs
     )
    

    Finally you should also have a <depend>geometry_msgs</depend> in autodrive_msgs/package.xml. This way any package that depends on your autodrive_msgs package will know it transitively depends on geometry_msgs and you don't have specify that in puch_sub/CMakeLists.txt

  • You have find_package(autodrive_msgs) in autodrive_msgs/CMakeLists.txt, implying the package depends on itself, which can't be (you should get a warning about that when building the package), so that line can/should go.