Skip to content

[fix] nav2 packages#591

Merged
lopsided98 merged 10 commits intolopsided98:developfrom
muellerbernd:fix-nav2-costmap-2d
Apr 27, 2025
Merged

[fix] nav2 packages#591
lopsided98 merged 10 commits intolopsided98:developfrom
muellerbernd:fix-nav2-costmap-2d

Conversation

@muellerbernd
Copy link
Copy Markdown
Contributor

@muellerbernd muellerbernd commented Mar 4, 2025

With this changes navigation2 compiles for jazzy and humble.

@muellerbernd muellerbernd changed the title [fix] nav2-costmap-2d [fix] nav2 packages Mar 4, 2025
@wentasah
Copy link
Copy Markdown
Collaborator

wentasah commented Mar 4, 2025

Confirming that this fixes quite a few packages. Not sure whether overriding env.NIX_CFLAGS_COMPILE is the best thing to do, but it clearly works.

@wentasah
Copy link
Copy Markdown
Collaborator

wentasah commented Mar 4, 2025

@muellerbernd The last commit added a large override for zenoh-bridge-dds. Is this intended?

@muellerbernd
Copy link
Copy Markdown
Contributor Author

muellerbernd commented Mar 4, 2025

@muellerbernd The last commit added a large override for zenoh-bridge-dds. Is this intended?

That was not intended. Thanks for pointing that out.

@wentasah
Copy link
Copy Markdown
Collaborator

wentasah commented Mar 7, 2025

Now this fixes builds of 78 packages. Thanks.

@muellerbernd
Copy link
Copy Markdown
Contributor Author

muellerbernd commented Mar 9, 2025

While testing this an going through the nav2 tutorials I have encountered a problem while executing

ros2 launch nav2_bringup tb3_simulation_launch.py headless:=False

RVIZ and gazebo start but some Nav2 plugins do not load:

Failed to load library /nix/store/wicvswg08kwklnv7sc3xx24irvsx2ay6-ros-env/lib/libnav2_rviz_plugins.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: /nix/store/wicvswg08kwklnv7sc3xx24irvsx2ay6-ros-env/lib/libnav2_rviz_plugins.so: undefined symbol: \_ZN17nav2_rviz_plugins12DockingPanel9onStartupEv, at /build/rcutils-release-release-jazzy-rcutils-6.7.2-1/src/shared_library.c:99

And also

Original error: MultiLibraryClassLoader: Could not create object of class type nav2_costmap_2d::StaticLayer as no factory exists for it. Make sure that the library exists and was explicitly loaded through MultiLibraryClassLoader::loadLibrary()

Same problems occur, while building navigation2 from source in a workspace.

Seems to be related to the PLUGINLIB_EXPORT_CLASS macro in the plugins implementations.

@wentasah
Copy link
Copy Markdown
Collaborator

wentasah commented Mar 9, 2025

I've seen similar errors with some Autoware rviz plugins. This change seems to fix the problem. If it works for you, feel free to use the patch in this PR.

@muellerbernd
Copy link
Copy Markdown
Contributor Author

I've seen similar errors with some Autoware rviz plugins. This change seems to fix the problem. If it works for you, feel free to use the patch in this PR.

Thanks. Now the nav2 rviz plugins are working.

@muellerbernd
Copy link
Copy Markdown
Contributor Author

muellerbernd commented Mar 9, 2025

But unfortunately the nav2 gazebo simulation is not working as intended. The nav2 changes seem to work. I will test that tomorrow on a real world robot.

@muellerbernd
Copy link
Copy Markdown
Contributor Author

Update on that. I want to use the static layer plugin of nav2_costmap_2d and I get the following error:

nav2_costmap_2d::StaticLayer as no factory exists for it. Make sure that the library exists and was explicitly loaded through MultiLibraryClassLoader::loadLibrary()

@muellerbernd
Copy link
Copy Markdown
Contributor Author

muellerbernd commented Mar 11, 2025

Next update. If you have the following shell:

{ pkgs ? import ../. {} }:
with pkgs;
with rosPackages.jazzy;

mkShell {
  nativeBuildInputs = [
    (buildEnv {
      paths = [
        ros-core
        colcon
        geometry-msgs
        turtlebot4-desktop
        turtlebot4-simulator
        slam-toolbox
        nav2-minimal-tb4-sim
        nav2-minimal-tb3-sim
      ];
    })
  ];
}

