You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Control Two Wheeled Self Balancing Robot using LQR controller
1. Simulation Results
2D Simulation
In this model, the robot's state is represented by the position and velocity of the center of mass (COM) and the angular velocities of the wheels
3D Simulation
In this model, the robot's state is represented by the position, velocity, and angular velocities (roll, pitch, and yaw) of the center of mass (COM) and the angular velocities of the wheels
2. Dynamic equations
In the repository, I am only presenting the equations for the 3D model.
Modeling Robot
Symbol
Unit
Description
$\theta_{(l,r)}$
Rad
Angle of the left and right wheels
ψ
Rad
Tilt angle of the robot body
ϕ
Rad
Rotation angle of the robot
The dynamics of the two wheeled self-balancing robot can be described by the following system of differential equations:
Parameters Robot
Symbol
Unit
Description
$m$
Kg
Mass of the wheel
$M$
Kg
Mass of the robot
$R$
M
Radius of the wheel
$W$
M
Width of the robot
$D$
M
Length of the robot
$H$
M
Height of the robot
$L$
M
Distance from the robot's center of mass to the axle
$f_w$
Friction coefficient between the wheel and the plane
$f_m$
Friction coefficient between the robot and the DC motor
$I_m$
kg·m²
Moment of inertia of the DC motor
$R_m$
Ohm
Resistance of the DC motor
$K_b$
V·sec/rad
EMF coefficient of the DC motor
$K_t$
Nm/A
Torque coefficient of the DC motor
$N$
Gear reduction ratio
$G$
m/s²
Gravitational acceleration
$\theta$
Rad
Average angle of the left and right wheels
$\theta_{(l,r)}$
Rad
Angle of the left and right wheels
$\psi$
Rad
Tilt angle of the robot body
$\phi$
Rad
Rotation angle of the robot
$x_l, y_l, z_l$
M
Coordinates of the left wheel
$x_r, y_r, z_r$
M
Coordinates of the right wheel
$x_m, y_m, z_m$
M
Average coordinates
$F_\theta, F_\psi, F_\phi$
Nm
Torque generated in different directions
$F_{(l,r)}$
Nm
Torque generated by the left and right motors
$i_l, i_r$
A
Current through the left and right motors
$v_l, v_r$
V
Voltage across the left and right motors
Dynamic equations
Apply the Euler-Lagrange equations to the robot's dynamics:
$T$: The sum of the kinetic energy components of the system.
$V$: The sum of the potential energy components of the system.
$L_{\text{lagrange}} = T - V$: The Lagrangian multiplier.
$q_i$: A generalized coordinate describing one of the degrees of freedom in the system.
$F_k$: The total external force acting on the system corresponding to the generalized coordinates $q_i$.
For the 3-degree-of-freedom model, there are three generalized coordinates: $q_1 = x$ (The horizontal motion); $q_2 = \theta$ (The tilt angle); $q_3 = \psi$ (The rotation angle of the robot body).
Assuming at time $t = 0$, the robot moves in the positive direction of the x-axis. The dynamic equations describing the motion of the robot are as follows:
Linearizing the robot at the equilibrium point (where all initial state variables are zero) allows for accurate determination of the matrices $A_0$ and $B_0$ for the equilibrium condition, where the robot is assumed to be stable.
The working point chosen to proceed with the linearization of the robot to a linear form $\dot{X} = A_0 X + B_0 U$ is as follows:
Working point: