How to spawn multiple copies of the same robot with ros2_control?
Hello, I have a working setup with a single robot (manipulator) that I can run and control with a joint trajectory controller. I want to modify my setup to spawn multiple copies of the same robot in Gazebo and have them simultaneously perform the same trajectories. However, I am having trouble achieving this. I will describe my current working setup for a single robot and what I thought would be the steps to achieve a multi-robot setting.
Current Setup:
- I'm running ROS 2 Humble with Gazebo 11.10.2 on Ubuntu 22.04 LTS
- I have a custom robotic arm described in Xacro format controlled with
ros2_control, and there is thegazebo_ros2_controlplugin inside the URDF.- As a parameter of the plugin, I specify the controller YAML file that configures
JointStateBroadcasterandJointTrajectoryController(position interfaces only)
- As a parameter of the plugin, I specify the controller YAML file that configures
In the launch file:
- Start Gazebo with an empty world (using
gazebo.launch.pyfrom thegazebo_rospackage) - Start the
robot_state_publishernode with the URDF robot description as a parameter - Run
spawn_entity.pyfrom thegazebo_rospackage to spawn the robot, using argument-topic /robot_description - When the spawn script exits, I start the
joint_state_broadcasternode using thespawnerfromcontroller_managerpackage - After that, I start the
joint_trajectory_controllerin the same way
- Start Gazebo with an empty world (using
Robot is spawned in Gazebo. On the side, I start another ROS 2 node that publishes trajectories to
/joint_trajectory_controller/joint_trajectorytopic every few seconds -> Robot moves in Gazebo.
Going multi-robot:
So I thought, if I want three robots spawned, I'll just start three robot_state_publishers with different namespaces and run three spawn_entity.py scripts using different robot descriptions topics (with appropriate namespaces). However, the problem, I think, is that only a single /gazebo_ros2_control node starts. Where do I go from here? Is there an easier way?
Asked by Envilon on 2023-04-15 07:13:11 UTC
Comments