Skip to content

[ROS2] Loading plugins from a non-ROS package #161

@schornakj

Description

@schornakj

In ROS 1, the paths to all packages used in the project workspace are added to the ROS_PACKAGE_PATH environment variable, including pure CMake packages. This allows pluginlib to find libraries defined in non-ROS libraries, since the ROS 1 implementation of ClassLoader uses ros::package::path().

However, in ROS 2 there are different environment variables for CMAKE_PREFIX_PATH and AMENT_PREFIX_PATH. The first one contains all CMake packages used in my project, while the second one is a subset of the first only containing ament CMake packages. The ROS 2 implementation of ClassLoader uses ament_index_cpp::get_package_prefix(), which apparently only looks for packages in AMENT_PREFIX_PATH. This means that (so far) I can no longer load libraries defined in non-ROS packages.

The Tesseract motion planning pipeline is an example of something affected by this difference in behavior. The tesseract_plugins package defines several plugins which use libraries created by the ROS-agnostic tesseract_collision package, and these plugins are loaded at runtime by classes in the tesseract_monitoring ROS package. This works just fine in ROS 1 but in my ROS 2 port I get errors like:

[my_project_planning_manager_node-1] terminate called after throwing an instance of 'pluginlib::ClassLoaderException'
[my_project_planning_manager_node-1]   what():  package 'tesseract_collision' not found, searching: [/home/joe/workspaces/ros2_ws/install/xacro, /home/joe/workspaces/ros2_ws/install/opencv_tests, /home/joe/workspaces/ros2_ws/install/joint_state_publisher, /home/joe/workspaces/ros2_ws/install/vision_opencv, /home/joe/workspaces/ros2_ws/install/my_project_planning, /home/joe/workspaces/ros2_ws/install/tesseract_monitoring, /home/joe/workspaces/ros2_ws/install/tesseract_rosutils, /home/joe/workspaces/ros2_ws/install/tesseract_plugins, /home/joe/workspaces/ros2_ws/install/tesseract_msgs, /home/joe/workspaces/ros2_ws/install/srdfdom, /home/joe/workspaces/ros2_ws/install/robot_state_publisher, /home/joe/workspaces/ros2_ws/install/rct_ros_tools, /home/joe/workspaces/ros2_ws/install/rct_image_tools, /home/joe/workspaces/ros2_ws/install/rct_optimizations, /home/joe/workspaces/ros2_ws/install/octomap_msgs, /home/joe/workspaces/ros2_ws/install/mutable_transform_publisher, /home/joe/workspaces/ros2_ws/install/mutable_transform_publisher_msgs, /home/joe/workspaces/ros2_ws/install/image_geometry, /home/joe/workspaces/ros2_ws/install/cv_bridge, /opt/ros/dashing]

Any thoughts? I'd be open to package configuration workarounds on my end as well.

(pinging @Levi-Armstrong as the Tesseract package maintainer)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions