cyberbotics / webots_ros2

Webots ROS 2 packages
Apache License 2.0
389 stars 141 forks source link

Multiple Robot #928

Closed harunkurtdev closed 1 month ago

harunkurtdev commented 1 month ago

Is your feature request related to a problem? Please describe.

The current implementation of the WebotsLauncher class does not support launching multiple supervisors simultaneously, which limits the capability of running multiple robot instances in Webots with different controllers.

Describe the solution you'd like ?

To enable support for launching multiple supervisors simultaneously, the WebotsLauncher class needs to be modified to accept configurations for multiple supervisors. Each supervisor configuration should include parameters such as the port number.

Describe alternatives you've considered ?

An alternative solution could be to manually launch each supervisor node separately outside of the WebotsLauncher class, but this would be less convenient and may require additional setup and coordination.

Additional context ?

Adding support for multiple supervisors would enhance the flexibility and scalability of running multiple robot instances in Webots, especially in complex robotic simulations or multi-robot scenarios.

harunkurtdev commented 1 month ago
turtlebot_driver_1 = WebotsController(
        robot_name='TurtleBot3Burger1',
        parameters=[
            {'robot_description': robot_description_path,
             'use_sim_time': use_sim_time,
             'update_rate':50,
             'set_robot_state_publisher': True},
            ros2_control_params
        ],
        port='1234',
        remappings=mappings_1,
        respawn=True,
        namespace='robot1'
    )

    turtlebot_driver_2 = WebotsController(
        robot_name='TurtleBot3Burger2',
        parameters=[
            {'robot_description': robot_description_path,
             'use_sim_time': use_sim_time,
             'update_rate':50,
             'set_robot_state_publisher': True},
            ros2_control_params
        ],
        port='1235',
        remappings=mappings_2,
        respawn=True,
        namespace='robot2'
    ) 

my turtlebot drivers

