To use the Lagrange-Euler Equation we have to define the Lagrangian.
The kinetic energy of the system is:
T=21Iw(θ˙+ϕ˙)2+21Ip(θ˙)
This is the relative velocity of the wheel attached to the pendulum θ˙+ϕ˙.
Then we define the potential function:
V=mglcos(θ)
Where m is the mass of the system, and l is the distance from the pivot to the center of mass.
The Lagrangian equation is:
L=T−VL=21Iw(θ˙+ϕ˙)2+21Ip(θ˙)−mglcos(θ)
Lagrange-Euler Equation
dtd∂q˙∂L−∂q∂L=QiNC
We define q=[θϕ]
Expanding the QiNC term, we have two contributions, the torque of the brushless motor and the friction on the wheel and the body pendulum.
So expanding the Lagrange-Euler Equation becomes:
dtd∂q˙∂L−∂q∂L=τi+Qidiss
Using the Rayleigh Dissipation Function:
R=21bpθ˙2+21bwϕ˙2
Where bp and bw are coefficients of friction respectively of pendulum on the pole and wheel.
Then
Qidiss=−∂q˙∂R
Brushless motor
![[Screenshot 2026-05-07 at 14.56.55.png]]
We can model our brushless motor as a normal DC motor with a good approximation, drawing a typical circuit we can easily identify the torque function of the input voltage.
The motor applies +τ to the wheel and an opposite −τ to the pendulum.
Since the angle ϕ is relative to the position of the pendulum, the work depends on relative displacement.
This is the reason why the internal motor does not net work on global rotation.
For this reason:
τθ=0
The final kinematic equation for the θ component is:
θ¨(Ip+Iw)+Iwϕ¨−mglsin(θ)=−bpθ˙
Component ϕ:
∂ϕ˙∂L=Iwϕ˙+Iwθ˙dtd∂ϕ˙∂L=Iwϕ¨+Iwθ¨
Inserting the torque τϕ and the friction from the Reiligh dissipation function:
Iwϕ¨+Iwθ¨=RaKtVa−RaKtKeϕ˙−bwϕ˙
Now that we have our system of kinematics equation:
This dynamic system is not linear, we can linearise it near an equilibrium point, that is when the pendulum is straight up (θ=0), so that when the angle is small enough we can solve an optimal control problem like LQR.
For small angles sinθ≈θ so our linearised system when the pendulum is straight up becomes: