The ARC Bridge is a cross-platform software bridge of a nominal robot controller to Mujoco simulator via LCM communication protocol.
- Make sure you have java installed. Type
javacto verify. - Clone this repo:
git clone git@github.com:ARCaD-Lab-UM/arc-bridge.git
- Create a conda environment:
conda env create -f environment.yml conda activate arcpy
- Generate LCM types:
bash gen_lcm_types.sh # Ubuntu or macOS gen_lcm_types_win.cmd # Windows
⚠️ Restart MATLAB to make changes effective. Redo this if any LCM types are changed. - Install
arc-bridgeas a Python module in editable and compatible mode:pip install -e . --no-deps --config-settings editable_mode=compat - Launch it in any terminal with
arcpyactivated:Usearc-bridge # Ubuntu or Windows--helpto find other launching options. If you are using macOS, launch it in this repo's root folder:mjpython arc_bridge/main.py # macOS - Check the communication status and visualize data:
arc-lcm-spy
👇 Click to find the corresponding controller
- For a referenced integration, see the pendulum example added in commit
bd614b0. - Sensors including IMU, joint encoder, foot force, CoM position and velocity are parsed automatically. Check hopper_model.xml for an example of a floating-based robot with a common sensor pack.
-
Add your robot's MuJoCo XML files in
robot_assets/:robot_assets/ └── YourRobot/ └── your_robot.xml # Robot and scene definitions -
Define LCM message types in
lcm_types/:lcm_types/ ├── your_robot_state_t.lcm # Robot state message └── your_robot_control_t.lcm # Robot control messageMessage structure example:
// your_robot_state_t.lcm package lcm_msgs; struct your_robot_state_t { int64_t timestamp; double qj_pos[N]; // Joint positions double qj_vel[N]; // Joint velocities double qj_tau[N]; // Joint torques // Add robot-specific fields as needed } // your_robot_control_t.lcm package lcm_msgs; struct your_robot_control_t { int64_t timestamp; double qj_tau[N]; // Desired joint torques double qj_pos[N]; // Desired joint positions double qj_vel[N]; // Desired joint velocities double kp[N]; // Proportional gains double kd[N]; // Derivative gains }Replace
Nwith the number of actuated joints of your robot. -
Create a robot bridge classin
arc_bridge/bridges/your_robot_bridge.py:import mujoco import numpy as np from .lcm2mujuco_bridge import Lcm2MujocoBridge from arc_bridge.lcm_msgs import your_robot_state_t, your_robot_control_t from arc_bridge.utils import * class YourRobotBridge(Lcm2MujocoBridge): def __init__(self, mj_model, mj_data, config): super().__init__(mj_model, mj_data, config) def parse_robot_specific_low_state(self): """Add robot-specific state information to low_state message""" # Example: Add inertia matrix and bias forces temp_inertia_mat = np.zeros((self.mj_model.nv, self.mj_model.nv)) mujoco.mj_fullM(self.mj_model, temp_inertia_mat, self.mj_data.qM) self.low_state.inertia_mat = temp_inertia_mat.tolist() self.low_state.bias_force = self.mj_data.qfrc_bias.tolist()
-
Register your robot to bridge imports in
arc_bridge/bridges/__init__.py:# ... existing robots ... from .your_robot_bridge import YourRobotBridge
-
Register your robot to launching configurations in
arc_bridge/config.py:robot_path_dict = { # ... existing robots ... "your_robot": "YourRobot/robot.xml", }
-
Re-generate LCM Types
bash gen_lcm_types.sh # Ubuntu/macOS gen_lcm_types_win.cmd # Windows
For macOS users
Use mjpython instead of python to launch the bridge.
For Windows users
Use arc-bridge --busywait to avoid inaccurate system clock resolutions.
LCM messages not found in MATLAB
Restart MATLAB once after generating LCM types.
GLFW Error
GLFWError: (65542) b'GLX: No GLXFBConfigs returned'
GLFWError: (65545) b'GLX: Failed to find a suitable GLXFBConfig'
ERROR: could not create windowSet NVIDIA GPU as primary renderer (for systems with NVIDIA GPUs)
export __NV_PRIME_RENDER_OFFLOAD=1
export __GLX_VENDOR_LIBRARY_NAME=nvidia
Unable to install LimX SDK in arcpy
Downgrade mujoco to 3.2.2 and numpy to 1.21.6 manually.