harunkurtdev commented 1 month ago
[webots_controller_TurtleBot3Burger1-7] [INFO] [1717368580.961037646] [resource_manager]: Initialize hardware 'WebotsControl' 
[webots_controller_TurtleBot3Burger1-7] [INFO] [1717368580.961125287] [resource_manager]: Successful initialization of hardware 'WebotsControl'
[webots_controller_TurtleBot3Burger1-7] [INFO] [1717368580.961201163] [resource_manager]: 'configure' hardware 'WebotsControl' 
[webots_controller_TurtleBot3Burger1-7] [INFO] [1717368580.961206153] [resource_manager]: Successful 'configure' of hardware 'WebotsControl'
[webots_controller_TurtleBot3Burger1-7] [INFO] [1717368580.961209710] [resource_manager]: 'activate' hardware 'WebotsControl' 
[webots_controller_TurtleBot3Burger1-7] [INFO] [1717368580.961213063] [resource_manager]: Successful 'activate' of hardware 'WebotsControl'
[webots_controller_TurtleBot3Burger1-7] [INFO] [1717368581.097228238] [plugin_node_example]:   - properties: {'parameterExample': 'someValue'}
[webots_controller_TurtleBot3Burger1-7] [INFO] [1717368581.097492533] [plugin_node_example]:   - robot name: TurtleBot3Burger1
[webots_controller_TurtleBot3Burger1-7] [INFO] [1717368581.097703848] [plugin_node_example]:   - basic timestep: 20
[webots_controller_TurtleBot3Burger1-7] [INFO] [1717368581.097924458] [plugin_node_example]:   - is supervisor? False
[ERROR] [launch]: Caught exception in launch (see debug for traceback): ExecuteLocal action 'webots_controller_TurtleBot3Burger2-9': executed more than once: <webots_ros2_driver.webots_controller.WebotsController object at 0x7c3e27f6bc10>
[INFO] [webots_controller_TurtleBot3Burger2-8]: sending signal 'SIGINT' to process[webots_controller_TurtleBot3Burger2-9]
[INFO] [webots_controller_TurtleBot3Burger1-7]: sending signal 'SIGINT' to process[webots_controller_TurtleBot3Burger1-7]
[INFO] [static_transform_publisher-6]: sending signal 'SIGINT' to process[static_transform_publisher-6]
[INFO] [static_transform_publisher-5]: sending signal 'SIGINT' to process[static_transform_publisher-5]
[INFO] [robot_state_publisher-4]: sending signal 'SIGINT' to process[robot_state_publisher-4]
[INFO] [robot_state_publisher-3]: sending signal 'SIGINT' to process[robot_state_publisher-3]
[INFO] [ros2_supervisor.py-2]: sending signal 'SIGINT' to process[ros2_supervisor.py-2]
[INFO] [webots-1]: sending signal 'SIGINT' to process[webots-1]
[static_transform_publisher-6] [INFO] [1717368581.102902468] [rclcpp]: signal_handler(signum=2)
[static_transform_publisher-5] [INFO] [1717368581.103542493] [rclcpp]: signal_handler(signum=2)
[robot_state_publisher-4] [INFO] [1717368581.104079386] [rclcpp]: signal_handler(signum=2)
[robot_state_publisher-3] [INFO] [1717368581.104681721] [rclcpp]: signal_handler(signum=2)
[ERROR] [ros2_supervisor.py-2]: process has died [pid 22287, exit code -2, cmd '/home/harunkurtdev/workspace_ws/install/webots_ros2_driver/lib/webots_ros2_driver/ros2_supervisor.py --ros-args -r __ns:=/Ros2Supervisor -r /Ros2Supervisor/clock:=/clock'].
[webots_controller_TurtleBot3Burger1-7] [INFO] [1717368581.142501719] [robot1.TurtleBot3Burger1]: Controller successfully disconnected from robot in Webots simulation.
[INFO] [static_transform_publisher-6]: process has finished cleanly [pid 22297]
[INFO] [static_transform_publisher-5]: process has finished cleanly [pid 22295]
[INFO] [robot_state_publisher-4]: process has finished cleanly [pid 22293]
[INFO] [robot_state_publisher-3]: process has finished cleanly [pid 22290]
[INFO] [webots-1]: process has finished cleanly [pid 22285]
[INFO] [webots_controller_TurtleBot3Burger1-7]: process has finished cleanly [pid 22300]
[webots_controller_TurtleBot3Burger2-9] Cannot connect to Webots instance, retrying for another 40 seconds...
[ERROR] [webots_controller_TurtleBot3Burger2-8]: process[webots_controller_TurtleBot3Burger2-9] failed to terminate '5' seconds after receiving 'SIGINT', escalating to 'SIGTERM'
[INFO] [webots_controller_TurtleBot3Burger2-8]: sending signal 'SIGTERM' to process[webots_controller_TurtleBot3Burger2-9]
[ERROR] [webots_controller_TurtleBot3Burger2-8]: process has died [pid 22302, exit code -15, cmd '/home/harunkurtdev/workspace_ws/install/webots_ros2_driver/share/webots_ros2_driver/scripts/webots-controller --robot-name=TurtleBot3Burger2 --protocol=ipc --port=1235 ros2 --ros-args -r /diffdrive_controller/cmd_vel_unstamped:=/cmd_vel -r /diffdrive_controller/odom:=/odom -r __ns:=/robot2 -p robot_description:=/home/harunkurtdev/workspace_ws/install/webots_ros2_turtlebot/share/webots_ros2_turtlebot/resource/turtlebot_webots.urdf -p use_sim_time:=True -p update_rate:=50 -p set_robot_state_publisher:=True --params-file /home/harunkurtdev/workspace_ws/install/webots_ros2_turtlebot/share/webots_ros2_turtlebot/resource/ros2control.yml'].

I got have error for webots_controller_TurtleBot3Burger

harunkurtdev commented 1 month ago

@DavidMansolino sir, can you give me some advice for this.

I have not use multiple robot