A comprehensive control framework for the Quadson quadruped robot, implementing kinematic algorithms, locomotion control, and deep reinforcement learning for stable and adaptive walking.
Quadson is a quadruped robot platform that combines classical kinematics with deep reinforcement learning to achieve robust locomotion. This project includes:
- Forward & Inverse Kinematics: Precise control of leg positions and orientations
- Differential Kinematics: Smooth velocity control using numerical Jacobian computation
- Body Kinematics: Coordinate transformations for body pose control
- Locomotion Controller: Multi-gait support (walk, trot, pace, bound, gallop)
- Deep RL Integration: PPO-based learning for adaptive gait optimization
- Simulation Environment: PyBullet-based physics simulation with Gymnasium interface
The following GIFs illustrate two major stages of control development:
Figure 1. Comparison of algorithmic gait control and DRL-trained locomotion.
- Forward Kinematics: Compute end-effector positions from joint angles
- Inverse Kinematics: Analytical solution for 3-DOF leg mechanism
- Differential Kinematics: Velocity control via Moore-Penrose pseudoinverse
- Body Kinematics: World-to-shoulder frame transformations for pose control
Figure 2. Body kinematics visualization showing body pose control through world-to-shoulder transformations.
- Support for multiple gaits: walk, trot, pace, bound, and gallop
- Phase-based gait cycle control with configurable duty factors
- Cubic Bezier curve interpolation for smooth swing phase trajectories
- Adjustable step height, length, and timing parameters
- Custom Gymnasium environment (
QuadsonEnv) built on PyBullet - PPO algorithm implementation using Stable Baselines3
- 29-dimensional observation space (body state, joint positions, leg phases)
- 12-dimensional action space (end-effector offsets for adaptive control)
- Multi-objective reward function optimizing for:
- Forward velocity tracking (target: 0.5 m/s)
- Stability (reduced roll/pitch oscillations by >80%)
- Energy efficiency
- Height maintenance
Training over 5M simulation steps achieved:
- Improved orientation stability: Roll and pitch std dev reduced by >80%
- Forward velocity: Progressing toward 0.5 m/s target
- Vertical stability: Reduced oscillations in z-axis motion
For Docker users, use the following command to build and run the environment:
makeActivate your virtual environment and choose the requirements file that fits your needs:
For real robot with CAN bus support:
pip install -r requirements-real.txtFor simulation environment:
pip install -r requirements-sim.txtThen install the project to ensure that the modules can be imported correctly:
pip install -e .Before launching the program on real hardware, ensure your host kernel supports CAN bus.
Run the following command to verify CAN modules are available:
ls /lib/modules/$(uname -r)/kernel/net/canYou should see:
can.ko can-dev.ko can-raw.koIf the modules are not loaded, manually load them:
sudo modprobe can
sudo modprobe can_raw
sudo modprobe can_devIf you encounter errors such as:
modprobe: FATAL: Module can not found in directory /lib/modules/...modprobe: ERROR: could not insert 'can': Exec format errorCannot find device "can0"
Your kernel may not have CAN bus support built-in. You will need to switch to a compatible kernel or manually build CAN modules.
After loading modules, use the provided script to start the CAN interface:
./bash/start_can.shquadson_py/
├── src/
│ ├── common/ # Shared kinematics and locomotion algorithms
│ │ ├── body_kinematics.py
│ │ ├── leg_kinematics.py
│ │ └── locomotion.py
│ ├── real/ # Real robot hardware interface
│ │ ├── motor_manager.py
│ │ ├── leg.py
│ │ └── quadson.py
│ └── sim/ # Simulation components
│ ├── quadson_env.py # Gymnasium environment
│ ├── quadson.py
│ └── leg.py
├── tests/ # Test scripts and training
│ ├── sim/
│ │ ├── train_ppo.py # RL training script
│ │ ├── test_gait.py
│ │ └── analyze_gait.py
│ ├── real/
│ └── hybrid/
├── notebook/ # Jupyter notebooks for visualization
├── assets/ # URDF models and meshes
└── bash/ # Bash scripts
Activate the Docker container:
make runIf you are using a Python virtual environment, ensure it is activated.
Run gait simulation in PyBullet:
python tests/sim/test_gait.pyTrain the RL model:
python tests/sim/train_ppo.pyTest motor communication:
python tests/real/test_motor_manager_cando.pyTest leg positioning:
python tests/real/test_leg_angle.py- Simulation-to-Reality Transfer: Deploy trained models to physical hardware with domain adaptation
- Terrain Adaptation: Enhanced RL policies for slopes and uneven surfaces
- Sensor Integration: IMU and LiDAR for real-time feedback and obstacle detection
- Multi-directional Locomotion: Enable sideways and omnidirectional movement
- Recovery Mechanisms: Self-righting and failure adaptation capabilities
- Isaac Gym Migration: Transition to Isaac Gym for GPU-accelerated training
- World Frame (W): Global reference frame
- Body Frame (B): Attached to robot's center
- Shoulder Frame (S): Local frame for each leg's base joint
- Configurable duty factor (stance phase ratio)
- Phase offsets for inter-leg coordination
- Step height and length adjustment
- Cycle time control
Comprehensive documentation is available in the Quadson: A Quadruped Robot Control Framework.pdf.


