Robotics / Kinematics

Quadruped Leg Kinematics

I assembled an open-source quadruped platform with four 3-DOF legs, developed an object-oriented Python kinematics framework, and built a physics simulation of the robot from its own 3D-printed part files that walks, turns, and jumps in MuJoCo.

IN PROGRESSKinematics framework developed / physical platform assembled / walking, turning and jumping in MuJoCo simulation / hardware locomotion in progress.
Fully assembled quadruped platform
FIG. 00The assembled four-leg platform
Overview

I assembled an open-source quadruped platform with four 3-DOF legs. Each leg consists of a Coxa, Femur, and Tibia. I developed a Python object-oriented framework for forward kinematics, inverse kinematics, servo control, joint-angle based control, end-effector coordinate based control, and workspace visualization. I then built a MuJoCo physics simulation of the robot directly from its STL print files: joint pivots were located from the servo-mount and bearing holes in the meshes, the model was validated against my NumPy forward kinematics, and the simulated robot walks with a statically stable crawl gait, turns in place by driving its left and right legs in opposite directions, and jumps about 11 cm using the same servo torque limits. The physical quadruped is assembled but is not currently walking, and hardware issues are still being worked through.

Key specifications
  1. 014 x 3-DOF leg design
  2. 02Forward and inverse kinematics framework
  3. 03Joint-angle and end-effector coordinate control
  4. 04Workspace visualization
  5. 05MuJoCo simulation built from the printed STL parts, validated against the FK model
  6. 06Statically stable crawl gait walking in simulation
  7. 07In-place turning at about 14°/s with tank-steer leg control
  8. 08Crouch-and-thrust jump: about 11 cm of liftoff, lands upright
Document
Hand derivation of the 3D forward kinematics5 pages · PDFOpenDownload

Five handwritten pages, from the coordinate frames to the closed-form foot position R_y(θc)·R_z(θf)·R_z(θt). The final formula matches numpyfk3d.py exactly.

This browser can’t show the PDF inline.

Open PDF
Code
numpyfk3d.py3D forward kinematics for one 3-DOF leg
import numpy as np

class Leg:
    def __init__(self, lc, lf, lt):
        self.lc = lc
        self.lf = lf
        self.lt = lt

    # Coxa endpoint in global coordinates
    def coxa(self, theta_c):
        return np.array([
            self.lc * np.cos(np.radians(theta_c)),
            0,
            -self.lc * np.sin(np.radians(theta_c))
        ])

    # Knee position in global coordinates
    def femur(self, theta_c, theta_f):

        hip_position = self.coxa(theta_c)

        theta_c_rad = np.radians(theta_c)
        theta_f_rad = np.radians(theta_f)

        femur_rel_coxa = np.array([
            [np.cos(theta_c_rad), 0, np.sin(theta_c_rad)],
            [0, 1, 0],
            [-np.sin(theta_c_rad), 0, np.cos(theta_c_rad)]
        ])

        femur_local = np.array([
            self.lf * np.cos(theta_f_rad),
            self.lf * np.sin(theta_f_rad),
            0
        ])

        knee_position = hip_position + femur_rel_coxa @ femur_local

        return knee_position

    # Foot position in global coordinates
    def tibia(self, theta_c, theta_f, theta_t):

        knee_position = self.femur(theta_c, theta_f)

        theta_c_rad = np.radians(theta_c)
        theta_f_rad = np.radians(theta_f)
        theta_t_rad = np.radians(theta_t)

        femur_rel_coxa = np.array([
            [np.cos(theta_c_rad), 0, np.sin(theta_c_rad)],
            [0, 1, 0],
            [-np.sin(theta_c_rad), 0, np.cos(theta_c_rad)]
        ])

        femur_rotation = np.array([
            [np.cos(theta_f_rad), -np.sin(theta_f_rad), 0],
            [np.sin(theta_f_rad), np.cos(theta_f_rad), 0],
            [0, 0, 1]
        ])

        tibia_rel_femur = np.array([
            [np.cos(theta_t_rad), -np.sin(theta_t_rad), 0],
            [np.sin(theta_t_rad), np.cos(theta_t_rad), 0],
            [0, 0, 1]
        ])

        tibia_local = np.array([self.lt, 0, 0])

        foot_position = (
            knee_position
            + femur_rel_coxa @ femur_rotation
            @ tibia_rel_femur @ tibia_local
        )

        return foot_position


# Testing
if __name__ == "__main__":

    leg = Leg(3, 5.6, 8)

    print("Test 1:", leg.tibia(0, 0, 0))
    print("Test 2:", leg.tibia(0, 90, 0))
    print("Test 3:", leg.tibia(0, 30, 40))
    
Next steps
  • Resolve hardware issues
  • Transfer the simulated gaits to the physical robot
  • Continue locomotion development
Build log

Build details

05 items