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

[ROS2] Multiplayer support #328

Draft
wants to merge 5 commits into
base: development
Choose a base branch
from
Draft

Conversation

lgleim
Copy link
Contributor

@lgleim lgleim commented May 12, 2023

Summary

Add support for multiplayer (client/server) simulation to the ROS2 Gem, based on a (Gazebo-inspired) "fat-client" architecture, using an O3DE server for state synchronization among clients.

What is the relevance of this feature?

There are an increasing number of use cases for simulating fleets of robots.

One area of application is in the context of warehouse simulation (cf. the Ros2FleetRobotTemplate) where many AMRs need to be simulated in the same environment.

While O3DE is already capable of simulating the physics of many robots (100+) on a single machine, there are clear limits to single-node scalability. This work should raise that ceiling and explore the scalability of an architecture with centralized state synchronization.

Feature design description

To evaluate the feasibility and scalability properties of multi-robot simulation in O3DE using a traditional Client-Server architecture, support for the O3DE Multiplayer Gem should be added to the ROS2 Gem.
Developers will then be able to simulate different robots on different machines, while the simulation state will be synchronized through a central game server. This approach is analogous to traditional multiplayer gaming.

Loosely inspired by the architecture of Gazebo Ignition, which employs a central "primary" for synchronizing the state of the simulation, we plan to make use of the O3DE Multiplayer Gem, creating

  • A single, central simulation Server: Responsible for state synchronization (transforms, physics-state) and not simulating any ROS2-specific components (as far as possible)
  • One Client per robot: All "heavy" components (e.g. rendering of camera sensors / LIDARs, control, ROS communication) are handled exclusively by one client, which is realized through the "Autonomous" role

Technical design description

  • Add a Utility function that allows ROS2 Components to determine if they are running in a multiplayer environment & if yes, if in autonomous / authorotative role to adapt their behavior accordingly
  • Adapt CMakeLists.txt to Multiplayer build configuration
  • Adapt ROS2 Sensor Components such that they are only activated when in "Autonomous" role
  • Adapt ROS2 Controller Components such that they are only activated when in "Authority" role
  • Adapt ROS2SystemComponent such that each client has a distinct ROS2 node name
  • Adapt ROS2SpawnerComponent such that the assigned namespaces do not clash, e.g. using random namespace suffixes
  • Extend ROS2SpawnerComponent based on Simple Network Player Spawner Component to assign the autonomous role to robots in multiplayer mode
  • Fix PhysX Joints not created in Multiplayer Mode o3de#16020
  • Adapt SimulationClock.cpp to publish a namespaced simulation clock (i.e. one simulation clock per node simulating robots)

What are the advantages of the feature?

  • Increased scalability of Robotics Simulation with O3DE
  • An additional example of developing "multiplayer" applications with O3DE

What are the disadvantages of the feature?

  • Increased complexity of the ROS2 Gem codebase
  • Likely additional Editor Components for the users to configure

How will this be implemented or integrated into the O3DE environment?

  • This change would introduce the Multiplayer Gem as an additional build dependency to the ROS2 Gem
  • Users should not Explain how a developer will integrate this into the codebase of O3DE and provide any specific library or technical stack requirements.

Are there any alternatives to this feature?

  • Reducing simulation complexity to improve single-node performance
  • An e.g. spatially-partitioned multiserver architecture, in which the ROS2 components should only be executed when in "Authority" role. However, since the multiserver GEM is AWS-proprietary, this is not a viable option for the ROS2 Gem currently. Mostly, the other planned modification apply equally.
  • Instead of creating "Autonomous-authoritative" versions of the NetworkTransform & NetworkRigidBody components, the ROS2 controllers could be adapted to be NetworkControllers. This requires more changes to the ROS2 Gem Controller Architecture though.

How will users learn this feature?

  • A multiplayer version of the ROS2FleetTemplate should be created
  • A tutorial for setting up multiplayer support for a ROS2 O3DE Simulation should be provided
  • Documentation should be augmented for any behavioral changes / additional setup & configuration steps

@lgleim lgleim added kind/feature Categorizes issue or PR as related to a new feature. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/simulation Categorizes an issue or PR as relevant to SIG Simulation status/active Indicates that an issue or PR is actively being worked on by a contributor. feature/robotics This item is related to robotics. labels May 12, 2023
@lgleim lgleim self-assigned this May 12, 2023
Added a new function "IsAutonomousOrNonMultiplayer" to the
"ROS2GemUtilities" to help components determine if they are attached
to an entity that is Networked.
This is preliminary work to allow components to be activated
selectively in the future, avoiding duplicated work for the ROS2
multiplayer architecture.

Signed-off-by: Lars Gleim <lars.gleim@huawei.com>
Adapt ROS2SystemComponent such that each O3DE instance has
a distinct ROS2 node name by appending a pseudorandom suffix.

Signed-off-by: Lars Gleim <lars.gleim@huawei.com>
Refactored ROS2GemUtilities to avoid compilation issues with the
ROS2.Static target and moved the CreateComponent function to the
RobotImporterUtils

Signed-off-by: Lars Gleim <lars.gleim@huawei.com>
Signed-off-by: Lars Gleim <lars.gleim@huawei.com>
Signed-off-by: Lars Gleim <lars.gleim@huawei.com>
@AMZN-alexpete AMZN-alexpete requested a review from kberg0 May 17, 2023 16:44
@adamdbrw
Copy link
Contributor

@lgleim was there any further work done on this? Do you have a preferred course of action?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/robotics This item is related to robotics. kind/feature Categorizes issue or PR as related to a new feature. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/simulation Categorizes an issue or PR as relevant to SIG Simulation status/active Indicates that an issue or PR is actively being worked on by a contributor.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants