Skip to content

matagno/spiderbot-simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

20 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

en fr

๐Ÿ•ท๏ธ SpiderBot Simulation - Robot_Bullet_Simulation

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.

Robot walking simulation

๐Ÿ“‹ Table of Contents


โœจ Features

  • 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

๐Ÿ—๏ธ Project Architecture

Main Files

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)

Main Classes

Robot (robot.py)

  • __init__ : Robot initialization with URDF
  • manual_move() : Manual joint control
  • manual_cart_move() : Cartesian leg control
  • autonomous_move() : Autonomous walking with trot
  • update_joint_axes() : Debug display of joint axes

WorldSimulate (world_simulate.py)

  • __init__ : PyBullet client initialization, environment setup
  • load_world() : Load plane (plane.urdf)
  • load_object() : Load robot URDF
  • create_heightfield_ground() : Generate variable terrain

Interface (interface.py)

  • init_auto() : Parameters for autonomous mode
  • init_manual() : Parameters for manual mode
  • init_manual_cart() : Parameters for cartesian mode
  • end_mode() : Debug parameters cleanup

ik_leg() (kinematics.py)

Inverse kinematics calculation for a leg:

  • Input : Target position (x, y, z)
  • Output : Joint angles [hip, knee, foot]
  • Parameters : Segment lengths (coxa, tibia, tarsus)

๐Ÿ“ฆ Installation

Prerequisites

  • Python 3.8+
  • PyBullet
  • NumPy
  • keyboard

Install Dependencies

pip install pybullet numpy keyboard

๐Ÿš€ Usage

Launch the Simulation

python main.py

Debug Mode

To enable debug mode (display joint axes):

debug = True  # In main.py line 13

๐ŸŽฎ Operating Modes

1๏ธโƒฃ Autonomous Mode

Activation : 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 movement
  • Turn : Enable/disable rotation
  • Rotation 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

2๏ธโƒฃ Manual Mode (Joint Control)

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

3๏ธโƒฃ Cartesian Mode

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

๐Ÿฆด URDF Structure

Robot Anatomy

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

Available Models

Version Name Usage
V1 RobotSpider Original
V2 RobotProto Prototype
V3 RobotSpider Final

โŒจ๏ธ Controls

In the Simulation (PyBullet Debug Interface)

  • 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

Keyboard

  • Q : Quit the simulation

๐Ÿ“ Inverse Kinematics

General Formula

For a leg with segments (coxa, tibia, tarsus), inverse kinematics calculates:

Hip : Base rotation $$\text{hip} = \frac{\pi}{2} - \arctan2(y, x)$$

Knee and Foot : Triangle geometry formed by the segments

Default Parameters

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ยฐ)

๐Ÿ“š References

PyBullet Documentation

URDF Files

  • URDF Format : Unified Robot Description Format
  • STL Files : 3D mesh files for visualization and collision

About

Complete PyBullet simulation of a quadruped spider robot with inverse kinematics, multiple control modes, and realistic physics.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages