Self-balancing vehicle control method and system based on steering control
By dynamically adjusting the balance median and using LQR/PID control, the balance and steering control of the self-balancing vehicle are coordinated, solving the stability problem during steering and achieving stable handling and smoothness of the vehicle during cornering.
Patent Information
- Application Number
- CN202511362897.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-23
- Publication Date
- 2026-02-03
AI Technical Summary
In existing self-balancing vehicles, the balance command and steering command are often independent of each other when turning, which complicates the system control logic and affects the stability and safety of the vehicle when turning.
By collecting vehicle attitude information in real time, the balance median is dynamically adjusted to respond to steering commands. By combining LQR optimal control and incremental PID control, balance and steering control are coordinated so that the two work together.
It significantly improves the vehicle's handling stability and smoothness when cornering, enhances the system's anti-interference ability and control precision, is compatible with multiple steering input methods, and achieves stable steering and balance coordination.
Smart Images

Figure CN121454894A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of balancing vehicles, in particular to a self-balancing vehicle control method and system based on steering control. BACKGROUND
[0002] Two-wheeled self-balancing vehicles, such as self-balancing bicycles or balance cars, have attracted widespread attention due to their flexible maneuverability. The core challenge lies in how to maintain the static unstable balance of the vehicle body, which requires a real-time and efficient control system. In the prior art, an inertial measurement unit (IMU) is generally used to detect the vehicle body attitude, and a control algorithm is used to calculate a balancing instruction to drive an execution motor (such as a rudder) to maintain the vehicle upright. However, when the vehicle needs to turn, the traditional control strategy faces a significant problem: the steering instruction and the balancing instruction are often generated independently of each other. Specifically, after receiving the steering instruction, the vehicle usually directly drives the front wheel steering mechanism to execute the turning action, while the balancing instruction continuously output by the vehicle to maintain balance may conflict with the steering instruction. This coupling and conflict between instructions will complicate the system control logic and introduce unnecessary interference during turning, causing the vehicle to lose stability during turning, resulting in the risk of shaking or even losing control, affecting the safety and smoothness of riding. Therefore, how to fundamentally coordinate the balance and steering control so that they work together rather than compete with each other has become a technical problem that needs to be solved in this field. SUMMARY
[0003] The purpose of the present application is to provide a self-balancing vehicle control method and system based on steering control to fundamentally coordinate the balance and steering control so that they work together rather than compete with each other.
[0004] To achieve the above-mentioned purpose, the following technical solutions are adopted.
[0005] A self-balancing vehicle control method based on steering control, comprising the following steps:
[0006] Real-time acquisition of vehicle body attitude information of the self-balancing vehicle;
[0007] Based on the vehicle body attitude information and a dynamic balance median value, a balance control instruction for maintaining the balance of the vehicle is calculated;
[0008] Receiving a steering instruction from a steering input device;
[0009] According to the steering instruction, the value of the dynamic balance median value is dynamically adjusted to generate a target balance median value offset, so that the vehicle autonomously generates a steering motion to maintain balance at a new target balance point;
[0010] The dynamic balance median adjusted based on the target balance median offset is used for subsequent balance control instruction calculation.
[0011] Optionally, the specific steps of calculating the balance control instruction based on the vehicle body posture information and the dynamic balance median include:
[0012] The state variables including the vehicle body inclination angle, the vehicle body inclination angle velocity and the front fork turning angle are constructed based on a bicycle dynamics model; the optimal state feedback calculation is performed on the state variables by using a linear quadratic regulator (LQR) algorithm with the dynamic balance median as the control target, the state feedback gain matrix is obtained by solving a Riccati equation, and the front fork target turning speed instruction for controlling the vehicle balance is calculated based on the gain matrix, wherein the cost function of the LQR algorithm considers both the state variable error and the control amount consumption.
[0013] Optionally, after the front fork target turning speed instruction is output, the step of controlling the actuator is further included:
[0014] The front fork target turning speed instruction is taken as an input deviation of a proportional-integral-derivative (PID) controller; the input deviation is subjected to incremental PID operation by the PID controller to calculate a pulse width modulation (PWM) control signal for driving the steering mechanism to turn, wherein the incremental PID operation is based on the front fork target turning speed instruction values at the current time and at the historical time, calculates the PWM control signal increment value at the current time relative to the last time, and adds the increment value to the PWM control signal value at the last time to obtain the final PWM control signal value at the current time.
[0015] Optionally, the specific steps of calculating the control signal for driving the steering actuator by the PID controller include:
[0016] The incremental PID control algorithm is adopted to calculate the PWM control signal increment to be output to the steering actuator at the current time according to the front fork target turning speed instruction at the current sampling time, the front fork target turning speed instruction at the last sampling time and the front fork target turning speed instruction at the second last sampling time by the formula
[0017] The PWM control signal increment to be output to the steering actuator at the current time is calculated, wherein represents the front fork target turning speed instruction at the current time, represents the front fork target turning speed instruction at the last sampling time, The value represents the target steering speed command for the fork at the sampling time two steps prior. Kp, Ki, and Kd are the proportional, integral, and derivative coefficients, respectively. The calculated increment of the PWM control signal is added to the PWM control signal value at the previous time step to obtain the final PWM control signal value at the current time step, which is used to drive the servo motor to achieve precise steering angle control.
[0018] Optionally, the specific steps for dynamically adjusting the dynamic balance median value according to the steering command include:
[0019] When a valid steering command is received, the current dynamic balance median is first recorded as the steering reference median. Then, based on the direction determination result of the steering command, a preset deviation amount corresponding to left steering is added to the steering reference median or a preset deviation amount corresponding to right steering is subtracted, thereby obtaining the adjusted target dynamic balance median.
[0020] Optionally, after the turn is complete, the following may also be included:
[0021] When a steering command failure is detected, the dynamic balance median is restored to the steering reference median.
[0022] A self-balancing vehicle control system based on steering control, comprising:
[0023] An attitude sensing module is used to detect vehicle attitude information in real time. The attitude sensing module includes a gyroscope and an accelerometer sensor.
[0024] Steering input module, used to receive steering commands from user or external device;
[0025] The control processing module is electrically connected to the attitude sensing module and the steering input module. The control processing module is used to perform functions such as vehicle attitude information acquisition, dynamic balance median calculation, steering command processing, and balance control command generation.
[0026] The steering execution module is electrically connected to the control processing module and is used to execute steering actions according to the control signals output by the control processing module. The steering execution module includes a servo drive circuit and a servo.
[0027] Optionally, the control processing module includes a mutually cooperating LQR control unit and a PID control unit:
[0028] The LQR control unit is used to construct state variables based on the bicycle dynamics model, and with the dynamic equilibrium median as the control target, it uses a linear quadratic regulator algorithm to perform optimal state feedback calculation on the state variables and outputs the front fork target steering speed command.
[0029] The PID control unit is connected to the LQR control unit and is used to receive the target steering speed command of the fork as the input deviation, and to calculate the PWM control signal to drive the steering execution module through an incremental PID algorithm.
[0030] Optionally, the steering input module may be a combination of any one or more of the following devices:
[0031] The electric power steering system (EPS) is used to generate steering commands in the form of electrical signals.
[0032] The manual steering mechanism uses sensors to convert mechanical steering actions into steering commands in the form of digital signals.
[0033] A wireless remote control device used to receive and transmit wireless steering commands from an external control device.
[0034] Optionally, the steering actuation module uses a servo motor as the actuator, and the control signal output by the control processing module to the servo motor is a pulse width modulation (PWM) signal. The duty cycle of the PWM signal is linearly related to the rotation angle of the servo motor, wherein the range of the duty cycle variation of the PWM signal corresponds to the range of the rotation angle of the servo motor.
[0035] Compared with the prior art, the present invention has the following beneficial effects:
[0036] This invention responds to steering commands by dynamically adjusting the balance median, internalizing the steering requirement as the goal of the balance control system itself. This allows the vehicle to autonomously generate steering motion to maintain stability at the new target balance point, thus fundamentally avoiding logical conflicts between balance and steering commands and significantly improving the vehicle's handling stability and smoothness during cornering. Furthermore, by introducing the LQR optimal control algorithm for precise feedback calculation of the vehicle state, optimal dynamic performance and anti-interference capability are ensured under different operating conditions. An incremental PID algorithm is further employed to servo-track the LQR output commands, enhancing the accuracy and rapid response of actuator control. The modular hardware design of the system is compatible with multiple control input methods such as electric power steering, manual steering, and wireless remote control. Through a unified signal processing and output architecture, flexible application of control strategies and strong system adaptability are achieved, effectively improving the overall performance and practical value of the entire system. Attached Figure Description
[0037] Figure 1 This is a schematic flowchart illustrating the steps of an embodiment of a self-balancing vehicle control method based on steering control according to the present invention.
[0038] Figure 2 This is a schematic diagram of the module structure of an embodiment of a self-balancing vehicle control system based on steering control according to the present invention. Detailed Implementation
[0039] The present invention will now be described in detail with reference to the accompanying drawings and embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other.
[0040] The following detailed description is exemplary and intended to provide further detailed explanation of the invention. Unless otherwise specified, all technical terms used in this invention have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. The terminology used in this invention is for the purpose of describing particular embodiments only and is not intended to limit the scope of exemplary embodiments according to the invention.
[0041] Example 1
[0042] like Figure 1 As shown, this embodiment provides a detailed explanation of a self-balancing vehicle control method based on steering control. The self-balancing vehicle can specifically be a two-wheeled self-balancing bicycle or a self-balancing scooter. Its core lies in coordinating balance control and steering control by dynamically adjusting the balance median, and combining LQR optimal control and incremental PID control to achieve stable vehicle handling. The following details each step of the method:
[0043] The first step is to collect the vehicle's attitude information in real time. This attitude information includes the vehicle's tilt angle, tilt velocity, and fork angle. The data acquisition can be achieved using an inertial measurement unit (IMU) and an encoder. The IMU can be an MPU6050 module, which integrates a three-axis accelerometer and a three-axis gyroscope, enabling simultaneous acquisition of the vehicle's tilt acceleration perpendicular to the direction of travel and its rotational angular velocity around the horizontal axis. The MPU6050 module connects to the vehicle's main control unit via an analog IIC interface, with a power supply voltage of 3.3V provided by the main control unit's voltage regulator circuit. The sampling frequency can be configured, and the DMP digital motion processor library can be enabled to fuse the raw acceleration and angular velocity data, eliminating drift errors from a single sensor. The final output is the filtered vehicle tilt angle and tilt velocity. The fork rotation angle can be acquired by an encoder, which can be an orthogonal encoder, installed on the fork steering shaft and rotates synchronously with the fork. The encoder can be connected to the timer of the main control unit and configured as an orthogonal encoder. The fork rotation angle is calculated by reading the counter value of the timer. The calculation process can be determined based on the number of encoder pulses and the mechanical transmission relationship.
[0044] Next, the step of calculating the balance control command based on the vehicle attitude information and the dynamic balance median is executed. The initial dynamic balance median is the reference value of the vehicle body tilt angle when the vehicle is upright. This value can be determined through the calibration process after the vehicle is powered on. During the calibration phase, the vehicle can be placed on a horizontal ground and kept upright, and the average tilt angle output by the inertial measurement unit at this time can be collected as the initial dynamic balance median. The balance control command can be calculated using the linear quadratic regulator (LQR) algorithm. This algorithm requires first constructing state variables based on the bicycle dynamics model. The state variables can be defined as vectors containing the bike lean angle, the bike lean velocity, and the fork rotation angle. The state equation of the bicycle dynamics model can be expressed as X_dot=A×X+B×u, and the output equation can be expressed as Y=C×X. The parameters of matrices A, B, and C are determined based on the vehicle's physical characteristics. Specific parameters may include gravitational acceleration g, vehicle center of gravity height h, vehicle speed v, front and rear wheel track w, and the distance between the rear wheel contact point and the center of gravity projection b. The values of the above parameters can be obtained through actual vehicle measurements. For example, g can be 9.8 m / s², h can be 0.088 m, v can be 0.634 m / s, w can be 0.167 m, and b can be 0.055 m.
[0045] The LQR algorithm achieves optimal control by constructing a cost function, which can be expressed as follows:
[0046]
[0047] In the formula, Q is a positive semi-definite state weighting matrix, and R is a positive definite control weighting matrix. In engineering practice, Q and R are symmetric matrices and are often diagonal matrices. The diagonal element qi in Q represents the degree of importance attached to the corresponding error component xi (the ultimate goal is to make the value of each state variable become 0, so the value of each state variable is also called the error value). The more important the error component, the faster it is desired to decrease, and correspondingly, its weight coefficient is larger. Similarly, the diagonal element ri in R represents the constraint on the corresponding input component ui, preventing it from becoming too large. The design idea of the LQR controller is to design a state feedback controller u = −Kx that minimizes the cost function minJ, thereby achieving the goal of achieving better performance indicators for the original system at a low cost. As for the calculation of the state feedback matrix, it is as follows:
[0048]
[0049] Where P is the Riccati equation The solution.
[0050] Similarly, for a discrete linear time-invariant system (assuming the system is completely controllable), let its state equation be...
[0051]
[0052] The performance index of the quadratic form is
[0053]
[0054] In the formula, Q is a symmetric positive definite constant matrix or a symmetric positive semi definite constant matrix, and R is a symmetric positive definite constant matrix.
[0055] The problem now is to design a state feedback controller U(k) = − LX(k) such that J is minimized. Similar to the above, the corresponding conclusion is given here:
[0056]
[0057] Where P is the Riccati equation The solution.
[0058] Having provided the qualitative explanation of the LQR controller above, we will now use the balancing process of a bicycle as an example to illustrate the design of the LQR controller. From the dynamic model of the bicycle, we know that the system's state equation is...
[0059]
[0060] The output equation is
[0061]
[0062] The specific calculation process can be implemented using the `dlqr` function in MATLAB software. Inputting the discretized system matrix, input matrix, Q matrix, and R matrix, the output is the specific value of the gain matrix K, for example, K = [-92.2973, -8.6746, 10.5355]. Based on this gain matrix, the calculation formula for the balance control command, i.e., the target steering speed command for the front fork, can be expressed as δ_dot = -K × (X - X_ref), where X_ref is the target state vector. The element in X_ref corresponding to the dynamic equilibrium median is the current dynamic equilibrium median. This formula converts the deviation between the actual attitude of the vehicle and the target attitude into the target steering speed that the front fork needs to achieve, thereby driving the front fork to rotate and achieve balance.
[0063] The next step is to receive steering commands from the steering input device. The steering input device can be of various types depending on the vehicle's usage scenario, specifically including manual steering mechanisms and electric power steering (EPS) systems. If a manual steering mechanism is used, its structure may include a steering wheel, a mechanical transmission rod, and a potentiometer. This potentiometer can be a linear potentiometer, connected in series with a fixed resistor and then connected to the ADC channel of the main control unit. The supply voltage can be 3.3V, thus limiting the potentiometer's output voltage range to a specific interval. When the driver turns the steering wheel, the mechanical transmission rod moves the sliding end of the potentiometer, changing the output voltage. The main control unit can accurately acquire this voltage via the ADC and convert the acquired voltage value into a steering command. For example, when the voltage is at the neutral position, there is no steering command; when the voltage deviates from the neutral position, it corresponds to a left or right steering command. The steering amplitude can be linearly related to the voltage deviation. If an EPS system is used, its structure may include a torque sensor, a power assist motor, and a reduction mechanism. The torque sensor can be a strain gauge torque sensor, installed between the steering wheel and the steering shaft. The output voltage signal can correspond to a specific range of steering torque. This signal can be connected to the ADC channel of the main control unit and converted into steering commands after being acquired by the ADC. The power assist motor of the EPS system can be connected to the main control unit through an H-bridge drive circuit to receive the power assist control signal. The generation of the power assist signal needs to be based on the coordinated result of the steering command and the balance control command to avoid conflicts caused by independent output.
[0064] The next step involves dynamically adjusting the dynamic balance median based on the steering command to generate the target balance median offset. The core logic of this step is to internalize the steering requirement as the target of balance control, rather than independently outputting steering commands. The specific process is as follows: When the main control unit detects a valid steering command, it first triggers the "steering reference median recording" operation, reads the current dynamic balance median, and stores it as the steering reference median, ensuring that subsequent adjustments are based on the current balance state. Then, the target balance median offset can be calculated based on the direction and magnitude of the steering command. For example, the offset can be positive for left turns and negative for right turns. The magnitude of the offset can be linearly correlated with the steering amplitude, and the specific calculation formula can be determined based on the conversion relationship between steering amplitude and angle / radian. Adding the steering reference median to the target balance median offset yields the adjusted dynamic balance median, which is the new balance control target. At this time, when the LQR algorithm calculates the balance control command, the target state vector will be updated to a vector based on the adjusted dynamic balance median. In order to achieve the new balance target, the vehicle will automatically calculate the corresponding front fork target steering speed command through the LQR algorithm, thereby driving the front fork to rotate and realizing autonomous steering motion, thus avoiding the direct conflict between balance command and steering command in principle.
[0065] During the steering process, the validity of the steering command needs to be continuously monitored: if a manual steering mechanism is used, when the main control unit detects that the potentiometer voltage has returned to the specific fluctuation range of the median voltage, or detects that the steering torque applied by the driver has disappeared, it can be determined that the steering command has failed. At this time, the "dynamic balance median value recovery" operation can be triggered to restore the dynamic balance median value from the adjusted value to the previously recorded steering reference median value, so that the vehicle returns to the normal upright balance state and the steering process ends.
[0066] Finally, the adjusted dynamic equilibrium median is used for subsequent balance control command calculations, and the actuator is driven by an incremental PID algorithm. Since the fork target steering speed command output by the LQR algorithm is a continuous speed signal, while the actuator servo requires pulse width modulation (PWM) signals for driving, an incremental PID controller can be introduced to process the fork target steering speed command. The input deviation of the incremental PID controller is the fork target steering speed command at the current moment. It also needs to store the deviations from the previous two moments. These historical deviations can be stored in the main control unit's buffer, and the buffer data is updated after each PID calculation.
[0067] The control increment ΔPWM of incremental PID can be calculated using the following formula:
[0068]
[0069] Where Kp, Ki, and Kd are the proportional coefficient, integral coefficient, and derivative coefficient, respectively. Their values can be determined based on system debugging. To facilitate software implementation, the coefficients can be amplified by a specific factor in actual use. For example, after amplification by 100 times, the values can be Kp=16, Ki=4, and Kd=4. The calculated control increment ΔPWM needs to be added to the PWM output value of the previous moment to obtain the final PWM control signal value at the current moment. This PWM signal can be output to the servo drive pin.
[0070] The servo can be a digital servo, operating at 5V, with sufficient output torque to drive the front fork. The rotation angle range is 0° to 180°, corresponding to a PWM signal period of 20ms and a high-level time range of 0.5ms to 2.5ms. The main control unit's timer can be configured for PWM output mode, with specific parameters set as a timer prescaler and automatic reload value to achieve a PWM signal frequency of 50Hz. To ensure the servo's center position aligns with the front fork, a PWM reference value can be set for the servo's center position. For example, this reference value could set the PWM signal high-level time to 1.5ms, corresponding to a servo angle of 90°. The final PWM value output to the servo can be adjusted based on the PWM reference value and control increments to ensure the PWM value range corresponds to the servo's rotation angle range, i.e., the front fork's steering limits. The servo can be connected to the front fork via a mechanical linkage, converting the servo's rotation angle into the front fork's steering angle, thus achieving vehicle steering while maintaining balance.
[0071] During the execution of the entire method, the main control unit can implement the cyclic execution of each step through a specific periodic interrupt. For example, an external interrupt can be triggered through the INT pin of the inertial measurement unit. The interrupt period can be 5ms, that is, every 5ms, the vehicle attitude acquisition, LQR balance control command calculation, steering command detection and balance median adjustment, incremental PID calculation and PWM signal output are completed to ensure the real-time response capability of the system and avoid balance instability caused by delay.
[0072] Example 2
[0073] like Figure 2 As shown, this embodiment corresponds to the above control method and provides a self-balancing vehicle control system based on steering control. The system adopts a modular design, is compatible with multiple steering input methods, and achieves coordinated control of balance and steering through a unified control core. Specifically, it includes an attitude sensing module, a steering input module, a control processing module, and a steering execution module.
[0074] The attitude sensing module is used to detect the vehicle's attitude information in real time. Its core component can be an inertial measurement unit (IMU), specifically the MPU6050 module, which integrates a three-axis MEMS accelerometer and a three-axis MEMS gyroscope, enabling simultaneous acquisition of the vehicle's acceleration and angular velocity data in three-dimensional space. The MPU6050 module's power supply pin VCC can be connected to a 3.3V power supply, provided by the control processing module's voltage regulator circuit. The GND pin is grounded. The SCL serial clock line and SDA serial data line can be connected to specific GPIO pins of the control processing module to achieve data interaction with the module via a simulated IIC communication protocol. The MPU6050's INT interrupt output pin can be connected to another GPIO pin of the control processing module to trigger an external interrupt, enabling synchronous acquisition of attitude data.
[0075] To improve the accuracy of attitude data, the MPU6050 module can integrate a DMP (Digital Motion Processor) to fuse raw acceleration and angular velocity data, eliminating gyroscope drift errors and accelerometer noise interference, and outputting filtered vehicle tilt angle and tilt velocity. The sampling frequency of the MPU6050 can be set via IIC commands sent from the control processing module to its internal registers, for example, to 200Hz, ensuring that valid attitude data is output every 5ms to meet the system's real-time requirements.
[0076] In addition, the attitude sensing module may also include an encoder assembly for acquiring the fork rotation angle. The encoder can be a 100-line orthogonal incremental encoder, mounted on the end of the fork steering shaft, rotating synchronously with the fork. The A-phase and B-phase output pins of the encoder can be connected to specific timer channels of the control processing module, the VCC pin can be connected to a 5V power supply, and the GND pin is grounded. The control processing module can configure the corresponding timer to orthogonal encoder mode, enabling the 4x frequency multiplication function, that is, the encoder can output 400 pulses per revolution. The fork rotation angle is calculated by reading the counter value of the timer—when the encoder rotates clockwise with the fork, the counter value increases; when it rotates counterclockwise, the counter value decreases. The median value of the counter can be set to a specific value corresponding to the state when the fork is directly in front. Therefore, the formula for calculating the fork rotation angle can be determined based on the difference between the counter value and the median value, the number of pulses, and the angle conversion relationship. The measurement range can meet the vehicle steering requirements.
[0077] The steering input module is used to receive steering commands from users or external devices. It adopts a multi-input compatible design and can specifically include two core forms: manual steering mechanism and EPS system. The structure and signal processing methods of each form are as follows:
[0078] The manual steering mechanism may include a steering wheel, a mechanical transmission assembly, and a potentiometer. The steering wheel can be connected to the front fork via a mechanical shaft. When the driver turns the steering wheel, the mechanical transmission assembly, including gears and linkages, moves the sliding end of the potentiometer. The potentiometer can be a linear carbon film potentiometer, with one pin connected to a 3.3V power supply and the other pin connected in series with a fixed resistor and then grounded. The sliding end pin can be connected to the ADC channel of the control processing module. Due to the series connection of the fixed resistor, the output voltage range of the potentiometer's sliding end can be limited to a specific range, preventing voltage over-limits caused by potentiometer wear. The ADC of the control processing module can be configured to a single-channel, single-conversion mode. The sampling time can be set to a specific clock cycle to ensure sampling accuracy. The ADC conversion is triggered by software, converting the analog voltage output by the potentiometer into a digital quantity, and calculating the steering command based on the digital quantity: when the digital quantity is at the middle value, it can be determined that there is no steering command; when the digital quantity is greater than the middle value, it can be determined that there is a right steering command, and the steering amplitude is proportional to the result of subtracting the middle value from the digital quantity; when the digital quantity is less than the middle value, it can be determined that there is a left steering command, and the steering amplitude is proportional to the result of subtracting the digital quantity from the middle value. The maximum value of the steering amplitude corresponds to the safety limit of the front fork steering. The effective range of the digital quantity can be limited by software to avoid oversteering.
[0079] The EPS system may include a torque sensor, a power steering motor, a reduction gear, and a current detection circuit. The torque sensor may be a strain gauge type, installed between the steering wheel shaft and the front fork drive mechanism, to detect the steering torque applied by the driver. The output signal of the torque sensor may be an analog voltage, corresponding to a specific range of steering torque. This voltage signal can be connected to the ADC channel of the control processing module for acquisition. The digital value range corresponds to the voltage range: when the digital value is at the middle value, it can be determined that there is no steering torque, i.e., no steering command; when the digital value is greater than the middle value, it can be determined that there is a right steering command; when the digital value is less than the middle value, it can be determined that there is a left steering command. The steering amplitude is proportional to the absolute value of the digital value minus the middle value.
[0080] The power steering motor in the EPS system can be a brushless DC motor with rated voltage and power sufficient to meet steering assist requirements. It connects to the control processing module via a three-phase H-bridge drive circuit, which can utilize a specific type of driver chip. The timer channel of the control processing module outputs a PWM signal to drive the H-bridge, enabling motor speed and steering control. The current detection circuit uses a sampling resistor connected in series in the motor power supply circuit. An operational amplifier amplifies the voltage across the resistor by a specific factor before connecting it to the ADC channel of the control processing module to detect the motor's operating current and prevent overcurrent damage. The control processing module dynamically adjusts the power steering motor's output torque based on the steering command amplitude and the current vehicle balance. For example, when the steering amplitude is large and the vehicle balance is stable, the motor's assist torque can be increased; when the steering amplitude is small or the vehicle experiences balance fluctuations, the assist torque can be reduced, ensuring coordinated power steering and balance control.
[0081] The control processing module is the core of the system, responsible for acquiring vehicle attitude information, calculating dynamic balance median, processing steering commands, and generating balance control commands. The core component can be an STM32F103C8T6 microcontroller, which uses an ARM Cortex-M3 core. Its clock speed, Flash capacity, and RAM capacity are sufficient to meet the requirements of multi-tasking real-time processing. The hardware circuitry of the control processing module includes a power supply regulator circuit, a clock circuit, a reset circuit, a serial communication circuit, and a timer circuit. The specific design of each part is as follows:
[0082] The power supply voltage regulator circuit can employ a two-stage voltage regulation structure, such as using AMS1117-5V and AMS1117-3.3V voltage regulator chips. The external power input can be provided by the vehicle's model aircraft battery. First, the voltage is regulated to 5V by the AMS1117-5V, powering the servo, encoder, and H-bridge drive circuit. The 5V power supply is then regulated to 3.3V by the AMS1117-3.3V, powering the microcontroller, inertial measurement unit, and ADC circuit. A capacitor can also be connected in parallel in the power supply circuit to filter out power supply noise and ensure stable power supply.
[0083] The clock circuit can use an external crystal oscillator, such as an 8MHz external crystal oscillator, which is multiplied to a specific frequency by the microcontroller's internal phase-locked loop to serve as the microcontroller's system clock. The reset circuit can include a manual reset button and a power-on reset circuit. The manual reset button can be connected to the microcontroller's reset pin, and pressing the button can trigger the microcontroller to reset. The power-on reset circuit can be formed by a capacitor and a resistor to achieve automatic reset upon power-on.
[0084] The serial communication circuit may include two serial ports, such as USART1 and USART3: USART1 can be used to communicate with the host computer, and the baud rate can be set to a specific value. It is used to upload information such as vehicle attitude data and PWM output values to facilitate system debugging. USART3 can be connected to a Bluetooth module as a communication interface for a wireless remote control device. The baud rate can be set to a specific value to be compatible with the command input of external wireless control devices. However, this system can prioritize the support of manual steering and EPS system steering input.
[0085] The timer circuit can include multiple timers, each performing different functions: for example, TIM1 can be configured as a PWM output mode, with a specific channel outputting a 50Hz PWM signal to drive the servo motor of the steering actuator module; TIM2 can be configured as a quadrature encoder mode to read the pulse signal of the front fork encoder; TIM4 can be configured as a PWM output mode, with a specific channel outputting a PWM signal to drive the drive motor of the rear wheel of the vehicle, which can be driven by a specific type of H-bridge chip; TIM3 can be configured as a PWM output mode to drive the power assist motor of the EPS system.
[0086] The software portion of the control processing module can adopt a modular design, including an initialization module, an attitude acquisition module, an LQR control module, a PID control module, a steering command processing module, and a PWM output module. The initialization module executes after the system is powered on and can complete the initialization of peripherals such as the microcontroller's GPIO, ADC, timers, serial ports, and external interrupts, as well as the initialization of the DMP library of the inertial measurement unit and the initial calibration of the dynamic balance median. The attitude acquisition module can read the vehicle body tilt angle and tilt rate output by the inertial measurement unit through external interrupts, as well as the fork rotation angle calculated by the timer counter value. The LQR control module can calculate the target steering speed command for the fork based on the acquired attitude information and the current dynamic balance median through a pre-calculated gain matrix. The steering command processing module can read the signals from the manual steering mechanism or EPS system acquired by the ADC in real time, determine the direction and amplitude of the steering command, and dynamically adjust the dynamic balance median. The PID control module can convert the speed command output by LQR into PWM control increments and calculate the final PWM output value. The PWM output module can output the PWM value calculated by the PID to the corresponding timer channel to drive the servo motor.
[0087] In addition, the control processing module may also include a battery voltage detection function, which collects the voltage of the vehicle model battery through the ADC channel. The battery voltage can be divided by a resistor and then connected to the ADC pin. The voltage range after voltage division can be adapted to the measurement range of the ADC. After the ADC collects the data, the actual battery voltage can be calculated by a specific formula. When the battery voltage is detected to be lower than a certain value, the control processing module can output a command to shut down the rear wheel drive motor to avoid over-discharge damage to the battery.
[0088] The steering actuation module executes steering actions based on control signals output from the control processing module. Its core components can be a servo motor and a mechanical transmission mechanism, specifically including a digital servo motor, a servo motor mounting bracket, a connecting rod, and a spherical bearing. The digital servo motor operates at 5V, provided by the 5V voltage regulator circuit of the control processing module. The current is sufficient for steering requirements, and the output torque drives the front fork to overcome steering resistance and achieve steering. The servo motor's signal pins can be connected to the timer PWM output channel of the control processing module to receive 50Hz PWM control signals. The servo motor's output shaft can be connected to the connecting rod via a coupling, and the other end of the connecting rod can be connected to the steering arm of the front fork via a spherical bearing, converting the servo motor's rotation angle into the front fork's steering angle. When the servo motor's output shaft rotates a specific angle, the front fork's steering angle corresponds to a specific transmission ratio. Through the design of the mechanical transmission ratio, it can be ensured that within the servo motor's rotation range, the front fork can achieve a steering angle that meets the vehicle's turning radius requirements.
[0089] The servo's control logic can be based on the duty cycle of the PWM signal: when the PWM signal period is 20ms, a high-level time of 0.5ms corresponds to the servo output shaft rotating to its left limit, at which point the front fork turns to its left limit; a high-level time of 1.5ms corresponds to the servo output shaft rotating to its center position, at which point the front fork is directly forward; and a high-level time of 2.5ms corresponds to the servo output shaft rotating to its right limit, at which point the front fork turns to its right limit. The control processing module can precisely control the servo's rotation angle by adjusting the high-level time of the PWM signal, thereby controlling the front fork's steering angle and maintaining the vehicle's balance.
[0090] To ensure the reliability of the steering actuator module, the mechanical transmission mechanism can use high-strength materials for the connecting rods, and the spherical bearings can be self-lubricating to reduce mechanical wear during steering. The servo mounting bracket can be made of rigid materials and rigidly connected to the vehicle frame with bolts to prevent vibration of the servo during vehicle operation, which would affect steering accuracy. In addition, the steering actuator module can be equipped with limit blocks, installed at the left and right steering limit positions of the front fork, to prevent excessive rotation of the servo and damage to the mechanical structure. The limit blocks can be made of cushioning materials to absorb the impact force when the front fork reaches the limit position.
[0091] In the actual operation of the system, the modules can work together: the attitude sensing module can continuously collect vehicle attitude and fork angle data, the steering input module can receive the driver's steering intention and convert it into an electrical signal, the control processing module can process these signals, coordinate balance and steering requirements by dynamically adjusting the balance median, and generate a precise PWM control signal by combining LQR and PID algorithms, and the steering execution module can drive the fork to steer according to the PWM signal, while maintaining the vehicle's upright balance, so as to achieve stable and smooth driving and steering control.
[0092] As is known from common technical knowledge, this invention can be implemented through other embodiments that do not depart from its spirit or essential characteristics. Therefore, the disclosed embodiments described above are merely illustrative in all respects and are not the only ones. All modifications within the scope of this invention or its equivalents are included in this invention.
Claims
1. A self-balancing vehicle control method based on steering control, characterized in that, Includes the following steps: Real-time acquisition of vehicle attitude information of the self-balancing vehicle; Based on the vehicle body attitude information and a dynamic equilibrium median, a balance control command for maintaining vehicle balance is calculated. Receive steering commands from the steering input device; The value of the dynamic equilibrium median is dynamically adjusted according to the steering command to generate a target equilibrium median offset, so that the vehicle can autonomously generate steering motion to maintain balance at the new target equilibrium point. The dynamic equilibrium median, adjusted based on the target equilibrium median offset, will be used for subsequent equilibrium control command calculations.
2. The self-balancing vehicle control method based on steering control according to claim 1, characterized in that, The specific steps for calculating the balance control command based on vehicle attitude information and dynamic balance median include: A state variable model is constructed based on a bicycle dynamics model, including the body lean angle, body lean velocity, and fork rotation angle. A linear quadratic regulator (LQR) algorithm is used, with the dynamic equilibrium median as the control target, to perform optimal state feedback calculation on the state variables. The state feedback gain matrix is obtained by solving the Riccati equation, and the target fork steering speed command for controlling vehicle balance is calculated based on the gain matrix. The cost function of the LQR algorithm considers both state variable error and control quantity consumption.
3. The self-balancing vehicle control method based on steering control according to claim 2, characterized in that, After outputting the target steering speed command for the front fork, the process also includes steps for controlling the actuator: The target steering speed command for the fork is used as the input deviation of the proportional-integral-derivative (PID) controller. The PID controller performs incremental PID calculations on the input deviation to calculate the pulse width modulation (PWM) control signal used to drive the servo motor. The incremental PID calculation is based on the target steering speed command values for the fork at the current time and at historical times. It calculates the incremental value of the PWM control signal at the current time relative to the previous time and adds the incremental value to the PWM control signal value at the previous time to obtain the final PWM control signal value at the current time.
4. The self-balancing vehicle control method based on steering control according to claim 3, characterized in that, The specific steps for calculating the control signal for driving the steering actuator using a PID controller are as follows: An incremental PID control algorithm is adopted, which calculates the target steering speed of the fork based on the current sampling time, the target steering speed of the fork at the previous sampling time, and the target steering speed of the fork at the time before that, using the formula... The increment of the PWM control signal that should be output to the steering actuator at the current moment is calculated, where This indicates the target steering speed command for the front fork at the current moment. This indicates the target steering speed command for the fork at the previous sampling time. K represents the fork target steering speed command at the time two samples ago. p K i K d These are the proportional, integral, and derivative coefficients, respectively. The calculated increment of the PWM control signal is added to the PWM control signal value of the previous moment to obtain the final PWM control signal value at the current moment, which is used to drive the servo motor to achieve precise steering angle control.
5. A self-balancing vehicle control method based on steering control according to claim 1, characterized in that, The specific steps for dynamically adjusting the dynamic balance median value according to the steering command include: When a valid steering command is received, the current dynamic balance median is first recorded as the steering reference median. Then, based on the direction determination result of the steering command, a preset deviation amount corresponding to left steering is added to the steering reference median or a preset deviation amount corresponding to right steering is subtracted, thereby obtaining the adjusted target dynamic balance median.
6. The self-balancing vehicle control method based on steering control according to claim 5, characterized in that, After the turn is completed, it also includes: When a steering command failure is detected, the dynamic balance median is restored to the steering reference median.
7. A self-balancing vehicle control system based on steering control, comprising the self-balancing vehicle control method based on steering control as described in any one of claims 1-6, characterized in that, include: An attitude sensing module is used to detect vehicle attitude information in real time. The attitude sensing module includes a gyroscope and an accelerometer sensor. Steering input module, used to receive steering commands from user or external device; The control processing module is electrically connected to the attitude sensing module and the steering input module. The control processing module is used to perform functions such as vehicle attitude information acquisition, dynamic balance median calculation, steering command processing, and balance control command generation. The steering execution module is electrically connected to the control processing module and is used to execute steering actions according to the control signals output by the control processing module. The steering execution module includes a servo drive circuit and a servo.
8. A self-balancing vehicle control system based on steering control according to claim 7, characterized in that, The control processing module includes an LQR control unit and a PID control unit that work together: The LQR control unit is used to construct state variables based on the bicycle dynamics model, and with the dynamic equilibrium median as the control target, it uses a linear quadratic regulator algorithm to perform optimal state feedback calculation on the state variables and outputs the front fork target steering speed command. The PID control unit is connected to the LQR control unit and is used to receive the target steering speed command of the fork as the input deviation, and to calculate the PWM control signal to drive the steering execution module through an incremental PID algorithm.
9. A self-balancing vehicle control system based on steering control according to claim 7, characterized in that, The steering input module is a combination of any one or more of the following devices: The electric power steering system (EPS) is used to generate steering commands in the form of electrical signals. The manual steering mechanism uses sensors to convert mechanical steering actions into steering commands in the form of digital signals. A wireless remote control device used to receive and transmit wireless steering commands from an external control device.
10. A self-balancing vehicle control system based on steering control according to claim 7, characterized in that, The steering actuation module uses a servo motor as the actuator. The control signal output by the control processing module to the servo motor is a pulse width modulation (PWM) signal. The duty cycle of the PWM signal is linearly related to the rotation angle of the servo motor, and the range of the duty cycle of the PWM signal corresponds to the range of the rotation angle of the servo motor.