Simulation Demo

Link to the full code Open In Colab

Project Overview

Tech Stack: Python, SymPy, NumPy, Plotly

This project models the dynamics of a Jack (a cross-shaped rigid body) bouncing inside a moving cup (square box). The system combines continuous differential equations of motion with discrete impact events.

Technical Implementation

1. Symbolic Lagrangian Dynamics

I used SymPy to mathematically derive the Equations of Motion (EOM) from scratch using the Euler-Lagrange method.

  • SE(3) Formulation: Modeled the 6-DOF configuration space using transformation matrices for the Cup frame and Jack frame.
  • Symbolic Derivation: Automatically calculated the Mass Matrix and Coriolis/Gravity terms by taking the Jacobian of the Lagrangian with respect to the state vectors.

2. Impact & Collision Handling

The core challenge was handling the discrete jumps in velocity when the Jack hits the Cup walls.

  • Geometric Constraints: Defined boundary conditions for all 4 walls of the cup relative to the 4 tips of the jack.
  • Impulse Solver: Implemented an impact update law that solves for the instantaneous change in velocity and the constraint force by solving the system of linear equations derived from the impact Hamiltonian.