Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi robot support #207

Merged
merged 14 commits into from
May 10, 2023
Merged

Multi robot support #207

merged 14 commits into from
May 10, 2023

Conversation

roni-kreinin
Copy link
Collaborator

@roni-kreinin roni-kreinin commented Mar 10, 2023

Description

Alternative to #189, but using GroupAction and PushRosNamespace for a cleaner implementation.
I am also proposing that the namespace is the robot name, and by default all robots will have to be namespaced for consistency, even with just 1 robot. The default robot name and therefore namespace is create3.

Launch files updates (ignition):

  • ignition.launch.py: Launches just Gazebo without spawning a robot
  • create3_spawn.launch.py: Spawns a robot. Requires that ignition.launch.py has been launched first.
  • create3_ignition.launch.py: Default launch file to launch ignition.launch.py with a default create3 robot.

Other changes:

  • cmd_vel:
    • In ignition, /<namespace>/cmd_vel is now the topic being bridged to the equivalent /<namespace>/cmd_vel ros topic.
    • Default cmd_vel topic for teleop plugin is now /create3/cmd_vel.
  • Create3 buttons:
    • Ignition topic is now /model/<namespace>/create3_buttons. ROS topic is now /<namespace>/_create3_buttons. Its hidden so that it is not confused with interface_buttons.
  • Using ros_gz_bridge instead of ros_ign_bridge. The ign version was not being terminated properly when the simulation was closed, leaving stray nodes running in the background.
  • Created individual bridges for each lidar. Supposed to increase performance. See Performance issues with bridging gpu_lidar data gazebosim/ros_gz#368
  • Added static transforms from tf_prefixed odom and base_link frames to namespaced frames. See [DiffDriveController] Optional tf namespace prefixes instead of using node namespace ros-controls/ros2_controllers#533
  • Spawning dock correctly when the y and yaw values are changed.
  • Open a namespaced RViz window for each robot

TODO:

Notes:

  • Spawning 2 robots works, but spawning a 3rd causes a libGL segfault for me. Not sure if this is a hardware limitation.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.
Provide instructions so we can reproduce. Also list any relevant details for your test configuration.

# Default single robot launch
ros2 launch irobot_create_ignition_bringup create3_ignition.launch.py

# Spawn a second robot
ros2 launch irobot_create_ignition_bringup create3_spawn.launch.py namespace:=robot2 y:=1.0

Alternatively:

# Launch ignition
ros2 launch irobot_create_ignition_bringup ignition.launch.py

# Spawn robot 1
ros2 launch irobot_create_ignition_bringup create3_spawn.launch.py namespace:=robot1 

# Spawn robot 2
ros2 launch irobot_create_ignition_bringup create3_spawn.launch.py namespace:=robot2 y:=1.0

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Added robot name to Create 3 buttons
Namespaced dock frame id in pose republisher
Rviz now launches for each robot spawn
Added static transform for prefixed odom and base_link frames
Added offset launch module in irobot_create_common_bringup
Fixed spawning robots with different x, y, and yaw positions
@alsora
Copy link
Contributor

alsora commented Mar 11, 2023

I'm not convinced by forcing a namespace even when running with a single robot.
One of the most frequent request for support that we receive is due to users setting a namespace on the robot and then not pre-pending it to their other commands.

@roni-kreinin
Copy link
Collaborator Author

@alsora That's fair. What about having a namespace arg that defaults to robot_name, and in create3_ignition.launch.py we set robot_name to create3 and namespace to empty by default? That way the default launch remains the same but any additional calls to create3_spawn.launch.py will apply a namespace automatically.

create3_ignition defaults to spawning 'create3' robot without namespace
@alsora
Copy link
Contributor

alsora commented Mar 13, 2023

I'm not sure I understand why we need both namespace and robot name arguments (I still need to finish looking at the PR).

I would imagine that we could do this only with the namespace argument. This would be empty by default.
If users want to manually spawn multiple robots they would just do something like

ros2 launch irobot_create_ignition_bringup create3_spawn.launch.py namespace:=robot1 
ros2 launch irobot_create_ignition_bringup create3_spawn.launch.py namespace:=robot2

A dedicated multi-robot launch file could be used such as

ros2 launch irobot_create_ignition_bringup multirobot_spawn.launch.py num_robots:=5 namespace_prefix:=robot

@roni-kreinin
Copy link
Collaborator Author

roni-kreinin commented Mar 13, 2023

The robot name is used mostly for the model name in ignition. We could just namespace the create3 name and call each robot <namespace>/create3.

