gazebosim / ros_gz

Integration between ROS (1 and 2) and Gazebo simulation
https://gazebosim.org
Apache License 2.0
211 stars 125 forks source link

Launch gzserver and the bridge as composable nodes #528

Closed caguero closed 1 month ago

caguero commented 3 months ago

🎉 New feature

Part of https://github.com/gazebosim/ros_gz/issues/544

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.

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

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.

azeey commented 3 months ago

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

azeey commented 3 months ago

cc @mjcarroll

caguero commented 3 months ago

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.