ros-industrial / ros2_canopen

CANopen driver framework for ROS2
https://ros-industrial.github.io/ros2_canopen/manual/rolling/
143 stars 62 forks source link

Put components loaded by the device container into its namespace, if any. #270

Closed gsalinas closed 5 months ago

gsalinas commented 6 months ago

This PR adds logic to device_container.cpp to creates components loaded by the device_container in the same namespace as the device_container. This allows one to push a ROS namespace onto the entire launch and have the CAN master and all nodes exist within that namespace.

For proxy systems, this is as simple as adding including the launch description and pushing a namespace to it.

However, for systems based on ROS2 control, such as cia402_systems, it is also necessary to rewrite ros2_controllers.yaml slightly to include a placeholder __namespace__ that can be dynamically added or removed, so this PR also includes an example launch file that does this, which will run the nodes in the global namespace when launched as-is, or within a different namespace if specified by the user as a launch argument.

This is helpful when one wants to run multiple CANopen-based robots as part of the same ROS domain; on machines with multiple CAN interfaces, it also lets you run multiple physically separate CAN buses on the same ROS domain, which is a nice placeholder in systems where some devices are CIA402 and others are not, as ros2_canopen does not support that kind of mixture of systems.

hellantos commented 5 months ago

This looks good to me. @gsalinas can you run pre-commit and fix the formatting. Should be mostly automatic.