lopsided98 / nix-ros-overlay

ROS overlay for the Nix package manager
Apache License 2.0
173 stars 69 forks source link

`pluginlib` plugin loading does not work in composable nodes #330

Open hacker1024 opened 7 months ago

hacker1024 commented 7 months ago

pluginlib plugins fail to load in nodes launched as components.

When executed from a composable node, this line in class_loader seems to return nullptr when it would normally not. I have not found out why.

To reproduce

Setup:

$ nix-build \
    -I nix-ros-overlay=https://github.com/lopsided98/nix-ros-overlay/archive/develop.tar.gz \
    --extra-substituters 'https://ros.cachix.org' \
    --extra-trusted-public-keys 'ros.cachix.org-1:dSyZxI8geDCJrwgvCOHDoAfOm5sV1wCPjBkKL+38Rvo=' \
    -E 'with import <nix-ros-overlay> { }; with rosPackages.humble; buildEnv {
          paths = [
            ros-core
            nav2-controller
          ];
        }'

Working: Regular nodes

Note that the static_layer plugin loads successfully.

$ ./result/bin/ros2 run nav2_controller controller_server
$ ./result/bin/ros2 lifecycle set /controller_server configure

Broken: Composable nodes

Note that the static_layer plugin fails to load.

$ ./result/bin/ros2 component standalone nav2_controller nav2_controller::ControllerServer
$ ./result/bin/ros2 lifecycle set /controller_server configure
mbeutelspacher commented 3 months ago

I faced a similar issue and looked a bit into it

With the regular node https://github.com/ros/class_loader/blob/iron/include/class_loader/class_loader_core.hpp#L313 calls addOwningClassLoader with a nullptr whereas in the component container getCurrentlyActiveClassLoader() returns a not-nullptr.

For the regular node the else if in branch https://github.com/ros/class_loader/blob/iron/include/class_loader/class_loader_core.hpp#L418 than matches (because the owner is nullptr) whereas for the component container neither of the two branches match (I guess expected is the first branch), and therefore for the component container it cannot load the plugin.

I still need to find out why 1) getCurrentlyActiveClassLoader() == nullptr and getCurrentlyLoadingLibraryName() == "" for the regular node but not for the component container and 2) why the first branch does not match in the component container case

but when I hack in that I always override the output of getCurrentlyActiveClassLoader() with nullptr, I can load the plugin also in the component container