A complete simulation of a spider robot (quadruped) using PyBullet for physics and inverse kinematics control. This project offers several control modes and autonomous movements.
- Features
- Project Architecture
- Installation
- Usage
- Operating Modes
- URDF Structure
- Controls
- Inverse Kinematics
- References
- Realistic physics simulation with PyBullet
- 3 versions of URDF models (V1, V2, V3) with collision geometries
- Inverse kinematics for cartesian leg control
- 3 control modes :
- Autonomous mode with trotting gait
- Manual mode with joint control
- Cartesian mode for direct foot position control
- Programmed trajectories :
- Straight-line movement (trot)
- In-place rotation
spiderbot-simulation/
โโโ main.py # Main entry point
โโโ robot.py # Robot class - kinematics and movement
โโโ kinematics.py # Inverse kinematics (IK)
โโโ interface.py # Control interface and debug parameters
โโโ world_simulate.py # Simulation and environment management
โโโ Robot_mesh_urdf_V1/ # Robot model V1 (RobotSpider)
โโโ Robot_mesh_urdf_V2/ # Robot model V2 (RobotProto)
โโโ Robot_mesh_urdf_V3/ # Robot model V3 (improved RobotSpider)
โโโ tools/ # Utilities (VHACD generator for collision)
__init__: Robot initialization with URDFmanual_move(): Manual joint controlmanual_cart_move(): Cartesian leg controlautonomous_move(): Autonomous walking with trotupdate_joint_axes(): Debug display of joint axes
__init__: PyBullet client initialization, environment setupload_world(): Load plane (plane.urdf)load_object(): Load robot URDFcreate_heightfield_ground(): Generate variable terrain
init_auto(): Parameters for autonomous modeinit_manual(): Parameters for manual modeinit_manual_cart(): Parameters for cartesian modeend_mode(): Debug parameters cleanup
Inverse kinematics calculation for a leg:
- Input : Target position (x, y, z)
- Output : Joint angles [hip, knee, foot]
- Parameters : Segment lengths (coxa, tibia, tarsus)
- Python 3.8+
- PyBullet
- NumPy
- keyboard
pip install pybullet numpy keyboardpython main.pyTo enable debug mode (display joint axes):
debug = True # In main.py line 13Activation : Click the "Mode Auto" button in the debug interface
Features :
- โ Trot walking (forward/backward)
- โ In-place rotation
- โ Dynamic leg lifting (70mm height)
Available Parameters :
Run: Enable/disable movementTurn: Enable/disable rotationRotation angle: Target rotation angle (-ฯ to +ฯ)
Gait
- Period : 0.25s
- 4 legs in trot configuration (diagonals)
- Front-right (AVD) + rear-left (ARG) legs in phase
- Front-left (AVG) + rear-right (ARD) legs offset by T/2
Activation : Click the "Mode Manuel" button in the debug interface
Features :
- ๐ฏ Direct control of 12 joints (3 per leg)
- Precise movement ranges for each joint
Joints per Leg :
- H (Hip) : Base rotation, ยฑ1.57 rad (ยฑ90ยฐ)
- V1 (Vertical 1) : First vertical joint, ยฑ1.57 rad
- V2 (Vertical 2) : Second vertical joint, -2.36 to +0.79 rad
Activation : Click the "Mode Manuel Patte" button in the debug interface
Features :
- ๐ฆต Direct control of foot position (x, y, z) for each leg
- Automatic angle calculation via inverse kinematics
Movement Ranges :
- X : -200 to +200 mm
- Y : -200 to +200 mm
- Z : -200 to 0 mm
The robot has 4 legs (ARD, ARG, AVD, AVG) with each having 3 joints :
Base (Chassis)
โโโ ARD (Rear-Right)
โ โโโ Hip
โ โโโ Knee (Tibia)
โ โโโ Foot (Tarsus)
โโโ ARG (Rear-Left)
โ โโโ Hip
โ โโโ Knee
โ โโโ Foot
โโโ AVD (Front-Right)
โ โโโ Hip
โ โโโ Knee
โ โโโ Foot
โโโ AVG (Front-Left)
โโโ Hip
โโโ Knee
โโโ Foot
| Version | Name | Usage |
|---|---|---|
| V1 | RobotSpider | Original |
| V2 | RobotProto | Prototype |
| V3 | RobotSpider | Final |
- Mode Buttons : Select desired mode
- Sliders : Adjust parameters based on active mode
- Camera :
- Right-click + drag : Rotation
- Right-click + Ctrl + drag : Zoom
- Right-click + Shift + drag : Pan
- Q : Quit the simulation
For a leg with segments (coxa, tibia, tarsus), inverse kinematics calculates:
Hip : Base rotation
Knee and Foot : Triangle geometry formed by the segments
coxa = 60 mm # Base segment (coxa)
tibia = 76.84 mm # Intermediate segment (tibia)
tarsus = 128.05 mm # Terminal segment (tarsus)
offset_foot_angle = 0.15708 rad # Foot angle offset (~9.5ยฐ)- URDF Format : Unified Robot Description Format
- STL Files : 3D mesh files for visualization and collision
