Is it possible to spawn and control 2 robots in webots with ROS2?
Hello, I am trying to make a simple application of 2 robots moving around in the webots simulator using ROS2. I am using the logic described in the tutorials https://docs.ros.org/en/foxy/Tutorial... which dictates the following:
1) A description for each robot in the .wbt world file
2) A URDF file for each robot with the connected devices and the plugin to the robot driver
3) An obstacle avoider node for each robot
4) And a controller node for each robot specified in the launch file.
I think that this last part is the source of the problem. This is the part of the launch file where I call the controller:
ros2_supervisor_robot1 = Node(
package='webots_ros2_driver',
executable='ros2_supervisor.py',
output='screen',
additional_env={'WEBOTS_CONTROLLER_URL': controller_url_prefix() + 'Ros2Supervisor'},
name='Ros2Supervisor')
ros2_supervisor_robot2 = Node(
package='webots_ros2_driver',
executable='ros2_supervisor.py',
output='screen',
additional_env={'WEBOTS_CONTROLLER_URL': controller_url_prefix() + 'Ros2Supervisor'},
name='Ros2Supervisor2')
In the tutorial this launcher for the Ros2Supervisor is used:
ros2_supervisor_robot1 = webots_ros2_driver.webots_launcher.Ros2SupervisorLauncher()
In both cases, the first robot works properly like in the tutorial but the second robot does not because it try as well to connect to the same Ros2Supercisor node and thus the process dies.
I would also like to add that in the .wbt world file, I have left the "controller" field of each robot exactly the same as in the tutorial (controller "<extern>")
What is it that I miss? Is there a way to fix this issue?
Thank you