yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
Self-balancing Robot Car📖
00.Get started quickly
  • 01.Balance car manual
  • 02.Balancing car assembly
  • 03.Get started quickly
  • 04.Balance car interface description
  • 05.Common Problem Analysis
  • 06.Balance Car V2 Library Function Development Manual
01.Environment development
  • 01.MDK-ARM installation
  • 02.STM32CubeIDE installation
  • 03.Common driver installation
  • 04.Download the program
  • 05.MDK-ARM project usage
  • 06.Program simulation
  • 07. VSCode Installation
02.STM32 getting started course
  • 01.Project creation
  • 02.LED Control(GPIO)
  • 03.Buzzer control(GPIO)
  • 04.Button control(EXTI)
  • 05.Serial communication(USART)
  • 06.Voltage detection(ADC)
  • 07.Basic timer(TIM)
  • 08.Universal timer(TIM)
  • 09.Advanced Timer(TIM)
  • 10.I2C Communication(I2C)-OLED
  • 11.SPI communication(SPI)-2.4G handle
  • 12.Independent Watchdog (IWDG)
  • 13.Window Watchdog (WWDG)
  • 14.DMA-USART
  • 15.DMA-I2C
03.STM32 expansion course
  • 01.Battery voltage detection (ADC)
  • 02.Ultrasonic module-measuring distance (TIM)
  • 03.Motor drive+encoder (TIM)
  • 04.OLED Data-Display(I2C)
  • 05.MPU6050-Data Read (I2C)
  • 06.Bluetooth module-Data reading (USART)
  • 07.2.4G handle-Data reading (SPI)
  • 08.Tracking module-Read status (GPIO)
  • 09.CCD module-Reading data (ADC)
  • 10.Electromagnetic module-Reading data (ADC)
  • 11.K210 module-Serial communication (USART)
  • 12.Tmini-Plus lidar-Reading data (USART)
04.Robot car PID control course
  • 01.PID basic concept
  • 02.PID example analysis
  • 03.P, PI, PD controller theory
  • 04.Position PID
  • 05.Incremental PID
  • 06.Cascade PID
  • 07.Balance principle of car
  • 08.Car upright control (PD)
  • 09.Car speed ​​control (PI)
  • 10.Car steering control (PD)
  • 11.Got angle and angular velocity (DMP algorithm)
  • 12.Got angle and angular velocity (Kalman filter algorithm)
  • 13.Got angle and angular velocity(Complementary filter algorithm)
05.Robot car basic course
  • 01.Car parameter adjustment
  • 02.Ultrasonic obstacle avoidance
  • 03.Ultrasonic follow
  • 04.Bluetooth remote control
  • 05.Load balance
06.Robot car advanced course
  • 01.4-channel tracking
  • 02.4-channel tracking avoid
  • 03.2.4G handle control
  • 04.CCD tracking
  • 05.CCD tracking avoid
  • 06.Electromagnetic tracking
  • 07.K210-QR code recognition
  • 08.K210-Color line tracking
  • 09.K210-Color follow
  • 10.K210-Self learning
  • 11.K210-Number recognition
  • 12.Lidar avoid
  • 13.Lidar guard
  • 14.Lidar follow
  • 15.Lidar patrol
  • 16.Lidar wall tracking-straight line
  • 17.Lidar wall tracking-multiple walls
  • 18. DIY Automatic driving car
07.Robot car LQR control
  • Robot car LQR control
08.Circuit design
  • 01.Overall circuit design
  • 02.STM32 minimum system
  • 03.Serial port circuit design
  • 04.Power circuit design
  • 05.MPU6050 Circuit Design
  • 06.Motor drive circuit design
09.Mathematical model
  • Mathematical model
10.Expand course
  • Autonomous Driving
Download
  • APP(Android)
  • Codes
  • Hardware-Info
  • SCH
  • Software Tools
  • STM32_Chip_DataSheet
  • 3D_Model_File
  • Video_PPT
Download ZIP

Welcome to Self-balancing Robot Car repository

Mathematical model

Balance car mathematical model

Balance car mathematical modelClassic inverted pendulum mathematical modelBalance car mathematical modelWheel modelCar body modelForward motionSteering movement

 

Classic inverted pendulum mathematical model

The inverted pendulum system usually consists of a rotatable rod and a mass block, the mass block is located at one end of the rod, and the entire system is controlled by a motor or other driver.

xxxxxxxxxx
The goal of controlling the inverted pendulum system is to keep the mass block in a vertical position and be robust to external interference

Figure (a) is a simplified model diagram of the inverted pendulum system, and Figure (b) is a force analysis diagram of the inverted pendulum system

image-20240921145253686

Instructions

image-20240921145404245

Based on Newton's mechanics and theorem of motion, the process of deriving the dynamic equation of the linear inverted pendulum system is as follows: Analyze the force balance of the car in the horizontal direction

image-20240921145531686

Analyze the force balance of the pendulum in the horizontal direction, and we can get:

image-20240921145514168

