tf2_ros:.Buffer definition causes crash of nodelet, undefined symbol undefined symbol: _ZTVN7tf2_ros6BufferE
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 ...
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.