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 file for combined spawn_model + bridge #534

Closed caguero closed 1 month ago

caguero commented 2 months ago

🎉 New feature

Summary

This patch adds two launch files: one for spawning a gz sim model and the other for spawning a gz sim model with a ros_gz bridge.

How to test it?

Launch gz sim:

ros2 launch ros_gz_sim gz_sim.launch.py gz_args:=empty.sdf

Hit play.

Use the provided gz_spawn_model.launch.py to spawn a vehicle (change file accordingly):

ros2 launch ros_gz_sim gz_spawn_model.launch.py world:=empty file:=/home/caguero/ros_gz_ws/src/ros_gz/ros_gz_sim_demos/models/vehicle/model.sdf name:=my_vehicle x:=5.0 y:=5.0 z:=0.5

Confirm that no container has been created:

caguero@cold:~/ros_gz_ws$ ros2 component list

Now let's spawn another model with a ros_gz bridge (update file and config_file accordingly):

ros2 launch ros_gz_sim ros_gz_spawn_model.launch.py world:=empty file:=/home/caguero/ros_gz_ws/src/ros_gz/ros_gz_sim_demos/models/vehicle/model.sdf name:=my_vehicle_2 x:=2.0 y:=2.0 z:=0.5 config_file:=/home/caguero/ros_gz_ws//src/ros_gz/ros_gz_bridge/test/config/full.yaml use_composition:=True

A second vehicle should be loaded into the scene.

gzserver should be running. Verify that you also see the /ros_chatter topic:

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

And confirm that a container has been created with both nodes:

caguero@cold:~/ros_gz_ws$ ros2 component list
/ros_gz_container
  1  /ros_gz_bridge

You could also explore launching another vehicle without the use_composition parameter.

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.