ros-perception / laser_filters

Assorted filters designed to operate on 2D planar laser scanners, which use the sensor_msgs/LaserScan type.
BSD 3-Clause "New" or "Revised" License
175 stars 206 forks source link

liblaser_scan_filters.so: undefined symbol: _ZN5boost6system16generic_categoryEv #160

Closed Woz4tetra closed 2 years ago

Woz4tetra commented 2 years ago

I'm getting this error message on ROS galactic when running on the NVidia Jetson Xavier NX: [scan_to_scan_filter_chain-10] [FATAL] [1652930119.877895968] [scan_to_scan_filter_chain]: Could not load library for laser_filters/LaserScanRangeFilter: Failed to load library /home/tj2/ros2_ws/install/laser_filters/lib/liblaser_scan_filters.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 dlopen error: /home/tj2/ros2_ws/install/laser_filters/lib/liblaser_scan_filters.so: undefined symbol: _ZN5boost6system16generic_categoryEv, at /home/tj2/ros2_galactic/src/ros2/rcutils/src/shared_library.c:99

I've checked out the following branches for its dependencies: angles - galactic-devel filters - ros2 laser_filters - ros2

I've tried rolling back to different versions but they don't compile. Not sure what to try next.

jonbinney commented 2 years ago

Are you running from debs or source?

jonbinney commented 2 years ago

Just saw you posted the branches you're using, so i guess this is source. Let me try to reproduce.

Woz4tetra commented 2 years ago

That's right I'm building from source

Woz4tetra commented 2 years ago

Not entirely sure what's happening but when I launch laser filters with a namespace, the run time error goes away and it's publishing filtered laser scans. This is the launch file that causes the crash (imports omitted):

def generate_launch_description():
    rplidar_path = str(get_package_share_path("tj2_rplidar") / "launch/rplidar_a2.py")
    filter_config = str(get_package_share_path("tj2_rplidar") / "config/diffyjr_laser_filter.yaml")

    return LaunchDescription([
        IncludeLaunchDescription(
            PythonLaunchDescriptionSource(rplidar_path),
            launch_arguments={
                "serial_port": "/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0",
                "frame_id": "laser",
                "node_name": "diffyjr_rplidar",
            }.items()
        ),
        Node(
            package="laser_filters",
            executable="scan_to_scan_filter_chain",
            parameters=[filter_config]
        ),
    ])

Here's the launch file that runs without error:

def generate_launch_description():
    rplidar_path = str(get_package_share_path("tj2_rplidar") / "launch/rplidar_a2.py")
    filter_config = str(get_package_share_path("tj2_rplidar") / "config/diffyjr_laser_filter.yaml")

    launch_include_with_namespace = GroupAction(
        actions=[
            # push-ros-namespace to set namespace of included nodes
            PushRosNamespace(namespace="laser"),
            IncludeLaunchDescription(
                PythonLaunchDescriptionSource(rplidar_path),
                launch_arguments={
                    "serial_port": "/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0",
                    "frame_id": "laser",
                    "node_name": "diffyjr_rplidar",
                }.items()
            ),
            Node(
                package="laser_filters",
                executable="scan_to_scan_filter_chain",
                parameters=[filter_config]
            ),
        ]
    )

    return LaunchDescription([launch_include_with_namespace])

Another piece of strange behavior, a bunch nodes seem to crash with a similar error message if I run from a tmux session. For example:

$ ros2 run demo_nodes_cpp talker
/home/tj2/ros2_galactic/install/demo_nodes_cpp/lib/demo_nodes_cpp/talker: symbol lookup error: /home/tj2/ros2_galactic/install/demo_nodes_cpp/lib/demo_nodes_cpp/talker: undefined symbol: _ZN12class_loader11ClassLoader31setUnmanagedInstanceBeenCreatedEb
Woz4tetra commented 2 years ago

It would seem calling setup.bash from .bashrc is causing these weird issues. I've removed it from my .bashrc and am calling it every time I launch a new terminal. When I do that, the tmux issues go away as well as the original issue.

Calling it from a script after the terminal opens also seems to work. I've made a script that looks like this:

export ROS_DOMAIN_ID=1
source ${HOME}/ros2_galactic/install/setup.bash
source ${HOME}/ros2_ws/install/setup.bash

and I call it like this for each terminal: source bringup.sh

jonbinney commented 2 years ago

interesting..... i'm not sure why that would happen.

Woz4tetra commented 2 years ago

So it seems that the error was just being hidden in the tmux session. The node was running but wasn't applying any laser filters. So it wasn't modifying the laser scan message at all. Running laser filters like this brings the original error message back: ros2 run laser_filters scan_to_scan_filter_chain --ros-args --log-level debug -r scan:=/laser/scan -r scan_filtered:=/laser/scan_filtered --params-file /home/tj2/tj2_ros/tj2_rplidar/config/diffyjr_laser_filter.yaml

Woz4tetra commented 2 years ago

I've fixed the issue. Laser filters is now working as expected. I had to define Boost explicitly as a linked library in the filters and laser_filter CMakeLists.txt file. Patch files here: https://github.com/frc-88/tj2_ros/blob/dev/ros2/install/fix-filters.patch https://github.com/frc-88/tj2_ros/blob/dev/ros2/install/fix-laser-filters.patch

jonbinney commented 2 years ago

Interesting... any idea why this is an issue specifically on the jetson? I'm not able to reproduce it on arm-linux in a VM