Simple inverted pendulum simulation using Python
An exercise in visualization of the equations of motion. The ultimate goal is to simulate an inverted pendulum using a nonlinear system of equations. Additionally, the object can be stimulated by three signals (sine, triangle and square).
System Parameters:
- initial angle (Φ)
- pendulum mass (m)
- pendulum length (L)
- coefficient of friction (b)
- input signal (Ƭ)
Fixed data:
- acceleration of gravity (g ≈ 9.81 ms/s^2)
Equations:
Model:
- ω angular velocity
- φ angular displacement
A non-linear differential equation - solved with Fourth Order RK-Method
Project is created with:
- Python 3.9
- PyQt5
- Numpy 1.21.4
- Matplotlib 3.5.0
Running file named main.py
length and mass must by int values
Angle and friction could be float values
- Example
- frition = 1
- initial angle = 0.001 [°]
- length = 3 [m]
- mass = 1 [kg]
- input signal = zero
For these data we can observe that the pendulum from the vertical position (at the top) rotated (down) by 180° and due to the high value of friction it completely decelerated and remained in this position.
2. Example
- frition = 1
- initial angle = 0.001 [°]
- length = 3 [m]
- mass = 1 [kg]
- input signal = triangular
The pendulum has rotated 180° and oscillates about this value according to the triangular excitation slowly decaying.
3. Example
- frition = 0
- initial angle = 1 [°]
- length = 1 [m]
- mass = 1 [kg]
- input signal = zero
We see a non-decaying oscillation, the pendulum is moving on an angle interval (0, 360). Obviously, does not cross the vertical. These are harmonic vibrations.
4. Example
- frition = 0.1
- initial angle = 0.1 [°]
- length = 1 [m]
- mass = 1 [kg]
- input signal = rectangular
This is the first time that the pendulum has swung in the opposite direction from the previous examples. This was due to the rectungular input signal, which caused the pendulum to moved opposite to the action of gravity at first.
To run this project...