Skip to content

darshmenon/quadruped-dog-rl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

quadruped-dog-rl

Quadruped robot dog simulation, walking control, and reinforcement learning policy training workspace.

Supports: Unitree Go1/Go2, Boston Dynamics Spot, MIT Mini Cheetah, ANYmal B/C, Mini Pupper.

Unitree Go2 in RViz2

Unitree Go2 in Gazebo Garden


Repository Structure

quadruped-dog-rl/
├── urdf/                    # Robot URDF and mesh files
│   ├── go1_config/          # Unitree Go1
│   ├── go2_unitree/         # Unitree Go2 (with DAE meshes)
│   ├── spot_config/         # Boston Dynamics Spot
│   ├── mini_cheetah_config/ # MIT Mini Cheetah
│   ├── mini_pupper_config/  # Mini Pupper
│   ├── anymal_b_config/     # ANYmal B (ETH Zurich)
│   └── anymal_c_config/     # ANYmal C (ETH Zurich)
├── ros2/                    # ROS2 packages (CHAMP framework, ros2 branch)
│   ├── champ/               # Core locomotion controller
│   ├── champ_base/          # Hardware abstraction layer
│   ├── champ_bringup/       # Launch files
│   ├── champ_config/        # Robot-specific configs
│   ├── champ_description/   # URDF loading
│   ├── champ_gazebo/        # Gazebo simulation
│   ├── champ_navigation/    # Navigation stack
│   ├── champ_teleop/        # Keyboard/joystick teleoperation
│   └── robots/              # Pre-configured robot packages
├── launch/                  # Top-level launch files
│   ├── view_go2.launch.py   # View Go2 URDF in RViz2
│   ├── gazebo_go2.launch.py # Spawn Go2 in Gazebo Garden
│   ├── gazebo_sim.launch.py # Generic Gazebo sim launcher
│   ├── rviz_view.launch.py  # Generic RViz2 viewer
│   └── policy_deploy.launch.py # Deploy trained RL policy
├── scripts/                 # Shell scripts for common tasks
│   ├── train_policy.sh      # Train walking policy
│   ├── play_policy.sh       # Visualize trained policy
│   └── launch_sim.sh        # Launch Gazebo sim
├── training/                # RL policy training (Unitree RL Gym)
│   ├── legged_gym/          # PPO training scripts and environments
│   ├── deploy/              # Policy deployment to real robot
│   └── setup.py
├── description/             # Robot description docs and joint conventions
└── interfaces/              # Custom ROS2 msgs, srvs, actions (placeholder)

System Requirements

  • Ubuntu 22.04
  • ROS2 Humble
  • Gazebo Garden (gz-sim7) — already works with ros_gz_sim
  • Python 3.8+
  • NVIDIA GPU with 10GB+ VRAM for RL training

Build ROS2 Packages

cd ros2
source /opt/ros/humble/setup.bash
colcon build --symlink-install --cmake-args -DBUILD_TESTING=OFF
source install/setup.bash

View Go2 in RViz2

source /opt/ros/humble/setup.bash
ros2 launch launch/view_go2.launch.py

Opens RViz2 with the full Go2 mesh and a joint slider GUI to pose the legs.


Spawn Go2 in Gazebo Garden

source /opt/ros/humble/setup.bash
ros2 launch launch/gazebo_go2.launch.py

Starts Gazebo Garden, spawns the Go2, bridges topics to ROS2, and opens RViz2 alongside it.

Send velocity commands:

ros2 topic pub /cmd_vel geometry_msgs/msg/Twist "{linear: {x: 0.5}}" --once

RL Policy Training

Requires Isaac Gym — download from https://developer.nvidia.com/isaac-gym

cd training
pip install -e .

# Train Go2 walking policy
python legged_gym/scripts/train.py --task=go2 --headless

# Visualize trained policy
python legged_gym/scripts/play.py --task=go2

# Deploy to real robot
cd deploy
python deploy.py --task=go2 --ckpt=<path_to_checkpoint>

Or use the helper scripts:

./scripts/train_policy.sh go2
./scripts/play_policy.sh go2

Available Robots

Robot URDF Path RL Task
Unitree Go1 urdf/go1_config/ go1
Unitree Go2 urdf/go2_unitree/urdf/go2.urdf go2
Boston Dynamics Spot urdf/spot_config/
MIT Mini Cheetah urdf/mini_cheetah_config/
ANYmal B urdf/anymal_b_config/
ANYmal C urdf/anymal_c_config/
Mini Pupper urdf/mini_pupper_config/

Intelligence Modules

Higher-level autonomy stack built on top of the base simulation and RL policy.

intelligence/
├── gait/
│   └── gait_scheduler.py       # Auto-select gait (walk/trot/canter/bound) by speed
├── perception/
│   └── terrain_estimator.py    # Classify terrain (flat/slope/stairs/rough) from IMU + foot forces
├── navigation/
│   └── waypoint_navigator.py   # Autonomous waypoint following via pure pursuit
├── terrain/
│   └── adaptive_controller.py  # Fuse terrain + gait into safe velocity commands
└── llm_commander/
    └── llm_commander.py        # Natural language -> robot commands via Claude API

Gait Scheduler

Auto-selects the right gait based on commanded speed:

Speed (m/s) Gait Foot pattern
0 – 0.05 Stand All feet down
0.05 – 0.4 Walk One foot at a time
0.4 – 1.5 Trot Diagonal pairs (FL+RR, FR+RL)
1.5 – 2.5 Canter Three-beat
2.5 – 4.0 Bound Front pair then rear pair
4.0+ Pronk All four feet airborne

Terrain Estimator

Classifies terrain from IMU and foot contact forces, outputs recommended speed limit and foot clearance:

from intelligence.perception.terrain_estimator import TerrainEstimator
estimator = TerrainEstimator()
result = estimator.estimate(imu_roll=0.1, imu_pitch=0.05, contacts=[120, 115, 118, 122])
# TerrainEstimate(terrain_type=flat, slope_deg=6.6, recommended_speed_limit=3.0)

Waypoint Navigator (ROS2)

Autonomous point-to-point navigation using pure pursuit:

ros2 run quadruped_dog_rl waypoint_navigator --ros-args \
    -p waypoints:="[[2.0,0.0],[2.0,2.0],[0.0,2.0],[0.0,0.0]]" \
    -p linear_speed:=0.5

LLM Commander (Natural Language)

Control the robot with plain English using Claude API:

export ANTHROPIC_API_KEY=your_key
python3 intelligence/llm_commander/llm_commander.py

Then publish commands:

ros2 topic pub /natural_language_cmd std_msgs/msg/String "data: 'trot forward at medium speed'"
ros2 topic pub /natural_language_cmd std_msgs/msg/String "data: 'turn left slowly'"
ros2 topic pub /natural_language_cmd std_msgs/msg/String "data: 'stop'"

Adaptive Controller

Combines terrain estimation + gait scheduling into a single safe command output:

from intelligence.terrain.adaptive_controller import AdaptiveController
ctrl = AdaptiveController()
cmd = ctrl.adapt(desired_speed=1.2, imu_pitch=0.12, contacts=[110,115,108,120])
# AdaptedCommand(linear_x=1.0, gait='trot', terrain='slope', foot_clearance=0.08)

References

About

Quadruped robot dog walking simulation and RL policy training

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors