This project provides a simulation of the SLIP (Spring Loaded Inverted Pendulum)
model in 3D motion using PyBullet. The model allows you to adjust various parameters for the simulation. It includes kinematic equations that can be utilized for other simulations, and the project comes with a pre-configured URDF file that you can modify.
- SLIP Model Simulation in 3D Motion
The SLIP model is a simplified model used to describe the kinematics of a running or hopping robot. In this project, we simulate the SLIP model in 3D motion, where you can adjust physical parameters such as spring stiffness, spring length and mass. This simulation provides insights into the behavior of a spring-loaded inverted pendulum in simulation environments, and can be useful for researchers and engineers working in robotics.
- 3D simulation of the SLIP model using PyBullet
- Configurable physical parameters for the simulation (spring stiffness, spring length, etc.)
- Kinematic equations available for other simulations
- Pre-configured URDF file, which can be modified
- Python 3.x
- Matplotlib
- PyBullet
- Pygame
- NumPy
- Clone this repository:
git clone https://github.com/FRA333-Kinematics-of-Robotics-System/SLIP-Model-Simulation.git
- Moving path to project directory:
cd SLIP-Model-Simulation
- Install the required Python packages:
pip install -r requirements.txt
- Open Visual Studio Code for run a python:
code .
You can modify the following parameters to customize the simulation:
- Mass of the robot (kg)
- Stiffness of the spring (N/m)
- Velocity of spring compressed (m/s)
- Angular velocity in
$\theta$ and$\phi$ (rad/s)
- Jump number count for SLIP simulation.
The project includes a pre-configured URDF file for the robot. You can modify the URDF file to change the robot's design or parameters. The URDF file can be found in the urdf/
directory. If you modified a URDF file you will need to change a STL file in meshes/
too, for this project we use URDF file and STL from that export from SolidWorks
.
This project have an example simulation in SLIP/
directory, you can run a program using Visual Studio Code for avoid any problem cause develop use Visual Studio Code too.
In SLIP directory contains 2 python file that you can use.
-
Pybullet_Simulation_with_graph.py
This file run a SLIP simulation with a Matplotlib graph for visual and debugging.
-
Pybullet_Simulation.py
This file run only a SLIP simulation using Pybullet.
You can easily run those filw using run button on the top right of a Visual Studio Code windows.
After run a program Pybullet simulation will pop-up you can adjust parameter before lauch a SLIP, then press ENTER
for start a simulation
The following kinematic equations are utilized in the project.
from
Euler-Lagrange Equation for
Euler-Lagrange Equation for
Euler-Lagrange Equation for
Equation for
To find
Euler-Lagrange Equation for
To find
Euler-Lagrange Equation for
To find
For
where:
-
$r(t)$ is the length of the spring compressed. -
$\theta(t)$ is the orientation of robot in z axis . -
$\phi(t)$ is the orientation of robot between xy axis. -
$m$ is the mass of the robot. -
$g$ is the acceleration due to gravity. -
$k$ is the spring constant. -
$r_0$ is the length of the spring.
Projectile motion
where:
-
$x_c, y_c, z_c$ are the mass position.
where:
-
$x_i, y_i, z_i$ are the initial position before projectile. -
$\dot{x}_i, \dot{y}_i, \dot{z}_i$ are the initial velocity components before projectile. -
$g$ is the acceleration due to gravity.
Where:
-
$x(t)$ : The x-coordinate of the center of mass position. -
$y(t)$ : The y-coordinate of the center of mass position. -
$z(t)$ : The z-coordinate of the center of mass position.
def InitialState(_r0=1.0, _r=0.3, _theta=np.pi/6, _phi=np.pi/6, _r_dot=0.0, _theta_dot=0.0, _phi_dot=0.0, _g=-9.81)
The InitialState
function initializes and returns the initial state parameters for system.
Needed Parameters:
-
_r0
(default: 1.0): Length of the spring (m) -
_r
(default: 0.3): Length of the spring compressed (m) -
_theta
(default: π/6): Starting orientation of the robot in z axis (in radians) -
_phi
(default: π/6): Starting orientation of the robot between xy axis (in radians) -
_g
(default: -9.81): Gravitational acceleration ($m/s^2$ )
def StancePhase(m, k, r0, g, time_step, r, r_dot, theta, theta_dot, phi, phi_dot ,spring_x, spring_y, spring_z)
The StancePhase
function simulates the kinematics of a Spring-Loaded Inverted Pendulum (SLIP) from equation giving before, during its stance phase, calculating the motion and position of a mass.
Needed Parameters:
-
m
: Mass of the robot (kg) -
k
: Spring constant (N/m) -
r0
: Length of the spring (m) -
g
: Gravitational acceleration ($m/s^2$ ) -
time_step
: Simulation time increment (s) -
r
: Length of the spring compressed (m) -
theta
: Orientation of the robot in z axis (in radians) -
phi
: Orientation of the robot between xy axis (in radians) -
spring_x
,spring_y
,spring_z
: Position of spring attachment coordinates
Return:
- Absolute mass point coordinates (
mass_x
,mass_y
,mass_z
)
def StancePhaseControl(m, k, r0, g, time_step, r, r_dot, theta, theta_target, theta_dot, phi, phi_dot ,spring_x, spring_y, spring_z, Kp, Kd):
The StancePhaseControl
function simulates the kinematics of a Spring-Loaded Inverted Pendulum (SLIP) from equation giving before, during its stance phase, calculating the motion and position of a mass with a Kp
and Kd
control.
Needed Parameters:
-
m
: Mass of the robot (kg) -
k
: Spring constant (N/m) -
r0
: Length of the spring (m) -
g
: Gravitational acceleration ($m/s^2$ ) -
time_step
: Simulation time increment (s) -
r
: Length of the spring compressed (m) -
theta
: Orientation of the robot in z axis (in radians) -
phi
: Orientation of the robot between xy axis (in radians) -
spring_x
,spring_y
,spring_z
: Position of spring attachment coordinates -
Kp
: Proportional gain for theta control -
Kd
: Derivative gain for theta control
Return:
- Absolute mass point coordinates from a PD control (
mass_x
,mass_y
,mass_z
)
def StanceToFlight(mass_x, mass_y, mass_z, theta, phi, r_dot, r, theta_dot, phi_dot):
The StanceToFlight
function manages the transition from stance to flight phase in a SLIP (Spring-Loaded Inverted Pendulum) robot model, calculating initial conditions for the flight phase.
Needed Parameters:
-
mass_x
: X-coordinate of the mass (m) -
mass_y
: Y-coordinate of the mass (m) -
mass_z
: Z-coordinate of the mass (m) -
theta
: Orientation of the robot in z axis (in radians) -
phi
: Orientation of the robot between xy axis (in radians) -
r
: Length of the spring compressed (m)
Returns:
- Absolute spring point coordinates (
spring_x
,spring_y
,spring_z
)
def FlightPhase(x_i, y_i, z_i, r, theta, phi, theta_i, t, g, dx, dy, dz, T):
The FlightPhase
function simulates the kinematics of a Spring-Loaded Inverted Pendulum (SLIP) from equation giving before, during its flight phase, calculating the motion and position of a mass in projectile motion.
Needed Parameters:
-
x_i
: X-coordinate position before projectile. -
y_i
: Y-coordinate position before projectile. -
z_i
: Z-coordinate position before projectile. -
r
: Length of the spring compressed (m) -
theta
: Orientation of the robot in z axis (in radians) -
phi
: Orientation of the robot between xy axis (in radians)
Returns:
-
Absolute spring point coordinates (
spring_x
,spring_y
,spring_z
) -
Absolute mass point coordinates (
mass_x
,mass_y
,mass_z
) -
New
theta
for flight phase.
The simulation was conducted using the following parameters:
Parameter | Value | Unit |
---|---|---|
Mass (m ) |
1.0 | kg |
Spring Stiffness (k ) |
100 | N/m |
Spring Compression Rate (dr ) |
-6 | m/s |
Angular Velocity in dtheta ) |
1.0 | rad/s |
Angular Velocity in dphi ) |
1.0 | rad/s |
SLIP Jump Count (count ) |
4 | count |
In this configuration, the simulation does not use proportional-derivative (PD) control for stabilization. Below is the result:
Video (without PD Control)
Graphs (without PD Control) To further illustrate the behavior, below are graphs of key parameters over time (e.g., x, y, z, theta):
- Observations:
- Over time, the system fails to maintain balance, causing the robot to lose its ability to perform multiple consecutive jumps.
With the addition of PD control, the simulation achieves เพื่อให้โมเดลสามารถกระโดดไปได้เรื่อยๆ. Below is the result:
when kp
: 37 and
kd
: 20
Video (with PD Control)
Graphs (with PD Control) To further illustrate the behavior, below are graphs of key parameters over time (e.g., x, y, z, theta):
- Observations:
- The system is effectively stabilized using PD control gains (Kp and Kd), allowing the robot to maintain consistent jumping behavior across multiple cycles.
- From the graphs, it is evident that the theta value changes more smoothly compared to the simulation without PD control.
- The smoother control of theta prevents abrupt oscillations, enabling the robot to sustain consecutive jumps.
- However, as the number of jumps increases, small errors in theta accumulate, leading to a gradual drift in the model. This occurs because the simulation does not use a closed-loop control system to correct accumulated errors.
This simulation effectively demonstrates the motion of a 3D Spring-Loaded Inverted Pendulum (SLIP) model under two control configurations: with and without PD control. Without PD control, the system struggles to maintain balance, resulting in erratic and unstable behavior during jumps. In contrast, the introduction of PD control significantly enhances stability, allowing the system to perform smooth and continuous jumps. However, over time, small errors in theta accumulate due to the lack of a closed-loop control mechanism, which limits long-term performance.
The results highlight the importance of control strategies in robotic systems. PD control ensures that theta changes as expected, allowing the model to move smoothly and continuously. This makes it effective for achieving stability in the short term. However, for longer-term performance, error accumulation in theta becomes noticeable, eventually affecting the model's ability to maintain consistent motion. A closed-loop control system or advanced strategies would be necessary to address this issue.
Additionally, the simulation currently lacks real-world factors such as friction, ground irregularities, and sensor noise, which could significantly impact the behavior of the system in practical applications.
Future work could focus on refining the control parameters, incorporating environmental variability, and applying the findings to real-world scenarios, such as legged or hopping robots. These steps would help to better understand the dynamics and limitations of the SLIP model.
Apichaya Sriwong - ImJAiiiii - Developer Researcher
Poppeth Petchamli - Toonzaza - Developer
Vasayos Tosiri - TeeTyJunGz - Developer