Submitted:
20 November 2026
Posted:
26 November 2026
You are already at the latest version
Abstract
To enable a Two-Wheeled Self-Balancing Robot (TWSBR) to accurately track trajectories in the X--Y plane despite external disturbances and severe parametric uncertainties—specifically substantial shifts in chassis mass, moments of inertia, and center of gravity induced by unknown payloads—a robust cascaded control architecture is proposed. The controller comprises an inner dynamic loop for vertical stabilization and traction control, coupled with an outer kinematic loop for planar path guidance. For the inner loop, a kinematically decoupled Sliding Mode Control (SMC) scheme is formulated across two independent channels: i) a longitudinal channel regulating pitch balance and linear velocity, and ii) a rotational channel governing yaw orientation. Meanwhile, the outer loop implements a Pure Pursuit-inspired look-ahead kinematic guidance law to mitigate non-minimum phase trajectory distortions. Numerical simulations on a realistic TWSBR model validate the proposed approach under sensor measurement noise, periodic impulsive disturbances, and large payload variations (up to 51% in mass and 79% in center-of-gravity height).

Keywords:
two-wheeled self-balancing robot
; sliding mode control
; cascaded control
; underactuated systems
; non-minimum phase
; trajectory tracking
; Lyapunov stability
1. Introduction
Two-wheeled self-balancing robots (TWSBRs) have become a standard benchmark platform for validating and analyzing nonlinear and robust control algorithms due to their mechanical simplicity and rich dynamic complexity [1,2]. Fundamentally modeled as mobile inverted pendulums, TWSBRs are underactuated, inherently unstable, strongly coupled, and exhibit non-minimum phase behavior when executing longitudinal and turning maneuvers [2,3]. In practical applications, classical linear controllers—such as conventional Proportional-Integral-Derivative (PID) or Linear Quadratic Regulators (LQR)—often degrade significantly when exposed to unmodeled friction, sensor noise, external impulses, or substantial payload variations [2]. To overcome these limitations, numerous robust control methodologies have been developed to guarantee vertical stabilization and trajectory tracking under model uncertainties and external disturbances [3].
1.1. Types of Robust Controllers Applied to TWSBR
The most prominent robust control strategies applied to TWSBRs can be categorized into several theoretical families:
- Sliding Mode Control (SMC): SMC is widely adopted for TWSBRs due to its theoretical invariance to matched external disturbances and parametric uncertainties once the system trajectories reach a predefined sliding manifold [4,5]. To mitigate its primary practical drawback—high-frequency control chattering—researchers commonly employ continuous boundary-layer approximations, continuous sliding mode formulations, or Second-Order Sliding Mode Control (SOSMC) algorithms such as Super-Twisting [6,7,8,9].
- Robust Control: This frequency- and state-space-domain methodology minimizes the worst-case energy gain from exogenous disturbances and sensor noise (e.g., MEMS gyroscope and accelerometer noise) to regulated performance outputs, ensuring strict input-to-state stability against unstructured uncertainties [2,3].
- Robust Constrained Model Predictive Control (R-MPC): Unlike nominal MPC, which relies on exact model predictions, robust formulations (such as Tube-based MPC) explicitly incorporate uncertainty tubes and state constraints into an online optimization problem, guaranteeing that the TWSBR respects physical tilt and actuator torque limits to prevent catastrophic falls [3].
- Robust Adaptive and Intelligent Control: Classical adaptive schemes estimate varying physical parameters (such as payload mass or center-of-mass shifts) online, while intelligent hybrid architectures integrate neural networks or fuzzy logic systems to approximate complex unmodeled nonlinearities without requiring exact analytical expressions [3].
- Metaheuristic-Tuned Hybrid Controllers: Recent literature increasingly combines robust control laws with offline or online metaheuristic optimizers—such as Modified Particle Swarm Optimization (MPSO) and Modified Cuckoo Search (MCS)—to automatically tune SMC gains or weighting matrices, improving transient response and tracking accuracy [3,10].
1.2. Control Challenges and Motivation of the Proposed Architecture
Despite significant advances in the literature, deploying robust controllers on real TWSBR platforms entails critical trade-offs across eight major challenges: i) strong nonlinearities, ii) underactuated degrees of freedom, iii) open-loop gravitational instability, iv) high-frequency IMU measurement noise, v) large parametric uncertainties due to unknown payloads, vi) high sampling rate requirements (typically to ), vii) computational tractability for embedded microcontrollers, and viii) formal Lyapunov stability guarantees for both actuated and internal dynamics [2,3].
A critical examination of existing approaches reveals two persistent limitations. First, computationally intensive strategies such as R-MPC and neural-adaptive schemes impose heavy real-time processing burdens that hinder deployment at sampling rates on low-cost embedded hardware. Second, conventional single-loop SMC designs that combine position error () and pitch error () on a single sliding surface often suffer from conflicting control objectives: the robot must tilt backward before accelerating forward due to its non-minimum phase zero, inducing severe internal oscillations and trajectory “hooks” during tight turns.
To bridge this gap, this paper proposes a computationally lightweight, kinematically decoupled Robust Cascaded Control architecture. By exploiting the natural structural decoupling between longitudinal and yaw dynamics near the vertical equilibrium point [11], the inner loop separates control authority into two independent boundary-layer SMC channels—eliminating conflicting pitch-position actions while guaranteeing finite-time reaching and asymptotic stability of the underactuated zero dynamics. Furthermore, an outer look-ahead kinematic guidance law anticipates high-curvature path transitions to suppress non-minimum phase trajectory distortions without requiring heavy online optimization.
2. Modelling
The differential equations representing the dynamic behavior of this TWSBR are obtained by projecting the forces and moments onto the sagittal plane (longitudinal motion and pitching) and the horizontal plane (yawing) using the Euler-Lagrange method.
Longitudinal Motion (x):
Pitching Motion of the Pendulum ():
Yaw / Turning Motion ():
These equations can be written in the classical matrix form used for robotic control systems, including friction:
Table 1.
Physical Parameters of the TWSBR.
| Symbol | Description |
|---|---|
| Chassis mass | |
| Wheel mass | |
| l | Distance from CoM to the origin |
| r | Wheel radius |
| W | Distance between the wheels |
| g | Acceleration due to gravity |
| Moment of inertia of the chassis about the axis Y | |
| Moment of inertia of the chassis about the axis Z | |
| Moment of inertia of the wheel about the axis Y | |
| Moment of inertia of the wheel about the axis Z | |
| Chassis friction | |
| Pendulum friction |
Table 2.
TWSBR Variables.
| Variable | Description |
|---|---|
| Torque on the left wheel | |
| Torque on the right wheel | |
| x | Linear displacement of the chassis |
| Linear velocity of the chassis | |
| Angle of the pendulum with the vertical | |
| Angular velocity of the pendulum | |
| Chassis yaw angle | |
| Angular velocity of the chassis |
Thus, Equations (1)–(3) can be combined into the following matrix equation:
where the entries of mass and Coriolis matrices are:
To solve the system algebraically and isolate the longitudinal, pitch, and yaw accelerations, the symbolic determinant of the coupled system () is first defined as:
Using the expression given by Equation (7), the explicit equations representing the linear acceleration of the chassis (), the angular acceleration of the pendulum (), and the angular yaw acceleration () are as follows:
2.1. Model Linearization
To linearize the model given by Equations (8)–(10), the vertical equilibrium point of the TWSBR is considered, where the tilt angle is zero and velocities are zero (, , , ). Under these conditions, small-angle approximations are applied — and — and quadratic velocity terms, such as , are eliminated.
Substituting these approximations into the original dynamic equations given by Equation (5), all the entries of the Coriolis matrix are zero (), and the gravitational term is simplified as , then, the linearized equations can be written in the classical form given by Equation (4):
Where:
Defining the linearized and constant determinant , the three decoupled and linearized accelerations are as follows:
To obtain the state representation of the linearized plant, first, the state vector () and the control input vector () are defined as follows:
Where the position (gravitational) terms K, velocity (friction) terms B, and control terms G are given by:
2.2. Open-Loop Stability Analysis
tab:parametrostwip shows the nominal parameters of the TWSBR, as well as those corresponding to the loaded TWSBR. In both cases, the components of the linearized model are shown in Table 4.
Evaluating the characteristic polynomial using the nominal dimensions and inertia of the TWSBR prototype yields the following six open-loop poles:
(Three pure poles at the origin → Free integrators): This means that the longitudinal position (x) and the yaw orientation () lack natural elastic restoring forces. If the robot is left stationary on a surface, it can remain at any coordinate or angle without returning to the origin on its own.
and (Negative real poles → Stable): These result from inertial coupling damped by viscous friction at the wheels () and the pendulum pivot ().
(Positive real pole → Unstable): Determines the robot’s dominant instability. Physically, it represents the rate at which the chassis diverges exponentially from the vertical () due to the action of gravity.
Open-loop conclusion: Since there is a root with a strictly positive real part (), the open-loop system with nominal parameters is inherently unstable. The pendulum will fall exponentially if no control energy is injected.
Using the mass and inertia parameters with the load, the unstable pole shifts from to . This mathematically demonstrates that, with the load applied, the robot physically has a slower free-fall rate, theoretically giving the system more "time" to react. tab:comparativacomponentes shows the comparison between the poles calculated using nominal parameters and those calculated under load.
Although the TWSBR falls more slowly when carrying its load, in this case, the determinant increased nearly fourfold (from to ) due to the massive increase in the inertia . Consequently, with a controller tuned using the nominal model, the motors will drive the loaded robot using only a small fraction of the torque actually required to move that additional mass, resulting in slow yet very large-amplitude oscillations in the simulation.
Therefore, it will be necessary to use a controller that is sufficiently robust against these changes, including other disturbances such as unmodeled dynamics or sensor noise.
Table 3.
TWSBR parameter values.
| Symbol / Value | Description | ||
|---|---|---|---|
| 2.9988 | kg | Nominal chassis mass | |
| 3.2 | kg | Mass of each wheel | |
| l | 0.0855 | m | Nominal distance from CoM to origin |
| r | 0.115 | m | Wheel radius |
| W | 0.256 | m | Track width (distance between wheels) |
| g | 9.81 | m/s | Acceleration due to gravity |
| 0.0228 | kgm | Nominal chassis moment of inertia around the Y-axis | |
| 0.0204 | kgm | Nominal chassis moment of inertia around the Z-axis | |
| 0.020 | kgm | Wheel moment of inertia around the Y-axis | |
| 0.011 | kgm | Wheel moment of inertia around the Z-axis | |
| 0.2 | Ns/m | Chassis friction | |
| 0.1 | Nms/rad | Pendulum friction | |
| 4.5308 | kg | Loaded chassis mass | |
| l | 0.1533 | m | Distance from CoM to origin under load |
| 0.0746 | kgm | Loaded chassis moment of inertia around the Y-axis | |
| 0.0397 | kgm | Loaded chassis moment of inertia around the Z-axis | |
Table 4.
Comparison of dynamic matrix components.
| Component / Parameter | Nominal Case | Loaded Case |
|---|---|---|
| kg | kg | |
| l | m | m |
| kg m | kg m | |
Table 5.
Comparison of the system’s eigenvalues.
| Eigenvalues | Nominal Case | Loaded Case |
|---|---|---|
2.3. Pitch and Yaw Accelerations (Non Linear and Linear Cases)
The base to design the main non-linear Sliding Mode Controller (NL-SMC), the actual pitch acceleration () and yaw acceleration () given by Equation (9) and Equation (10) respectively, can be written as:
Where , , , and are the exact nominal functions calculated using the empty-robot parameters using the following equations:
Where , while the terms and are given by Equations (6a)–(6h).
The control signals and are given by:
Proceeding in the same manner with the dynamic equations of the linearized model given by Equation (14) and Equation (15), we obtain the linear version of the pitch () and yaw () accelerations as follows:
Where the terms , , and , are the linearized nominal functions calculated using the empty-robot parameters defined by the following equations:
Where , while the terms are given by Equations (12a)–(12d).
3. Robust Sliding Mode Controller
This document reports on the development, tuning, and robustification of a guidance and control algorithm for a Two-Wheeled Self-Balancing Robotic System (TWSBR). As previously mentioned, the TWSBR is an inherently unstable, nonlinear, and underactuated system. The primary objective of this project is to achieve precise tracking of complex trajectories (such as Gerono’s lemniscate or a circle) in the plane while simultaneously ensuring the vehicle’s vertical balance.
Given the need for robustness against friction (), mass uncertainties, disturbances, and measurement noise, a solution based on Sliding Mode Control was adopted, as it is one of the most viable and efficient options for addressing these types of problems.
3.1. Controller Architecture
A robustified direct hierarchical sliding mode control (SMC-I) scheme was implemented, divided into two independent main channels and an external kinematic velocity loop:
Internal Longitudinal Channel:
Responsible for longitudinal motion (forward movement and pitching), that is, maintaining the pendulum’s vertical balance () and correcting deviations via a robust control law coupled with an equivalent direct gravity compensation action ().
Internal Rotational Channel:
Responsible for rotational movement (yaw), differentially controlling the heading () as well as the vehicle’s turning in curves.
External Kinematic Velocity Loop:
PI (proportional-integral) controller responsible for calculating the robot’s desired tilt () based on the translational velocity error (), as well as the robot’s linear (, ) and rotational (, ) velocity and acceleration setpoints.
3.2. Hierarchical Sliding Mode Control
In classical Sliding Mode Control (SMC) theory, transforming a system into the Lukyanov-Utkin Regular Form is primarily done for two reasons: i) To separate actuated states from unactuated ones: it divides the system into a block that depends directly on the control input (u) and another block that is independent of the control; and ii) To guarantee the stability of the zero dynamics: it allows for the mathematical design of the sliding surface such that, when the system is "sliding" (), the remaining (unactuated) states remain stable. In a generic underactuated system where the physical behavior is unknown, bypassing the regular form could lead to designing a surface that stabilizes one variable while destabilizing another.
The process to be controlled —the TWSBR— exhibits a specific structure and non-minimum phase behavior that justify designing an SMC controller based on kinematic decoupling; that is, by leveraging its particular physical structure. This approach separates the longitudinal behavior —in which the forward motion (x) and pitch () variables are coupled— from the rotational or yaw () behavior, which is completely linear and decoupled from the other variables.
Longitudinal channel:
It will have a sliding surface . Here, the priority is pitch stability; therefore, the sliding surface is selected based on and . Consequently, the position variable x automatically becomes the internal dynamics (zero dynamics) of the controlled system. Schemes that utilize and on the same first-level surface often suffer from the cancellation of opposing terms—the robot wants to brake to correct x but needs to tilt to correct , resulting in severe oscillations (chattering induced by physics rather than the control law). The proposed approach eliminates this conflict at its source.
Rotational Channel:
It will have a sliding surface . The yaw angle () subsystem is fully actuated. As a second-order system in which differential torque directly influences angular acceleration (), it is already inherently in a regular form. It requires no mathematical transformation to ensure its stability.
The TWSBR system allows for a natural partitioning of its equations, as the yaw channel is decoupled from the equilibrium state in the vicinity of the vertical operating point (). Since pitch stability is a sine qua non condition for the robot’s motion, a direct sliding surface is proposed for the corresponding subspace (). Instead of using the regular form to design the surface, direct surfaces are employed; it is then demonstrated that the resulting dynamics for longitudinal displacement x (when ) are passive or bounded within a local neighborhood. In other words, what the regular form demonstrates a priori is demonstrated a posteriori here. Thus, proposing the surfaces directly drastically simplifies the controller design and maintains a direct relationship between the control gains () and the robot’s actual physical behavior (specifically, the damping and response speed of the pendulum and the turning motion).
3.3. Longitudinal Channel
The Longitudinal Channel is responsible for both regulating the forward linear velocity () and maintaining the vertical balance () of the TWSBR. To achieve this in a cascaded structure, an intermediate Proportional-Integral (PI) velocity loop translates the linear velocity tracking error () into a desired pitch angle reference ():
where and are the proportional and integral velocity gains, respectively, and bounds the tilt reference within () to prevent the robot from exceeding its physical stability limits. The desired pitch angular velocity () is computed numerically at each sampling step as:
while higher-order reference derivatives are neglected () due to the smooth, bounded nature of .
Based on this reference, the pitch angle error is geometrically wrapped using the four-quadrant inverse tangent function to avoid angular discontinuities:
and the linear longitudinal sliding surface is defined as:
where , is the pitch angle stiffness gain, and is the pitch angular velocity damping gain.
Differentiating the sliding surface with respect to time and applying yields:
Substituting the nonlinear pitch acceleration () into the surface derivative leads to:
where and represent the nominal longitudinal dynamic functions, defined in Equations (20) and (21), and evaluated using the unloaded TWSBR parameters.
3.3.1. Calculation of Equivalent Control ( )
Under ideal sliding conditions (), setting the surface derivative to zero and solving for the continuous equivalent control input gives:
This feedforward term compensates for gravitational torque, viscous friction, and inertial couplings along the sliding manifold.
3.3.2. Longitudinal Controller
The complete longitudinal torque control law () combines the equivalent control with a robust switching feedback term to reject unknown payloads, unmodeled dynamics, and sensor noise:
where is the discontinuous robustness gain, and is the linear saturation function with boundary layer thickness used to suppress chattering:
3.4. Rotational Channel
The control action dedicated to managing the orientation (yaw) of the TWSBR is designated as the Rotational Channel. For differential turning control during the tracking of the orientation angle (yaw), the second sliding surface is defined as a function of the orientation error (), which is normalized beforehand to ensure the absence of discontinuities in the plane:
Thus, the second sliding surface is expressed as follows:
Where:
- is the stiffness gain associated with the yaw angle error.
- is the angular velocity damping gain.
- the angular velocity error.
Analogously to the longitudinal case, substituting the yaw acceleration () given by Equation (19)
into Equation (44) yields:
3.4.1. Calculation of Equivalent Control ( )
By setting Equation (46) to zero (whereby becomes ) and solving for , we obtain:
Where the nominal terms and , defined in Equations (22) and (23), are calculated using the parameters of the unloaded TWSBR.
For the vast majority of trajectories the TWSBR must follow, the desired steering angle () changes as a smooth ramp, such that the reference acceleration is zero (). In this case, the final controller equation simplifies.
3.4.2. Rotational Controller
Finally, the robust control law for the total rotational torque action () is given by:
Where the linear saturation function with a boundary layer , which serves to avoid the chattering phenomenon, and is defined similarly to Equation (40).
3.5. Kinematic Transformation to the Actuators
The relationship between the longitudinal () and rotational () controls and the torques at the left () and right () wheels is given by:
Using Equation (49), Equation (39) and Equation (48), the expressions for the torques at the right and left wheels are obtained:
Finally, physical constraints due to actual actuator saturation at must be applied to the physical right () and left () motor torque signals, as follows:
4. Stability Analysis
4.1. Redefinition of Plant Dynamics with Lumped Uncertainties
In practical applications, the mathematical model of the two-wheeled self-balancing robot (TWSBR) is subjected to unmodeled physical variations, asymmetric actuator behaviors, and external disturbances.
Since the TWSBR is required to track trajectories while carrying unknown and varying payloads, the control architectures must treat these parameter variations based on a robust control law.
To account for these effects, the actual non linear second-order dynamics for both the longitudinal (pitch) and rotational (yaw) channels are formulated by splitting the system acceleration into a known nominal part and an unknown bounded uncertainty term.
4.2. Exact Non-Linear Model Redefinition
The actual pitch acceleration () and yaw acceleration () are modeled by splitting the exact non-linear plant given by Equation (18) and Equation (19) respectively, into a known nominal part and an unknown bounded uncertainty term:
Where , , , and are the exact non linear nominal functions given by Equations (20)–(23), and calculated using the empty-robot parameters shown in Table 3.
The terms and represent the lumped uncertainties, which automatically absorb: i) The unmodeled forces and inertial shifts caused by the unknown payload; ii) The exact non-linear dynamics (trigonometric gravity vectors, centripetal couplings) that change with the payload; and iii) External physical disturbances.
4.3. Longitudinal Channel Stability Analysis
Theorem 1.
Consider the underactuated longitudinal dynamics of the two-wheeled self-balancing robot (TWSBR) governed by the actual acceleration equation:
where and (as defined in Equations (20) and (21), respectively) within the operating region () represent the nominal system dynamics, and denotes the lumped parametric uncertainties and external disturbances bounded by for a known constant .
If the sliding mode control law is defined as in Equations (38) and (39) using a boundary layer thickness , then the closed-loop system state trajectories are guaranteed to reach the boundary layer in finite time and remain uniformly ultimately bounded (UUB) within it, provided that the positive switching gain satisfies the following condition:
where is a design constant representing the reaching rate, and .
Proof.
To evaluate the reachability and stability of the longitudinal boundary layer, let us define a positive-definite quadratic global Lyapunov candidate function as follows:
Taking the time derivative of along the system trajectories yields:
Since and , substituting and the perturbed plant dynamics expands the expression to:
Applying the robust control law in the region outside the boundary layer (), where , yields:
By expanding terms, the error velocity and nominal plant dynamics are strictly canceled, yielding:
Since holds throughout the controllable pitch range, we substitute and apply , obtaining:
Applying the inequality property and enforcing the known upper bound of the lumped uncertainty (), the Lyapunov derivative is strictly upper-bounded for all by:
To satisfy the strict -reachability condition required for finite-time convergence to the boundary layer (), the right-hand side must fulfill:
Dividing both sides by leads directly to:
Solving for the discontinuous robustness gain yields:
Thus, all trajectories starting outside the boundary layer converge to in finite time. □
4.4. Rotational Channel Stability Analysis
Theorem 2.
Consider the rotational (yaw) dynamics of the two-wheeled self-balancing robot (TWSBR) governed by the actual acceleration equation:
where and , as defined in Equations (22) and (23), represent the nominal system dynamics, and denotes the lumped parametric uncertainties, unmodeled asymmetric wheel friction, and external disturbances bounded by for a known constant .
If the rotational sliding mode control law is defined as in Equations (47) and (48) using a boundary layer thickness , then the closed-loop system state trajectories are guaranteed to reach the rotational boundary layer in finite time and remain uniformly ultimately bounded (UUB) within it, provided that the positive switching gain satisfies the following condition:
where is a design constant representing the reaching rate, and .
Proof.
To evaluate the reachability and stability of the rotational boundary layer, let us define a positive-definite quadratic global Lyapunov candidate function as follows:
Taking the time derivative of along the system trajectories yields:
By substituting the time derivative of the rotational sliding surface (), the expression expands to:
Knowing that the nominal uncoupled drift dynamics satisfy , and applying the robust control law in the region outside the boundary layer (), where , we obtain:
By expanding the terms, the tracking error reference acceleration and nominal dynamics are strictly canceled, simplifying the derivative to:
Since , we can substitute . Utilizing the mathematical identity , the expression becomes:
Applying the inequality property and enforcing the known upper bound of the lumped rotational uncertainty (), the Lyapunov derivative is strictly upper-bounded for all by:
Enforcing the -reachability condition () and solving for the switching gain yields:
This guarantees finite-time convergence to the rotational boundary layer . □
4.5. Sliding Phase (Boundary Layer Dynamics)
Once the system enters the boundary layer (, for ), the saturation function operates in its linear region (). Consequently, the discontinuous switching action is replaced by a smooth, high-gain linear feedback regime that eliminates chattering while keeping the tracking errors uniformly ultimately bounded (UUB).
Theorem 3
(Longitudinal Boundary Layer Stability). Consider the perturbed longitudinal sliding surface dynamics inside the boundary layer () subject to the bounded lumped uncertainty . Under the continuous linear control regime, the sliding variable decays exponentially toward a small residual set around the origin, guaranteeing uniform ultimate boundedness. Moreover, in the nominal disturbance-free case (), converges exponentially to .
Proof.
To evaluate the stability inside the boundary layer, let us define a positive-definite quadratic local Lyapunov candidate function for the longitudinal channel as:
Taking the time derivative of along the perturbed system trajectories and substituting the linear region of the saturation function () yields:
Plugging this derivative into and defining the positive decay rate parameter , we obtain:
Applying Young’s inequality () leads to:
By invoking the comparison lemma, the solution satisfies:
This mathematically guarantees that decays exponentially into the ultimate residual bound (since from Equation (55)), proving that trajectories remain strictly trapped inside the boundary layer. In the absence of uncertainties (), , recovering exact exponential convergence to . □
Theorem 4
(Rotational Boundary Layer Stability). Consider the perturbed rotational sliding surface dynamics inside the boundary layer () subject to . Under the continuous linear control regime, decays exponentially into a small ultimate bound inside the boundary layer, and converges exponentially to when .
Proof.
Defining the local quadratic Lyapunov candidate function and substituting into the perturbed rotational surface dynamics yields:
Defining the positive decay rate coefficient and following the exact same bounding procedure via Young’s inequality and the comparison lemma gives:
Consequently, converges exponentially to the residual bound , completely eliminating the chattering phenomenon and protecting the prototype’s gearboxes and motors from overheating. □
4.6. Internal Dynamics Stability (Underactuated States)
Given that the TWSBR is an underactuated robotic system (with 3 DoF: x, , and , but only 2 actuators), ensuring that the closed-loop system states lie asymptotically on the sliding surfaces ( and ) restricts the system to its zero dynamics manifold. We must formally evaluate if the remaining underactuated internal dynamics are stable.
Theorem 5
(Zero Dynamics Stability). When the closed-loop state trajectories of the TWSBR are constrained to the sliding manifold and , the remaining internal unactuated dynamics associated with the linear position x are locally asymptotically stable around the equilibrium point .
Proof.
From the general robust matrix dynamic model established in Equation (5), the equation governing the linear translation channel (first row of the system) is given by:
From the second row of the same matrix model (corresponding to the pitch dynamics ), the control input torque combination satisfies:
Multiplying the pitch dynamic row by and substituting it into the translation equation eliminates the explicit control torque terms , yields the unactuated coupled internal dynamic relation:
Now, consider the system operating under ideal sliding mode conditions on the manifold ( and ). From Section 5.1, the sliding slopes enforce the linear tracking error decay relations for orientation, where the reference states are set to zero (, ), yielding:
Near the origin, evaluating the zero dynamics manifold implies setting the orientation variables and their higher-order derivatives to their stable equilibrium trajectories () and (). Substituting these conditions, the mass matrix entries from Equations (6a)-(6h) linearize to constants (, ), and all nonlinear Coriolis terms vanish (, ).
Consequently, the remaining unactuated internal dynamic equation reduces strictly to:
To evaluate the stability of this residual subsystem, let us define a positive-definite quadratic local Lyapunov candidate function for the translation velocity state as:
Taking the time derivative of along the unactuated trajectory results in:
Substituting the reduced dynamic equation () yields:
Since the physical wheel friction parameter is strictly positive (), the Lyapunov derivative is negative semi-definite (). According to LaSalle’s Invariance Principle, the system state trajectories asymptotically converge to the largest invariant set where , which directly implies , and consequently, the linear position x settles to a constant stable value.
Combined with the exponential convergence of both actuated orientation channels ( and ), the local asymptotic stability of the underactuated closed-loop TWSBR on the ideal sliding manifold (, ) is formally established. □
Remark 1 (Practical Stability under Boundary-Layer Operation). In practical implementation using the continuous saturation approximation (Theorems 3 and 4), the sliding variables converge to a small residual invariant set and rather than identically zero. Near the vertical equilibrium, the unactuated translational dynamics can be viewed as a cascaded system driven by bounded residual orientation errors proportional to and . Because the unperturbed zero dynamics () are exponentially stable in velocity and passive in position with strictly positive damping (), the internal subsystem satisfies the local Input-to-State Stability (ISS) property. Consequently, when the states remain trapped inside the boundary layers, the translational velocity remains uniformly ultimately bounded (UUB) within a small neighborhood of the origin proportional to the boundary-layer thickness, ensuring that the TWSBR maintains upright balance without unbounded drift.
5. SMC Gain Tuning
The design of the sliding mode controller gains must satisfy two strict conditions: the sliding phase (ensuring errors converge exponentially to zero at the desired rate) and the reaching phase (ensuring robust gains overcome disturbances and the plant’s natural gravitational instability). The gains are calculated below using the parameters shown in Table 3.
5.1. Surface Gains ()
These gains define the robot’s linear error dynamics once the state trajectories are captured on the sliding surfaces ().
5.1.1. Longitudinal Channel (Pitch)
To achieve a well-damped transient response without exciting unmodeled high-frequency dynamics or saturating the actuators during velocity tracking, a closed-loop sliding pole at is selected. Consequently, the longitudinal surface gains are assigned as and , yielding the desired ratio .
5.1.2. Rotational Channel (Yaw)
The yaw channel behaves as a pure integrator in open loop. To ensure smooth heading tracking along curved trajectories without inducing aggressive differential wheel torques, a closed-loop sliding pole at is selected. This is achieved by setting and , such that .
5.2. Robustness Gains ()
Based on the Lyapunov stability conditions derived in Section 4, the discontinuous switching gains are dimensioned to dominate the worst-case gravitational torques, parametric payload variations, and external disturbances.
5.2.1. Longitudinal Channel ()
The control law must overcome the maximum gravitational destabilizing acceleration within the permissible tilt bound . Using the nominal parameters from Table 3 and Table 4, the worst-case gravitational drift term and control effectiveness are evaluated as:
Therefore, to satisfy the reachability condition in the nominal case, the switching gain must satisfy:
Furthermore, under the loaded condition (Table 4), the determinant increases nearly fourfold to , reducing to while reaches , which raises the minimum theoretical threshold to . To guarantee a wide robustness margin against payload shifts, viscous friction, and external perturbations, a tuned gain of is selected.
5.2.2. Rotational Channel ()
Since the yaw dynamics are decoupled from gravity (), the rotational switching gain is dimensioned to overcome unmodeled asymmetric wheel friction and ensure rapid heading convergence during tight turns, resulting in a tuned value of .
5.2.3. Boundary Layers and
To eliminate control chattering and attenuate residual high-frequency IMU measurement noise inside the sliding manifold, linear saturation boundary layers are specified with thicknesses and . Finally, Table 6 summarizes all tuned parameters of the proposed cascaded controller.
5.3. Digital Noise Filter
The measurement of the pitch angle () and its angular velocity () using an IMU is affected by random noise comprising two main components:
i) White or Gaussian noise. High-frequency noise ranging from a few Hertz up to the Nyquist sampling limit (typically between and or higher), produced by the thermomechanical noise of MEMS components and digital quantization noise. It behaves like white noise distributed uniformly across the sensor’s entire physical spectrum. In a gyroscope, when angular velocity is integrated to calculate the angle, this high-frequency noise introduces a cumulative error known as Angle Random Walk (ARW), which manifests as small, rapid vibrations and immediate inaccuracies.
ii) Low-frequency noise. It manifests as a dynamic bias or drift; its dominant frequencies are very low—below and close to zero. It originates from slow temperature changes, manufacturing imperfections, and bias instability. It causes the sensor’s physical "zero" to shift slowly over time. When integrating angular velocity to obtain orientation, this extremely slow DC-like component accumulates, resulting in the well-known angular drift.
To shield the surface against high-frequency stochastic disturbances in the sensors measuring the pendulum’s angle () and angular velocity (), the analog signals will be passed through a discrete filter with a cutoff frequency close to . This filter is implemented recursively at each time step with a time constant of , defined by the following expressions:
Where:
Given that the sampling period is much smaller than the time constant (), the cutoff frequency can be approximately calculated as follows:
Selecting establishes a clear spectral separation between the rigid-body dynamics of the TWSBR and high-frequency sensor noise. Specifically, the dominant open-loop unstable pole of the unloaded pendulum lies at (), while the desired closed-loop longitudinal sliding manifold pole is placed at (). Because the filter bandwidth is nearly an order of magnitude higher than both the natural gravitational divergence rate and the closed-loop control bandwidth, the filter introduces negligible phase lag within the operational frequency range of the robot (introducing less than of phase delay at ), thereby preserving closed-loop stability margins while effectively attenuating white Gaussian MEMS noise and high-frequency structural vibrations above . Finally, for physical prototype deployment, this low-pass stage is intended to operate alongside a sensor fusion algorithm (such as a complementary or Kalman filter) to compensate for low-frequency gyroscope bias drift.
6. Trajectory Generation and Kinematic Guidance Law
To solve the trajectory-tracking problem in the plane, a guidance law was designed that transforms the global position error into desired velocity (, ) and acceleration (, ) commands compatible with the TWSBR’s inertial dynamics.
6.1. Parametric Reference Equations
For the experimental stage (in simulation), two different trajectories were defined (a circle and a Gerono’s lemniscate).
Case 1: Circular Trajectory
A circular trajectory was defined with a constant radius of and an angular frequency of , expressed by the following equations:
The vector components of the desired velocity in the inertial reference frame are obtained by differentiating with respect to time:
Case 2: Gerono’s Lemniscate
This classic curve is defined by a horizontal extent amplitude of A and a traversal frequency of , expressed by the following equations:
Whereas their corresponding kinematic velocity profiles in the inertial reference frame are as follows:
6.2. Kinematic Guidance Law and Non-Minimum Phase Mitigation
For an inverted pendulum to begin moving forward or turning in a specific direction, the wheels must execute a counter-intuitive movement —moving initially in the opposite direction— due to the system’s non-minimum phase characteristic. If the robot attempts to move forward, the wheels will instantly accelerate backward, causing the pendulum to tilt forward; to compensate for the gravitational effect, the robot begins to move forward as intended. Mathematically, this implies that the transfer function possesses zeros in the right half of the s-plane. Upon receiving a command for an abrupt change in heading, the system initially responds in reverse; this often results in small "hooks" or inward dips before the robot enters the curve, particularly when the desired trajectory exceeds the physical limitations of the TWSBR.
The non-minimum phase effect on the trajectory is a physical limitation of the robot (the right-half-plane zero cannot be eliminated); the only way to mitigate its impact on the trajectory in the plane is to alert the guidance system in advance that a curve is approaching, allowing the pendulum to begin tilting before reaching the apex. To achieve this, the equation for the desired orientation () can be slightly modified by adding a look-ahead term based on the vehicle’s analytical velocities.
The position error in the inertial reference frame is defined as and . To mitigate the physical effect arising from the inverted pendulum’s intrinsic non-minimum phase characteristic—which manifests during high-curvature trajectories—a geometric anticipation term (look-ahead) was incorporated. The robot’s desired orientation () is calculated by projecting the future velocity required by the trajectory in question:
Where is the lateral attraction gain and is the anticipation factor. The local heading error is continuously normalized to keep it well-conditioned:
The raw velocity setpoints are defined by projecting the local translational error (), defining a , a gain , and applying physical saturation limits:
6.3. Dynamic Smoothing and Analytical Acceleration Generation
To avoid discontinuities and infinite mathematical spikes in the derivatives—generated by the atan2 function at zero crossings—the velocity profiles were conditioned using a critical inertial filter with a time constant , defined as ().
Based on this smoothing, the desired continuous and differentiable accelerations are derived, which predictively feed the equivalent loops of the SMC:
To dampen and eliminate vehicle understeer during the tightest curves of the trajectory (lemniscate), a direct mathematical rotational friction/damping term was incorporated into the angular acceleration:
7. Simulation Results
To validate the theoretical stability guarantees and trajectory-tracking performance of the proposed cascaded controller, numerical simulations were conducted in MATLAB/Simulink over a horizon with a fixed sampling step of (). Crucially, the inner SMC and intermediate velocity-PI loops remained strictly parameterized with the unloaded nominal model (Table 6) across all test cases.
7.1. Test Scenarios and Perturbation Setup
Two reference trajectories in the plane were evaluated: a constant-curvature circular path of radius and angular frequency , and a figure-eight Gerono’s lemniscate with semi-width and frequency . The outer look-ahead kinematic guidance controller was parameterized with a position gain , a look-ahead distance , and a heading gain . Table 7 summarizes the trajectory, guidance, and disturbance parameters used in the simulations.
Each trajectory was tested under two distinct operating regimes while keeping the inner SMC and intermediate velocity-PI loops strictly tuned to the unloaded nominal parameters (Table 6):
- Nominal Case: The TWSBR operates with its unloaded physical parameters (Table 3) in a noise-free, disturbance-free environment, establishing a baseline for ideal tracking accuracy.
- Loaded and Perturbed Case: The plant is simultaneously subjected to: i) the full parametric payload variation from Table 3 (increasing chassis mass by and shifting the center of mass height l by , which quadruples the inertial determinant ); ii) zero-mean additive white Gaussian noise (, sampled at ) injected into the IMU pitch () and pitch-rate () measurements; and iii) periodic asymmetric impulsive disturbances of applied to a single wheel every () to induce coupled pitch and yaw perturbations.
Baseline Cascaded PID Benchmark: To establish a fair comparative baseline under identical outer-loop guidance and sensing conditions, a conventional cascaded PID controller [11] was implemented by replacing only the inner dynamic SMC laws with two decoupled linear PID channels:
The baseline gains were tuned for critically damped response under nominal unloaded conditions () while avoiding phase-lag oscillations from the IMU low-pass filter, yielding , , for the pitch channel, and , , for the yaw channel.
7.2. Performance Analysis
Table 8 summarizes the quantitative performance metrics evaluated after the initial transient (), including the Euclidean position Root Mean Square Error (RMSE), maximum tracking error, Integral of Absolute Error (IAE), maximum pitch excursion (), peak actuator torque (), and Integral of Squared Control Input ().
- Trajectory Tracking Invariance: As shown in Figure 1 and Figure 2, the TWSBR closely tracks both trajectories without exhibiting the characteristic inward “hooks” caused by non-minimum phase dynamics, confirming the effectiveness of the look-ahead kinematic guidance term (). Remarkably, transitioning from the ideal nominal case to the heavily loaded and perturbed regime increases the steady-state RMSE by only () on the circle and () on Gerono’s lemniscate.
- Vertical Stabilization and Impulse Rejection: Across all scenarios, the pitch angle remains strictly bounded within , maintaining a wide safety margin below the physical tilt limit of (). Whenever the periodic asymmetric impulses hit the wheel every (Figure 3), the longitudinal SMC rapidly arrests the induced pitch excursion and restores vertical equilibrium in under without destabilizing the trajectory.
- Control Effort and Chattering Suppression: Under nominal conditions, peak motor torques remain below with minimal energy expenditure (). Under combined payload uncertainty, IMU noise, and external impulses (Figure 4), the controller increases its peak torque output to —utilizing less than of the actuator saturation limit—while the low-pass filter and boundary layers () effectively prevent high-frequency chattering.
Comparative Benchmark Against Baseline Cascaded PID: To further highlight the robustness advantages of the proposed architecture, Figure 5 compares the closed-loop response against a standard cascaded PID controller [11] sharing the exact same outer look-ahead guidance law and intermediate velocity-PI loop, tuned for nominal unloaded operation. While the linear PID maintains acceptable tracking in the nominal unloaded regime, introducing the +51% payload shift reduces the effective pitch control authority nearly threefold. As a result, the baseline PID exhibits sustained pitch oscillations exceeding the physical safety margin and suffers severe non-minimum phase looping distortions during high-curvature turns. In contrast, the proposed cascaded SMC preserves tight trajectory invariance and rapid impulse recovery without saturating the actuators.
Figure 1.
Circular trajectory tracking in the plane under payload uncertainty, IMU noise, and periodic impulses.
Figure 1.
Circular trajectory tracking in the plane under payload uncertainty, IMU noise, and periodic impulses.

