YaelBenShalom / Simulating-Jack-in-a-Box

ME_314 final project - Dynamic simulation of planar multi-body system

Home Page:https://yaelbenshalom.github.io/dynamic_simulation/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simulating Jack in a Box

My final project for Theory of Machine Dynamics (ME-314) course at Northwestern University.

Table of Contents

Project Description

In this project, I simulated and animated the dynamics of a planar jack-in-a-box system. The simulation included the dynamic of the multi-body system in time, with external forces applied on the box and impact occurs between the two rigid bodies (the jack and box’s walls).

Both bodies in the planar systems are in gravity (in the -y direction of the world frame). In addition, two external forces are applied to the box – the first is an equal and opposite force to gravity (to ensure the box stays at the same position), and the second is a torque to rotate the box. The applied torque has a sinusoidal form to make the box rotate back and forth in a constant frequency.

The system can be defined using the following configuration valuables:
q = [ x_box, y_box, θ_box, x_jack, y_jack, θ_jack ]

In the projects, both the jack and the box started from rest, in the initial position of (0, 0, 0) relative to the world frame. The world frame is fixed, while the two bodies can translate and rotate freely in the plane. In addition, I added 8 extra frames in the center of each mass to help simulate the impact’s dynamics – 4 frames on the masses of the jack and 4 frames in the center of each wall.

The following image shows the different frames of the dynamic model:

Dynamic Simulation

To simulate the dynamic system, I used a simulation function that calculate the bodies' trajectory using their initial configuration, the time conditions and the integration law. The function uses the dynamics calculated by the Euler-Lagrange equations, and checks for impacts every single iteration.
When impact is detected, the function updates the next configuration according to the impact dynamics laws.

For visualization, the simulation function plots 4 graphs for the box and jack configurations and velocities:

Jack in a box animation:

About

ME_314 final project - Dynamic simulation of planar multi-body system

https://yaelbenshalom.github.io/dynamic_simulation/index.html

License:MIT License


Languages

Language:Jupyter Notebook 100.0%