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

tf2_ros:.Buffer definition causes crash of nodelet, undefined symbol undefined symbol: _ZTVN7tf2_ros6BufferE

asked 2022-03-07 09:55:29 -0600

PaddyCube gravatar image

Hi there,

I'm building a nodelet with ROS Melodic. The nodelet publishes a pointcloud based on bumper messages, similar to http://wiki.ros.org/kobuki_bumper2pc. I try to adopt this behaviour for a given (own build) robot. In general, my code is working, when not using any tf2 package. It compiles fine and runs good so far.

Because my robot model has separate frames for left and right bumper, I wanted to use tf2 to set the points at the right place in respect to base_frame. As these are static frames, I wanted to use get x,y offset of each bumper frame from tf tree.

For some reason, as soon as I place this line in my class, it fails to run but compiles with no error.

tf2_ros::Buffer tfBuffer; <-- this causes the error

This line must just be part of header file and the nodelet crashes. Even if I remove any tf2 related code, it fails as soon as this definition is part of the header.

I can't figure out why this happens. It would be great, if someone can help me to figure things out.

This error occurs, but doesn't if I comment it out:

    started roslaunch server http://ubuntu-jetson:35617/

SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.12

NODES
  /
    Bumper2PCNodelet (nodelet/nodelet)
    base_controller (ros_hovermower_base_controller/ros_hovermower_base_controller)
    standalone_nodelet (nodelet/nodelet)

auto-starting new master
process[master]: started with pid [10534]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 9cc5535a-9e2c-11ec-82cd-520628f4d385
process[rosout-1]: started with pid [10547]
started core service [/rosout]
process[base_controller-2]: started with pid [10550]
process[standalone_nodelet-3]: started with pid [10560]
process[Bumper2PCNodelet-4]: started with pid [10568]
[ INFO] [1646667501.947591664]: Loading nodelet /Bumper2PCNodelet of type ros_hovermower_base_controller/Bumper2PcNodelet to manager standalone_nodelet with the following remappings:
[ INFO] [1646667501.970422695]: waitForService: Service [/standalone_nodelet/load_nodelet] has not been advertised, waiting...
[ INFO] [1646667501.973934612]: Initializing nodelet with 4 worker threads.
[ INFO] [1646667501.987027620]: Reconfigure Request: timeout_smag: 200 timeout: 10 
[ INFO] [1646667501.996778507]: waitForService: Service [/standalone_nodelet/load_nodelet] is now available.
[ INFO] [1646667502.016520080]: Initialized dynamic reconfigure
[ INFO] [1646667502.016709772]: Timeout smag  200
[ INFO] [1646667502.016864933]: Timeout  10
[ERROR] [1646667502.076439711]: Failed to load nodelet [/Bumper2PCNodelet] of type [ros_hovermower_base_controller/Bumper2PcNodelet] even after refreshing the cache: Failed to load library /home/ros/catkin_ws/devel/lib//libros_hovermower_base_controller_nodelet.so. Make sure that you are calling the PLUGINLIB_EXPORT_CLASS macro in the library code, and that names are consistent between this macro and your XML. Error string: Could not load library (Poco exception = /home/ros/catkin_ws/devel/lib//libros_hovermower_base_controller_nodelet.so: undefined symbol: _ZTVN7tf2_ros6BufferE)
[ERROR] [1646667502.076723833]: The error before refreshing the cache was: Failed to load library /home/ros/catkin_ws/devel/lib//libros_hovermower_base_controller_nodelet.so. Make sure that you are calling the PLUGINLIB_EXPORT_CLASS macro in the library code, and that names are consistent between this macro and your XML. Error string: Could not load library (Poco exception = /home/ros/catkin_ws/devel/lib//libros_hovermower_base_controller_nodelet.so: undefined symbol: _ZTVN7tf2_ros6BufferE)
[FATAL] [1646667502.077329891]: Failed to load nodelet '/Bumper2PCNodelet` of type `ros_hovermower_base_controller/Bumper2PcNodelet` to manager `standalone_nodelet'
[Bumper2PCNodelet-4] process has died [pid 10568, exit ...
(more)
edit retag flag offensive close merge delete

Comments

1

Quick comment: this is not a crash. It's the nodelet manager's pluginlib instance telling you it cannot resolve all the symbols in your shared library (as that's what nodelets are in the end) as it attempts to load it.

You need to check you're linking your library to all the other libraries you're using. In this specific case: the TF2 libraries.

And I'm saying "this is not a crash" as none of your code has been executed when the ERROR is printed.

gvdhoorn gravatar image gvdhoorn  ( 2022-03-07 11:50:30 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-03-07 13:35:06 -0600

PaddyCube gravatar image

Thank you @gvdhoorn for this hint.

I missed to add them as build and exec_depend in package.xml as well as find_packages in CMakeLists.txt. After fixing this in both files, it starts to work.

I'm wondering why I was able to build without any errors before, but now it works.

edit flag offensive delete link more

Comments

I'm wondering why I was able to build without any errors before

by default, the linker, when linking a shared library, will assume any symbols it cannot resolve at build-time will be resolved at runtime.

In your case, there were no errors as the linker basically assumed the nodelet manager would "know" where to find the symbols it couldn't find (not really the nodelet manager of course, as the linker doesn't know anything about that, but whatever entity was going to consume the shared library).

gvdhoorn gravatar image gvdhoorn  ( 2022-03-08 01:35:42 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2022-03-07 09:55:29 -0600

Seen: 409 times

Last updated: Mar 07 '22