I am trying to make a simple application of 2 robots moving around in the webots simulator using ROS2 humble. I am following this tutorial. I have done the following things:
- A description for each robot in the .wbt world file.
- A URDF file for both robots with the connected devices and the plugin to the robot driver.
- A controller node for each robot specified in the launch file.
This is the launch file where I call the controller:
import os
import launch
from launch import LaunchDescription
from ament_index_python.packages import get_package_share_directory
from webots_ros2_driver.webots_launcher import WebotsLauncher
from webots_ros2_driver.webots_controller import WebotsController
def generate_launch_description():
package_dir = get_package_share_directory('my_package')
robot_description_path = os.path.join(package_dir, 'resource', 'my_robot.urdf')
webots = WebotsLauncher(
world=os.path.join(package_dir, 'worlds', 'my_world.wbt')
)
my_robot_driver1 = WebotsController(
robot_name='my_robot_1',
parameters=[
{'robot_description': robot_description_path},
]
)
my_robot_driver2 = WebotsController(
robot_name='my_robot_2',
parameters=[
{'robot_description': robot_description_path},
]
)
return LaunchDescription([
webots,
my_robot_driver1,
my_robot_driver2,
launch.actions.RegisterEventHandler(
event_handler=launch.event_handlers.OnProcessExit(
target_action=webots,
on_exit=[launch.actions.EmitEvent(event=launch.events.Shutdown())],
)
)
])
After successfully build and launching it the simulator starts with 2 robots. when i run ros2 topic list this are the list of topics:
/cmd_vel
/my_robot_1/ds0
/my_robot_1/ds1
/my_robot_2/ds0
/my_robot_2/ds1
/parameter_events
/remove_urdf_robot
/rosout
When i want to move the robot using /cmd_vel both robot moves parallely. But i need seperated /cmd_vel for each robots like:
/my_robot_1/cmd_vel
/my_robot_1/ds0
/my_robot_1/ds1
/my_robot_2/cmd_vel
/my_robot_2/ds0
/my_robot_2/ds1
/parameter_events
/remove_urdf_robot
/rosout
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>".
Is there a way to fix this issue?
Thank you