Figure 2.
Gerono’s lemniscate tracking in the plane under payload uncertainty, IMU noise, and periodic impulses.
Figure 2.
Gerono’s lemniscate tracking in the plane under payload uncertainty, IMU noise, and periodic impulses.

Figure 3.
Position tracking error and pitch angle response during Gerono’s lemniscate under loaded and perturbed conditions.
Figure 3.
Position tracking error and pitch angle response during Gerono’s lemniscate under loaded and perturbed conditions.

Figure 4.
Right () and left () wheel control torques under loaded and perturbed conditions.

Figure 5.
Comparative performance between the proposed cascaded SMC and a standard cascaded PID controller during Gerono’s lemniscate tracking under combined payload uncertainty (+51% mass), IMU noise, and periodic asymmetric wheel impulses.
Figure 5.
Comparative performance between the proposed cascaded SMC and a standard cascaded PID controller during Gerono’s lemniscate tracking under combined payload uncertainty (+51% mass), IMU noise, and periodic asymmetric wheel impulses.

8. Conclusions
This paper presented a kinematically decoupled robust cascaded control architecture for Two-Wheeled Self-Balancing Robots (TWSBRs) operating under severe parametric uncertainties, sensor measurement noise, and external impulsive disturbances. By exploiting the structural decoupling between longitudinal and yaw dynamics near the vertical equilibrium point, the inner dynamic loop separates control authority into two independent boundary-layer Sliding Mode Control (SMC) channels—governing pitch stabilization and heading orientation, respectively—while an intermediate velocity-PI loop and a Pure Pursuit-inspired look-ahead kinematic outer loop ensure planar path guidance.
Theoretical stability analysis based on Lyapunov theory established finite-time convergence to the sliding manifolds, bounded tracking within the continuous boundary layers without high-frequency actuator chattering, and local asymptotic stability of the underactuated zero dynamics via LaSalle’s invariance principle. Numerical simulations on a realistic nonlinear TWSBR model across circular and Gerono’s lemniscate trajectories demonstrated that:
- Invariance to Payload and External Perturbations: Despite a increase in chassis mass, a shift in center-of-gravity height (raising the gravitational destabilizing torque from to ), MEMS IMU noise, and periodic wheel impulses, the proposed controller maintained pitch excursions strictly below and kept planar tracking RMSE within (circle) and (lemniscate).
- Superiority Over Linear Cascaded Control: Comparative benchmarks against a nominally tuned cascaded PID controller sharing identical outer-loop guidance confirmed that, while linear control performs adequately under unloaded nominal conditions, the payload-induced shift in gravitational stiffness causes the baseline PID to lose vertical balance () and suffer a sevenfold increase in trajectory RMSE ( vs. on the lemniscate).
- Non-Minimum Phase Mitigation and Actuator Feasibility: The look-ahead kinematic guidance law effectively suppressed non-minimum phase trajectory distortions during high-curvature turns, while continuous boundary-layer smoothing kept peak motor torques below —well within the physical actuator limits.
Future work will focus on experimental validation on a physical TWSBR prototype embedded at a sampling rate, as well as the integration of online disturbance observers to further tighten boundary-layer bounds under time-varying payloads.
Author Contributions
Conceptualization, J.M.I.Z.; methodology, J.M.I.Z.; software, J.M.I.Z. and I.A.R.M.; validation, J.M.I.Z. and I.A.R.M.; formal analysis, J.M.I.Z. and I.A.R.M.; writing—original draft preparation, J.M.I.Z.; writing—review and editing, J.M.I.Z.; supervision, J.M.I.Z. All authors have read and agreed to the published version of the manuscript.
Funding
This research received no external funding.
Data Availability Statement
The original contributions presented in the study are included in the article; further inquiries can be directed to the corresponding author.
Conflicts of Interest
The authors declare no conflicts of interest.
References
- Grasser, F.; D’Arrigo, A.; Colombi, S.; Rufer, A.C. JOE: A Mobile, Inverted Pendulum. IEEE Trans. Ind. Electron. 2002, 49, 107–114. [Google Scholar] [CrossRef]
- Chan, R.P.M.; Stol, K.A.; Halkyard, C.R. Review of Modelling and Control of Two-Wheeled Robots. Annu. Rev. Control 2013, 37, 89–103. [Google Scholar] [CrossRef]
- Zhang, H.; Mohamad Nor, N. Control Strategies for Two-Wheeled Self-Balancing Robotic Systems: A Comprehensive Review. Robotics 2025, 14, 101. [Google Scholar] [CrossRef]
- Utkin, V.I. Sliding Modes in Control and Optimization; Springer-Verlag: Berlin, Heidelberg, 1992. [Google Scholar]
- Ngo, Q.H.; Nguyen, N.P.; Nguyen, C.N.; Tran, T.H.; Ha, Q.P. Two-Wheeled Self-Balancing Robot Modeling and Nonlinear Control. In Proceedings of the 2017 14th International Conference on Ubiquitous Robots and Ambient Intelligence (URAI), 2017; pp. 238–243. [Google Scholar] [CrossRef]
- Levant, A. Sliding Order and Sliding Accuracy in Sliding Mode Control. Int. J. Control 1993, 58, 1247–1263. [Google Scholar] [CrossRef]
- Shtessel, Y.; Edwards, C.; Fridman, L.; Levant, A. Sliding Mode Control and Observation; Birkhäuser: New York, NY, 2014. [Google Scholar] [CrossRef]
- Gutiérrez, D.; Fridman, L.; Moreno, J.A. Control de un Carro-Péndulo con algoritmos por Modos Deslizantes Continuos. In Proceedings of the Memorias del Congreso Nacional de Control Automático 2017, Monterrey, Nuevo León, Mexico, 2017. [Google Scholar]
- Jmel, I.; Dimassi, H.; Hadj-Said, S.; Farza, M. Super Twisting Algorithm for Two Wheeled Inverted Pendulum with Unmeasured State. In Proceedings of the 2023 IEEE 11th International Conference on Systems and Control (ICSC), 2023; pp. 201–206. [Google Scholar] [CrossRef]
- Karam, E.H.; Habeeb, R.S.; Mjeed, N. A New Approach in Design of Sliding Mode Controller by Optimization State Feedback for Two Wheeled Self Balancing Robot. Int. J. Open Inf. Technol. 2020, 8, 39–44. [Google Scholar]
- Pratama, D.; Binugroho, E.H.; Ardilla, F.; Pratama, P.S.; Binugroho, E.H.; Ardilla, F.; Pramadihanto, D. Movement Control of Two Wheels Balancing Robot Using Cascaded PID Controller. In Proceedings of the 2015 International Electronics Symposium (IES), 2015; pp. 94–99. [Google Scholar] [CrossRef]
Table 6.
Cascaded Velocity-PI and SMC Controller Gains.
| Gain / Parameter | Value | Description |
|---|---|---|
| Velocity loop proportional gain | ||
| Velocity loop integral gain | ||
| Maximum desired pitch angle bound | ||
| Pitch angle error stiffness gain | ||
| Pitch angular velocity damping gain | ||
| Yaw angle error stiffness gain | ||
| Yaw angular velocity damping gain | ||
| Longitudinal discontinuous robustness gain | ||
| Rotational discontinuous robustness gain | ||
| Longitudinal boundary layer thickness | ||
| Rotational boundary layer thickness |
Table 7.
Simulation, Trajectory, and Disturbance Parameters.
| Category | Parameter | Value |
|---|---|---|
| Circular Trajectory | Radius () | |
| Angular frequency () | ||
| Gerono’s Lemniscate | Semi-width (A) | |
| Angular frequency () | ||
| Kinematic Guidance | Position gain () | |
| Look-ahead distance () | ||
| Heading gain () | ||
| External Disturbances | IMU Gaussian noise () | |
| Periodic wheel impulse | every |
Table 8.
Quantitative Performance Comparison Between Proposed Cascaded SMC and Baseline Cascaded PID ().
Table 8.
Quantitative Performance Comparison Between Proposed Cascaded SMC and Baseline Cascaded PID ().
| Trajectory | Controller / Condition | RMSE | Max Error | IAE | ISU | ||
|---|---|---|---|---|---|---|---|
| [m] | [m] | [ms] | [deg] | [Nm] | [] | ||
| Circle | Proposed SMC (Nominal) | 0.1481 | 0.3873 | 13.7502 | 5.92 | 1.47 | 0.70 |
| Proposed SMC (Perturbed) | 0.1569 | 0.4539 | 14.0622 | 6.98 | 2.97 | 16.59 | |
| Baseline PID (Nominal) | 0.2045 | 1.2476 | 19.6377 | 12.35 | 3.79 | 7.29 | |
| Baseline PID (Perturbed) | 1.9081 | 4.0666 | 109.4687 | 128.25 | 6.76 | 1781.60 | |
| Gerono’s Lemniscate | Proposed SMC (Nominal) | 0.2751 | 0.6415 | 15.0151 | 3.80 | 1.38 | 1.48 |
| Proposed SMC (Perturbed) | 0.2772 | 0.6677 | 15.2912 | 6.92 | 3.01 | 17.29 | |
| Baseline PID (Nominal) | 0.4793 | 1.1973 | 23.3830 | 10.65 | 1.24 | 1.44 | |
| Baseline PID (Perturbed) | 2.1106 | 4.8413 | 120.0247 | 133.67 | 6.49 | 1748.00 | |
| Indicates loss of vertical stabilization () under the payload increase and impulsive disturbances. | |||||||
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.
Copyright: This open access article is published under a Creative Commons CC BY 4.0 license, which permit the free download, distribution, and reuse, provided that the author and preprint are cited in any reuse.