ros_gz icon indicating copy to clipboard operation
ros_gz copied to clipboard

Launch file for combined spawn_model + bridge

Open caguero opened this issue 2 months ago • 0 comments

🎉 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

  • [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 12 '24 21:04 caguero