
Dynamics Engine for Kinematic Chain
I implemented a physics simulator for a 2D kinematic chain with an arbitrary number of links, utilizing the Newton-Euler algorithm for solving dynamics and Euler integration for state updates.
There are two key parts in any physics engine: the solver: at every time step, based on externally applied forces as well as internal constraints, the accelerations were of all the bodies involved. It was done via the Newton-Euler algorithm. The integrator: after computing accelerations, these are numerically integrated to give positions, and velocities at the next time step. It was done using Euler integration.
I coded the dynamics solver to compute forces, torques and accelerations of each link based on force equilibrium, torque equilibrium, consistency of linear acceleration, and consistency of angular acceleration. Euler integration was used to update positions and velocities over discrete time steps.
In the video, there are two robots. The blue one is the example robot. The red one is running my dynamics engine. A given torque is applied to the first joint of the robot, causing it to rotate counter-clockwise. After 8 s, that torque is removed, causing the robot to fall back down. The blue and red robots stay generally together. The Python script supports various command-line arguments that change several characteristics of the simulation and the robot including friction, number of links, time step, time limit, and visualization.