(1) and (2) In the equations, N is the interaction force between the slider and the pendulum in the horizontal direction. Combining the two equations (1) and (2) eliminates N, we get the first nonlinear dynamics model equation of the first-order linear inverted pendulum:

image-20240921145611963

Analyzing the force balance of the pendulum in the vertical direction, we get:

image-20240921145635811

Analyzing the moment balance of the pendulum around its center of mass, we get:

image-20240921145656266

In equations (2), (4), and (5), N and P are the interaction forces between the slider and the pendulum in the horizontal and vertical directions. Combining equations (2), (4), and (5) eliminates P, N, we get the second nonlinear dynamic model equation of the first-order linear inverted pendulum:

image-20240921145751308

The inverted pendulum is stable when -0.3rad < Φ <0.3rad, and the swing angle Φ is very small, so:

image-20240921145818901

Therefore, the nonlinear dynamic equation (3) of the inverted pendulum system can be Linearize with (6) to obtain the linearized dynamic equation of the first-order linear inverted pendulum system:

image-20240921145850123

Remember the state vector:

image-20240921145927483

With u=F, according to equation group (7) The state space equation of the first-order linear inverted pendulum system is as follows:

image-20240921150027126

image-20240921150045738

Balance car mathematical model

The balance car is a small car that achieves self-balancing through two wheels. Its structure mainly consists of a car body and two wheels. The mathematical model can be regarded as a moving inverted pendulum.

xxxxxxxxxx
The MPU6050 detects its posture information, and after processing by the processor, it will control the robot's motor so that the robot can reach a stable state.

Wheel model

The force analysis diagram of the left and right wheels of the two-wheeled robot is shown in the figure. The horizontal force of the robot is the vector sum of the friction between the wheel and the ground and the horizontal force between the body and the wheel.

The movement of the balancing car is achieved by the rotation of the wheels. We choose a pair of coaxially installed wheels with the same parameters (mass, moment of inertia, radius).

Take the right wheel as an example for force analysis:

image-20240921141154399

The movement of the wheel can be decomposed into translation and rotation, and Newton's second law can be obtained:

image-20240825221517308

From the law of rigid body fixed axis rotation, it can be obtained:

image-20240825221535659

Explanation

image-20240825222110723

Combining (1) and (2), we get:

image-20240825222213573

When the wheel does not slip, the speed of the wheel is proportional to the speed of rotation, that is,

image-20240825222 238194

Combining (3) and (4), we get:

image-20240825222316354

Since the parameters of the left and right wheels are the same, the left wheel has a similar result, that is,

image-20240825222335244

Car body model

The movement of the car body can also be decomposed into forward movement (forward, pitch) and lateral movement (steering, yaw): yaw movement can be regarded as a special case of steering movement.

Forward motion

The forward motion of the car can be decomposed into forward motion and relative rotation (pitch) around the center of mass P of the car body:

image-20240921141426563

The horizontal displacement of the center O of the chassis of the car is:

image-20240825223350923

Add equations (5) and (6) together, and divide both sides of the equation by 2 to get:

image-20240825223450159

Apply Newton's second law to the car body, in the horizontal direction:

image-2024082 5223602940

Apply Newton's second law to the car body, in the vertical direction:

image-20240825223612137

Apply the law of rigid body fixed axis rotation to the car body and we get:

image-20240825223638158

Explanation

image-20240825223707991

The combined equations (9) and (10) yield:

image-20240825223846078

Among them:

image-20240825224005898

The equation contains nonlinear terms, so it is linearized. Considering that the inclination angle of the vehicle body is relatively small, it can be considered that:

image-20240825224317215

Therefore, equation (13):

image-20240825224343500

Substitute equations (10) and (11) into equation (12):

image-20240825224431803

Linearize equation (15):

image-20240825224509442

Substitute equation (16) into equation (14):

image- 20240825224544717

image-20240825224614937

In summary, for forward motion:

image-20240825224702844

Steering movement

image-20240921141547236

The steering movement is caused by the unequal magnitudes of the reaction forces HL and HR applied to the vehicle body by the left and right wheels in the horizontal direction. According to the law of rigid body fixed axis rotation, we can get:

image-20240825225038872

Explanation

image-20240825225058285

Subtract equations (5) and (6) to get:

image-20240825225134542

When the left and right wheels have different speeds, the vehicle body turns:

image-20240825225213278

According to the geometric relationship, we can get:

image-20240825225525566

From equations (19) and (25), we can get the state equation of the system:

image-20240825225632177

The state variables represent the displacement, forward speed, inclination angle, angular velocity, steering angle and steering speed of the car.

Since the magnitude of the motor output torque is difficult to control directly, it is converted into the acceleration of the two wheels through the law of rigid body fixed axis rotation:

image-20240825225719369

The left side of equation (27) is the magnitude of the linear velocity of the left/right wheel when there is no friction (in rad/s).

Therefore, the state space expression of the system becomes:

image-20240825230023208

Motor drive circuit design
Autonomous Driving

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文