ros_gz icon indicating copy to clipboard operation
ros_gz copied to clipboard

Launch gzserver and the bridge as composable nodes

Open caguero opened this issue 3 months ago • 3 comments

🎉 New feature

Summary

Extends #500 and converts the gzserver ROS node into a ROS component. It also adds a launch file that creates a container and loads two ROS nodes: gzserver and a bridge.

  • The idea of loading bridges, gzserver and potentially other ROS user components under the same container will benefit performance as we'll use intraprocess in Transport and in ROS. If the ROS user code runs outside of the container, we'll still have the gz Transport intraprocess advantage.

  • Each bridge will be loaded as a separate ROS component. There might be some extra overhead compared with a scenario where all bridges are loaded within the same ROS component. However, there are advantages as many of the ROS utilities should work as expected (topic remapping, namespaces, etc.).

How to test it?

Use the provided ros_gz_sim.launch.py (modify config_file accordingly):

ros2 launch ros_gz_sim gz_sim_composition.launch.py world_sdf_file:=empty.sdf config_file:=/home/caguero/ros_gz_ws//src/ros_gz/ros_gz_bridge/test/config/full.yaml

gzserver and the bridge should be running. Open a new terminal and confirm that the two ROS nodes are loaded:

caguero@cold:~/ros_gz_ws$ ros2 component list
/gz_sim_container
  1  /gzserver
  2  /bridge

Verify that the bridge is advertising /ros_chatter:

caguero@cold:~/ros_gz_ws$ ros2 topic list
/parameter_events
/ros_chatter
/rosout

Now, open a new terminal and load a new bridge into the existing container:

caguero@cold:~/ros_gz_ws$ ros2 component load /gz_sim_container ros_gz_bridge ros_gz_bridge::RosGzBridge -p config_file:=/home/caguero/ros_gz_ws//src/ros_gz/ros_gz_bridge/test/config/minimum.yaml -e use_intra_process_comms:=true
Loaded component 3 into '/gz_sim_container' container node as '/ros_gz_bridge'

Confirm it:

caguero@cold:~/ros_gz_ws$ ros2 component list
/gz_sim_container
  1  /gzserver
  2  /bridge
  3  /ros_gz_bridge

Now verify that the new bridge is advertising the new topics:

caguero@cold:~/ros_gz_ws$ ros2 topic list
/chatter
/chatter_both_ros
/chatter_gz
/chatter_ros
/parameter_events
/ros_chatter
/rosout

Test it

Checklist

  • [x] Signed all commits for DCO
  • [ ] Added tests
  • [ ] Added example and/or tutorial
  • [ ] Updated documentation (as needed)
  • [ ] Updated migration guide (as needed)
  • [ ] Consider updating Python bindings (if the library has them)
  • [ ] codecheck passed (See contributing)
  • [ ] All tests passed (See test coverage)
  • [ ] While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

caguero avatar Apr 04 '24 18:04 caguero

I just updated merged from ros2 in #500. Can you merge from gz_sim_ros_node so CI will run?

azeey avatar Apr 04 '24 18:04 azeey

cc @mjcarroll

azeey avatar Apr 04 '24 18:04 azeey

I just updated merged from ros2 in #500. Can you merge from gz_sim_ros_node so CI will run?

Merged from gz_sim_ros_node.

caguero avatar Apr 04 '24 18:04 caguero