As for the multi-robot launch file, I would suggest we make a .yaml file to pass in. Something like:

robot1:
    x: 1.0
    y: 1.2
    z: 0.0
    yaw: 0.0
robot2:
    x: 2.0
    y: 0.0
    z: 0.0
    yaw: 1.5707

Then you can just call

ros2 launch irobot_create_ignition_bringup multirobot_spawn.launch.py robots:=/path/to/robots.yaml

@sp-sophia-labs
Copy link

Happy to support and contribute on this code if it proves to be the better approach. @roni-kreinin I see that you pushed something similar to us in turtlebot4_simulator as well, looks like we are trying to achieve the same things. Can we work together?

@roni-kreinin
Copy link
Collaborator Author

@sp-sophia-labs Of course. Feel free to make PR's against https://github.com/roni-kreinin/create3_sim/tree/multi_robot. Most of this PR is based on your work, I just wanted to make it compatible with the way that Nav2 and the physical TurtleBot 4 robot handle namespacing.

…ot_name arg

Changed dock name to be <namespace>/standard_dock
Remove robot_name arg, use just namespace for everything
@roni-kreinin
Copy link
Collaborator Author

@alsora I have updated it to use just the namespace. The robot model will now be <namespace>/create3, and the dock model is <namespace>/standard_dock.

The default create3_ignition.launch.py spawns a single robot at the world origin without a namespace. Additional robots can be spawned with

ros2 launch irobot_create_ignition_bringup create3_spawn.launch.py namespace:=robot1 x:=1.0

I tried making a multi robot launch file but ran into a couple of issues:

  • Spawning two models at the same time at launch causes an ignition rendering segfault
  • Nested IncludeLaunchDescription calls don't seem to apply the unique namespace arguments correctly. They require a top level declaration of the arg, and that one gets used for all included launch descriptions. I think this is just a limitation of ros2 launch, unless you know a way around it.

Currently the only way I can get multiple robots working is to launch each one in a separate terminal.

Use ogre2 as sensor render engine
Reduce max_step_size to 3ms
@roni-kreinin
Copy link
Collaborator Author

Looking to create a new default world to improve performance. The depot world is very GPU intensive which causes performance issues once the robot is spawned as well.

@roni-kreinin roni-kreinin marked this pull request as ready for review April 3, 2023 17:14
@alsora
Copy link
Contributor

alsora commented May 2, 2023

@roni-kreinin can you add support for gazebo classic and documentation in the readme on how to use namespaces?

Copy link
Contributor

@alsora alsora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for addressing the requests and sorry for this taking so long!

@alsora alsora merged commit 7fccefe into iRobotEducation:main May 10, 2023
alsora pushed a commit that referenced this pull request May 15, 2023
* Working multi robot sim

* Use wildcards for param files
Added robot name to Create 3 buttons

* Dock model is now called <robot_name>/standard_dock
Namespaced dock frame id in pose republisher

* Added namespacing support to Rviz config
Rviz now launches for each robot spawn
Added static transform for prefixed odom and base_link frames
Added offset launch module in irobot_create_common_bringup
Fixed spawning robots with different x, y, and yaw positions

* Linter fixes

* Added namespace launch arg. Defaults to 'robot_name' in create3_spawn
create3_ignition defaults to spawning 'create3' robot without namespace

* Frame id fixes

* Changed robot name to be <namespace>/create3, rather than using a robot_name arg
Changed dock name to be <namespace>/standard_dock
Remove robot_name arg, use just namespace for everything

* Fixed bumper
Use ogre2 as sensor render engine
Reduce max_step_size to 3ms

* Linter fixes

* Fixed import order

* Multi robot support for gazebo classic

* Updated README

* Fixed import order
@icsl-Jeon
Copy link

That is why I could not spawn two robots with different namespaces at the same time with a single launch..
Were you able to find the way for this?
Thank you in advance ;)

@alsora
Copy link
Contributor

alsora commented Sep 4, 2023

@icsl-Jeon the readme file contains instructions for spawning multiple robots with different namespaces (https://github.com/iRobotEducation/create3_sim#namespacing).
This requires to call multiple launch files, or to write your own launch script that combines them

@icsl-Jeon
Copy link

Of course I tried the instruction.
What I am interested in was having a single launch file that spawns the multiple robots.
I could not succeed as this mentioned:
#207 (comment)

@alsora
Copy link
Contributor

alsora commented Sep 5, 2023

We don't provide such a launch file, but there's nothing inherently preventing to do it.

If you need help please open a separate ticket and provide us with details about your launch script and the errors/problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants