You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The MATRiX platform supports simulating multiple robots simultaneously within the same environment. This feature is essential for researching multi-agent collaboration, swarming behaviors, and competitive scenarios.
This tutorial guides you through configuring the system for multi-robot simulation.
🔧 Configuration
Multi-robot setup is defined in the configuration file (e.g., config/config.json). You can define multiple robot instances by adding corresponding JSON objects. Each robot must have unique port configurations to ensure independent communication channels.
Example Configuration
Below is an example configuration for two robots (robot1 and robot2):
Crucial: Set different positions for each robot to avoid collision at spawn.
state_port
UDP port for broadcasting robot state (Joints, IMU, etc.).
Must be unique for each robot (e.g., 25001 vs 25011).
cmd_port
UDP port for receiving control commands.
Must be unique for each robot (e.g., 25002 vs 25012).
EgoView
Whether the camera follows this robot.
Usually set to true for the main robot and false for others to avoid camera conflict, or use Free Camera mode.
sensors
Sensor configuration for the specific robot.
Each robot can have its own independent sensor setup.
🎮 Controlling Multiple Robots
Since each robot listens on a different UDP port (cmd_port), you need to run separate control instances pointing to these specific ports.
For example:
Client A sends commands to port 25002 (Controls Robot 1)
Client B sends commands to port 25012 (Controls Robot 2)
This architecture allows for:
Decentralized Control: Independent agents controlling each robot.
Centralized Control: A single script sending commands to multiple ports.
🐍 Running the Python Demo
To run the control script using the HighLevel API, ensure the dependencies are correctly set up:
Execute the Script: Run the demo script to start sending commands.
```bash
cp matrix/config/config_multi_robot.json matrix/config/config.json
cd matrix/multirobot
python highlevel_demo.py
```
Modify Ports: In highlevel_demo.py, ensure each robot instance is initialized with the correct local_ip, local_port, dog_ip, and dog_port corresponding to your configuration.
⚠️ Tips
Performance: Simulating multiple robots with high-fidelity sensors (like Cameras/Lidar) increases GPU/CPU load. Disable unnecessary sensors for secondary robots if performance drops.
Identification: Use the EgoView parameter to check which robot is currently being tracked by the camera, or switch to Free Camera mode (press V) to overlook the entire scene.
Python API: Ensure your environment uses Python 3.10. When initializing robot instances, verify that each points to the correct unique IP and port combinations to prevent command conflicts.
Multi-Robot HighLevel API Usage
Initialization
Function Name
initRobot(const std::string & local_ip, const int local_port, const string& dog_ip, const int dog_port)
Description
Establishes communication with the robot dog. The default robot IP is "192.168.234.1". If changing the robot IP, provide the new IP through this interface.
Parameters
local_ip: User host IP; local_port: User host port; dog_ip: Robot IP; dog_port: Robot port.
Returns
None
Notes
Outputs failure logs to the terminal if communication establishment fails.
Control Functions
Function Name
lieDown()
Description
Controls the robot dog to lie down.
Parameters
None
Returns
0: Normal; 0x3012: Motor data lost; 0x3010: Motor disabled; 0x3011: Motor fault; 0x3009: Motor angle out of limit; 0x3007: State machine switch failed; 0x3013: Velocity command too large.
Notes
Robot lies down, joints locked.
Function Name
standUP()
Description
Controls the robot dog to stand up.
Parameters
None
Returns
0: Normal; Other error codes same as lieDown().
Notes
Robot stands normally, joints locked.
Function Name
passive()
Description
Controls the robot dog to enter emergency passive mode.