You can start a turtlebot4 simulation via:

ros2 launch turtlebot4_gz_bringup turtlebot4_gz.launch.py

After that you start SLAM:

ros2 launch slam_toolbox online_async_launch.py

Then start navigation2:

ros2 launch nav2_bringup navigation_launch.py

Now I can see all costmaps and no error occurs. This workflow is more or less the same as in the documentation

@wentasah
Copy link
Copy Markdown
Collaborator

When trying to follow your guide, the first command prints (among others):

[spawner-32] [FATAL] [1741768217.545395794] [spawner_joint_state_broadcaster]: Could not contact service /controller_manager/list_controllers
[ERROR] [spawner-32]: process has died [pid 2942386, exit code 1, cmd '/nix/store/0839x7x83la7ar6d5y4bz76k5k4j9a4p-ros-env/lib/controller_manager/spawner joint_state_broadcaster -c controller_manager --controller-manager-timeout 30 --ros-args -r __ns:=/'].

and navigation_launch.py:

[controller_server-1] [INFO] [1741768032.351308286] [local_costmap.local_costmap]: Timed out waiting for transform from base_link to odom to become available, tf error: Could not find a connection between 'odom' and 'base_link' because they are not part of the same tree.Tf has two or more unconnected trees.
[controller_server-1] [ERROR] [1741768032.351401653] [local_costmap.local_costmap]: Failed to activate local_costmap because transform from base_link to odom did not become available before timeout

And no graphical application (rviz, gazebo) appears. Do you have an idea why?

@muellerbernd
Copy link
Copy Markdown
Contributor Author

muellerbernd commented Mar 12, 2025

When trying to follow your guide, the first command prints (among others):

[spawner-32] [FATAL] [1741768217.545395794] [spawner_joint_state_broadcaster]: Could not contact service /controller_manager/list_controllers
[ERROR] [spawner-32]: process has died [pid 2942386, exit code 1, cmd '/nix/store/0839x7x83la7ar6d5y4bz76k5k4j9a4p-ros-env/lib/controller_manager/spawner joint_state_broadcaster -c controller_manager --controller-manager-timeout 30 --ros-args -r __ns:=/'].

and navigation_launch.py:

[controller_server-1] [INFO] [1741768032.351308286] [local_costmap.local_costmap]: Timed out waiting for transform from base_link to odom to become available, tf error: Could not find a connection between 'odom' and 'base_link' because they are not part of the same tree.Tf has two or more unconnected trees.
[controller_server-1] [ERROR] [1741768032.351401653] [local_costmap.local_costmap]: Failed to activate local_costmap because transform from base_link to odom did not become available before timeout

And no graphical application (rviz, gazebo) appears. Do you have an idea why?

I have attached an example shell to this PR. Test if RVIZ or gazebo start there. Important gazebo somehow needs connection to the internet (both directions, for whatever reason) otherwise it wont start. If you have a firewall running try to disable in temporally.

@wentasah
Copy link
Copy Markdown
Collaborator

Yes, switching off the firewall helped and gazebo starts.

If I start rviz and try to show some costmaps, they seem quite small (roughly 50x50 cm) compared to what can be seen in the nav2 tutorial and doesn't get larger when I move the robot. But I don't know much about what's the point of the demo so that's probably not relevant for this PR.

@muellerbernd
Copy link
Copy Markdown
Contributor Author

So following the official nav2 tutorials is still not working and I still get the error:

MultiLibraryClassLoader: Could not create object of class type nav2_costmap_2d::StaticLayer as no factory exists for it. Make sure that the library exists and was explicitly loaded through MultiLibraryClassLoader::loadLibrary()

There is also an upstream issue where the same error occurs when mixing compilation with gcc and clang. Maybe that's also the problem in this PR.

@muellerbernd
Copy link
Copy Markdown
Contributor Author

If we use the following with the given shell in this PR

ros2 launch nav2_bringup tb3_simulation_launch.py headless:=True use_composition:=False

Everything seems to work fine. The costmaps come up and even 2D navigation is working.

@lopsided98 lopsided98 merged commit 4072d6e into lopsided98:develop Apr 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants