Skip to content

nopgae/spot-robot-kinematics

Repository files navigation

Boston Dynamics Spot — Kinematic Simulation in Blender

A Python-based kinematic simulation of the Boston Dynamics Spot quadruped robot, implemented inside Blender's scripting environment. The robot2.py module provides a clean OOP interface to programmatically control Spot's body pose, leg positions, and footprint frame — enabling simulation of real robot behaviors without physical hardware.

Tech Stack

  • Language: Python 3 (Blender scripting API — bpy)
  • Math: mathutils (quaternion/matrix operations for 3D transforms)
  • Simulation: Blender 2.8+ (3D viewport + Python console)
  • Concepts: Forward kinematics, homogeneous transformation matrices, Euler angles (ZXY)

Features

  • Full body pose control (yaw, roll, pitch, X/Y/Z translation)
  • Per-leg foot positioning relative to body footprint frame
  • Predefined poses: crouch, stand_tall, power_on/off, pose1/2
  • Configurable leg geometry (hip length, thigh/shin length, foot radius)

Robot API

import robot2

spot = robot2.robot("Spot")
spot.create_robot()

spot.power_on()                                     # Stand up
spot.stand_tall()                                   # Full standing height
spot.transform_body(yaw=15.0, pitch=10.0, Z=2.5)  # Custom body pose
spot.move_foot(legNum=0, X=1.0, Z=-0.5)            # Shift a specific leg
spot.power_off()                                    # Return to rest

Project Structure

.
├── robot2.py              # Core kinematics class
├── spotPython4.blend      # Blender scene with Spot mesh + rig
├── images/
│   ├── spot_twist2.png              # Twist pose in Blender
│   ├── spot-blender_example.JPG     # Blender workspace screenshot
│   ├── ik_workspace.png             # IK solutions + reachable workspace
│   └── body_poses.png               # Body pose configurations
└── README.md

Setup

  1. Install Blender 2.8+
  2. Clone this repo
  3. Copy robot2.py to your Blender modules folder:
    • macOS: ~/Library/Application Support/Blender/<version>/scripts/modules/
    • Windows: %APPDATA%\Blender Foundation\Blender\<version>\scripts\modules\
  4. Open spotPython4.blend in Blender
  5. In the Blender Python Console:
import robot2
spot = robot2.robot("Spot")
spot.create_robot()
spot.power_on()

In Blender

Set up two editor areas (Text Editor + Python Console) as shown in the screenshot. The Python Console lets you send commands to Spot in real time and observe the 3D response in the viewport.

How It Works

The script builds 3D transformation matrices for each body segment using Blender's mathutils.Matrix. Each method computes a chain of homogeneous transforms:

  • Body frame – set by yaw/roll/pitch + XYZ translation
  • Footprint frame – base reference for all foot placements
  • Per-leg frames – derived from hip/thigh/shin lengths and foot offsets

This mirrors the forward kinematics stack used in real robot control software (e.g., Boston Dynamics Spot SDK).

Visualizations

Blender Simulation

Spot twist pose Spot executing a body twist pose — body yaw/roll/pitch controlled via transformation matrix chain

Blender workspace Blender scripting environment: 3D viewport + Python console for real-time kinematic control

Inverse Kinematics Analysis

IK Workspace Left: IK solutions for 4 foot target positions (standing, crouch, step forward/back) · Right: full reachable workspace of the 2-link leg (max reach = 6 Blender units)

Body Pose Configurations

Body Poses Three programmatic body poses — power_off (sitting), crouch (low stance), pose1 (yaw=0.4 rad) — each computed via homogeneous transform matrices

Key Findings & Insights

The leg's maximum reach (6 Blender units = thigh + shin = 3+3) defines the absolute boundary of foot placement, but the practical working envelope is significantly smaller. The IK workspace diagram shows that at maximum extension the leg is nearly fully straightened, leaving zero mechanical advantage for force application — a configuration used for reaching extreme terrain but not sustainable for walking. The optimal operating range (heights −3.5 to −4.5 units, horizontal offset ±1.5 units) occupies roughly 30–40% of the total workspace, balancing joint torque distribution across all three DOF (hip abduction, hip flexion, knee flexion).

The four stance configurations reveal a fundamental stability-mobility tradeoff. The crouch stance (bodyZ=2, symmetric foot placement) maximizes the support polygon area, providing maximum static stability but limiting leg reach for obstacle traversal. Forward and backward step configurations (horizontal offset ±1.5 units) shift the center of mass projection toward the polygon boundary, enabling dynamic locomotion at the cost of static stability margin. This tradeoff — larger support polygon vs. extended reach — is the core design constraint in legged robot motion planning and explains why Boston Dynamics' actual Spot uses a diagonal gait pattern rather than symmetric simultaneous leg lifts.

This kinematic simulation framework maps directly to warehouse AMR (Autonomous Mobile Robot) path planning problems. The move() and transform_body() methods parameterize body pose in 6-DOF (XYZ + yaw/roll/pitch), which is the same state space used in mobile robot localization (SLAM). The IK solver structure — computing joint angles from desired end-effector positions — is the core computation in industrial robot arm controllers for pick-and-place operations, and the reachable workspace analysis is directly applicable to optimizing shelf height placement and picking station ergonomics in automated fulfillment centers.

The current implementation has two significant limitations relative to a production robotics system. First, it computes quasi-static poses but does not implement dynamic balance — there is no contact force estimation, no center-of-mass trajectory planning, and no whole-body impedance control. A real walking controller requires solving a dynamic stability problem (Zero Moment Point or Centroidal Momentum Control) at every timestep. Second, the joint angle solver assumes rigid bodies with exact geometry; the actual Boston Dynamics Spot SDK incorporates compliant joint control and real-time sensor feedback that fundamentally changes the control problem beyond what a kinematic simulator captures.

Relevance to AI / Robotics Roles

  • Demonstrates spatial reasoning and 3D geometric programming
  • Forward kinematics implementation applicable to robotics simulation and digital twin systems
  • Python OOP design for hardware abstraction

Extended as part of IST 402 – Robots & Society, Penn State University (Spring 2025) Based on the open-source spot-blender project

About

Python OOP kinematic simulation of Boston Dynamics Spot robot in Blender. Forward kinematics with homogeneous transformation matrices.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages