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_control
plugin inside the URDF.- As a parameter of the plugin, I specify the controller YAML file that configures
JointStateBroadcaster
andJointTrajectoryController
(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.py
from thegazebo_ros
package) - Start the
robot_state_publisher
node with the URDF robot description as a parameter - Run
spawn_entity.py
from thegazebo_ros
package to spawn the robot, using argument-topic /robot_description
- When the spawn script exits, I start the
joint_state_broadcaster
node using thespawner
fromcontroller_manager
package - After that, I start the
joint_trajectory_controller
in 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_trajectory
topic 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_publisher
s 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?