M20 Deployment

All research

How we get our own policies running on the M20 with DEEP Robotics’ M20 SDK deploy repository (sdk_deploy). Their RL training and deployment tutorial walks through the full workflow on video.

Where code runs

DEEP Robotics’ deploy repository runs locomotion policies on AOS, the computer that already handles motion and sensing. GOS, the spare computer, is left for our higher-level algorithms that sit outside the locomotion loop (see Hardware Documentation).

High-level deployment steps

  1. Train the policy in Isaac Lab with DEEP Robotics’ rl_training (see Training Locomotion Policies).
  2. Convert the checkpoint to ONNX with rl_training’s export_onnx_fast.py.
  3. Put it in the deploy repo by copying the .onnx file into the policy folder, pointing the deploy code at it, and rebuilding.
  4. Test it sim-to-sim in MuJoCo on the laptop, which runs the policy through the same deployment code it will use on the robot.
  5. Transfer it to the robot by copying the repo to AOS and rebuilding there for ARM.
  6. Run it on the robot by turning on SDK mode on the gamepad, starting rl_deploy, standing the robot up and then starting the policy.

On the laptop

Export a checkpoint

cd ~/IsaacLab/rl_training
RUN=logs/rsl_rl/<experiment>/<run_timestamp>
docker exec -w /workspace/rl_training isaac-lab-base /isaac-sim/python.sh \
  scripts/tools/export_onnx_fast.py \
  --checkpoint_path $RUN/model_<iteration>.pt --robot m20 \
  --output_path $RUN/exported/<policy_name>.onnx

Add a policy under its own name

  1. Copy <policy_name>.onnx from ~/IsaacLab/rl_training/logs/rsl_rl/<experiment>/<run_timestamp>/exported/ into ~/sdk_deploy/src/M20_sdk_deploy/policy/.
  2. Open ~/sdk_deploy/src/M20_sdk_deploy/state_machine/quadruped_wheel/rl_control_state.hpp and go to line 87.
  3. Change "policy" / "policy.onnx" to "policy" / "<policy_name>.onnx" and save.
  4. Rebuild (below).

To go back to the stock policy, change the name back to policy.onnx and rebuild.

Build (x86)

deactivate 2>/dev/null
cd ~/sdk_deploy
source /opt/ros/humble/setup.bash
colcon build --packages-up-to m20_sdk_deploy --cmake-args -DBUILD_PLATFORM=x86

Sim-to-sim test

The deploy repository includes a sim-to-sim test, which runs a policy in MuJoCo through the same deployment code it will use on the robot, so it can be checked before it ever reaches the real M20. Start the simulator before the controller, use one simulator only, and start fresh each time.

# Terminal 2
cd ~/sdk_deploy && source /opt/ros/humble/setup.bash && source install/setup.bash
export ROS_DOMAIN_ID=1
python3 src/M20_sdk_deploy/interface/robot/simulation/mujoco_simulation_ros2.py

# Terminal 1
cd ~/sdk_deploy && source /opt/ros/humble/setup.bash && source install/setup.bash
export ROS_DOMAIN_ID=1
ros2 run m20_sdk_deploy rl_deploy

The deploy repository's sim-to-sim test: a policy running on the M20 in MuJoCo, on a test scene with a ramp, stairs and a raised platform.

Copy to the robot

ssh user@10.21.31.103 'mkdir -p ~/M20_sdk_deploy/src'
scp -r ~/sdk_deploy/src/drdds ~/sdk_deploy/src/M20_sdk_deploy user@10.21.31.103:~/M20_sdk_deploy/src

On the robot’s second Wi-Fi, use 10.21.41.1 instead of 10.21.31.103.

On the robot

Build (ARM, as user)

cd ~/M20_sdk_deploy
source /opt/ros/foxy/setup.bash
colcon build --packages-up-to m20_sdk_deploy --cmake-args -DBUILD_PLATFORM=arm

The 'drdds' is in: /opt/ros/foxy warning is expected. Success looks like Summary: 2 packages finished. To check which policy the build loads:

strings install/m20_sdk_deploy/lib/m20_sdk_deploy/rl_deploy | grep onnx   # which policy file it loads
md5sum src/M20_sdk_deploy/policy/*.onnx

Run

First enable SDK mode on the gamepad, then run each line on its own:

sudo su
cd /home/user/M20_sdk_deploy
source /opt/ros/foxy/setup.bash
source /opt/robot/scripts/setup_ros2.sh
source install/setup.bash
ros2 run m20_sdk_deploy rl_deploy

Controls

Keyboard control is the default (kKeyBoard, main.cpp line 20). Press keys in the rl_deploy terminal.

Key Action
z Stand up (takes about 3 s)
c Start the RL policy (only while standing)
w / s Forward / back
a / d Left / right
q / e Turn left / right
x Lie down
r Joint damping: the emergency stop; the robot goes limp

For ROS 2 control, set kRos2 in main.cpp and rebuild. Commands then go to /rl_deploy/command_state (stand, rl_control, lie_down, damping) and /rl_deploy/cmd_vel.

Safety

  • The robot’s own rl_deploy runs at boot (/opt/robot/share/rl_deploy). Don’t kill it; SDK mode on the gamepad hands control over. rob_bag restarting often is also firmware.
  • The policy path is compiled in. The policy that gets loaded is set in src/M20_sdk_deploy/state_machine/quadruped_wheel/rl_control_state.hpp (line 87) and defaults to policy/policy.onnx. Changing the file name means a rebuild; swapping the file under the same name only needs a restart, so check which policy a build loads before running it on the robot.