The control system of the lower limb rehabilitation robot adopts a three-layer architecture consisting of a high-level controller, a middle-level control layer, and a low-level execution layer. Built on a hierarchical distributed control framework, this design utilizes modular task decomposition and hierarchical state management to clearly define the logical topology while significantly enhancing resistance to dynamic disturbances. Traditional embedded solutions often face real-time performance limitations in distributed architectures due to communication protocol constraints. In contrast, ROS 2 employs the Data Distribution Service (DDS) for efficient node-to-node communication [
25,
26,
27]. By integrating Micro-ROS, the high-level controller and middle-level control layer share the same DDS communication protocol, enabling seamless data exchange. This approach significantly improves real-time performance and system stability compared to conventional embedded system designs [
28,
29]. A detailed comparison of control strategies is provided in
Table 1.
This control system adopts a hierarchical architecture to achieve an efficient and reliable operational framework, with each hardware layer carefully designed to ensure functional integrity. The high-level controller, built on the Jetson Nano computing platform, runs ROS 2 to handle global task planning and complex data processing. The middle-level control layer, based on the ESP32-S3 embedded board with Micro-ROS, focuses on data integration and communication bridging between layers, ensuring precise command execution. The low-level execution layer, implemented on the STM32F405 development board running the FreeRTOS real-time operating system, employs the Field-Oriented Control (FOC) algorithm for high-precision motor position control, enabling accurate trajectory tracking. Furthermore, four brushless DC motors serve as actuation units to drive the lower limb rehabilitation robot. The overall framework is illustrated in
Figure 1, where each layer is clearly defined and operates in seamless coordination, highlighting the technical advantages of the hierarchical architecture.
2.1. High-Level Controller Design
In the lower limb rehabilitation robot control system, the high-level controller functions as the central component, akin to a “brain”, executing high-performance, real-time tasks. These tasks include precise gait data processing, accurate generation and transmission of control commands, and efficient execution of complex algorithms. Given the stringent requirements for real-time performance, reliability, and computational capability, ROS 2 serves as an optimal framework due to its robust multi-threading capabilities and built-in Data Distribution Service (DDS) communication mechanism [
30,
31].
Specifically, ROS 2 utilizes DDS to support three efficient communication methods. Topic communication, based on a publish/subscribe model [
32], enables asynchronous information exchange and is well-suited for real-time transmission of continuous data streams, such as gait data. Service communication, following a request/response model [
33], provides synchronous communication, making it ideal for scenarios requiring immediate feedback, such as dynamically adjusting motion parameters. Action communication combines features of both approaches, supporting long-duration task execution while allowing clients to monitor progress and receive intermediate results [
34], making it suitable for complex algorithm implementation. The topology of these communication methods is illustrated in
Figure 2.
ROS 2 improves the flexibility and adaptability of the high-level controller while enhancing system stability and reliability, establishing a foundation for efficient operation of the lower limb rehabilitation robot. In the ROS 2-based design of the high-level controller, code is organized into nodes, with each node assigned a specific function. Multi-threading supports parallel task processing, boosting efficiency and resource utilization [
35].
A Jetson Nano platform is employed as the high-performance hardware foundation, with its Ubuntu operating system enhanced by a real-time kernel patch and configured to operate the ROS 2 framework. Based on this hardware–software architecture, an advanced controller system is developed, comprising two core functional nodes that work in coordination: one for processing human gait data and the other for generating rehabilitation training commands. This configuration enables precise control and management of the rehabilitation training process.
Functional Node 1 is responsible for integrating and processing gait data. To obtain continuous, smooth, and control-ready gait trajectory data, Functional Node 1 processed the collected raw gait data through segmented concatenation and spline interpolation smoothing. Specifically, the gait data are divided into the initiation phase, walking phase, and termination phase according to the stages of gait motion. The initiation and termination phases consisted of a static standing posture and its time-reversed sequence, respectively. For the walking phase, a single gait cycle served as the basis, with transitional segments generated by linear interpolation to ensure smooth connections between cycles. The complete walking sequence is then formed by repetitively concatenating these cycles according to the predefined number of repetitions. In the smoothing process, the angular degree sequences
associated with the left, right, and intermediate sides are used to perform curve fitting, based on the triangular splines
. The objective is to minimize the following functional to obtain a smooth curve:
In this context,
denotes the smoothing parameter, which regulates the trade-off between data fidelity and curve smoothness. As
, the curve approaches strict interpolation of the original data, whereas larger values of
yield smoother curves at the expense of reduced fitting accuracy. Following spline fitting, m new sampling points are uniformly inserted between each pair of original data points, resulting in a smoothed trajectory sequence with a temporal resolution increased by a factor of m + 1. This processing approach preserves the intrinsic kinematic characteristics of the motion while markedly reducing angular discontinuities at the cycle junctions and enhancing both trajectory continuity and control feasibility, thereby providing high-quality input data for subsequent joint control of the lower-limb rehabilitation robot. After data integration, the node uploads the database information to the ROS 2 parameter server, enabling real-time updates and dynamic management of the database content. This approach allows other functional nodes to quickly access the required data by querying the database name, ensuring efficient data sharing. Furthermore, by utilizing the centralized management feature of the ROS 2 parameter server, the system enhances both flexibility and scalability, facilitating future functional expansions.
Functional Node 2 is responsible for transmitting control commands to the middle-level control layer. For specific rehabilitation training requirements, this node converts gait data, the preset training duration, and the selected training mode into standardized commands, which are subsequently transmitted to the middle-level control layer. The design process fully considered practical rehabilitation needs to ensure the accuracy and execution efficiency of the commands. Furthermore, the system is capable of adapting gait data based on the user’s height and the lengths of the thigh and shank segments, thereby enabling personalized rehabilitation schemes. The operation of Functional Node 2 depends on real-time gait data provided by Functional Node 1, with both nodes working cooperatively to maintain the stability of the overall system.
Leveraging the integration of the ROS 2 control framework on a Jetson Nano hardware platform, a comprehensive rehabilitation training system has been successfully implemented. This system unifies data processing, database management, and control command dissemination into a single platform, markedly enhancing the efficiency and accuracy of gait data processing. Furthermore, the use of the ROS 2 parameter server optimizes data management and access protocols, thereby establishing a robust foundation for the development of intelligent, personalized rehabilitation training solutions. The operational mechanism of the high-level controller is depicted in
Figure 3.
2.2. Design of the Middle-Level Control Layer and the Low-Level Execution Layer
Both the middle-level control layer and the low-level execution layer are implemented on embedded systems running the FreeRTOS real-time operating system. Utilizing FreeRTOS task scheduling capabilities, the single-threaded architecture simulates concurrent multitasking, thereby substantially enhancing real-time performance and task processing efficiency.
Embedded components ESP32-S3 and STM32F405 provide driver interfaces for various sensors and control units, ensuring efficient operation. A functional requirements analysis led to the selection of the ESP32-S3 platform to deploy Micro-ROS, with communication to the high-level controller achieved via the DDS framework. This decision ensures architectural consistency between the high-level controller and the middle-level control layer, both developed using the ROS 2 framework. Consequently, common communication issues in traditional embedded systems are resolved, and data format conversions are avoided.
At the core of the middle-level control layer, the ESP32-S3 runs FreeRTOS to meet Micro-ROS performance requirements and exploit its robust driver interface capabilities for integration with additional embedded platforms and sensors. In the lower limb rehabilitation robot control system, the ESP32-S3 functions as a key data relay station; the block diagram is shown in
Figure 4. Communication with the high-level controller is maintained via the DDS protocol, while data exchange with the low-level execution layer is achieved through the USART protocol. The flexible configuration of communication interfaces permits the combination of multiple common data types as required, thereby enhancing system scalability and adaptability.
Upon receiving instructions from the high-level controller, the middle-level control layer disassembles floating-point gait data into individual bytes and stores the result in a byte-based database for rapid retrieval and processing by the embedded system. In accordance with the high-level controller’s directives, the data are then transmitted in byte format to the low-level execution layer.
Within the low-level execution layer, the received byte data are reorganized in memory following a specified communication protocol and subsequently converted back into floating-point format for use by the motor control system. As the fundamental control unit, the low-level execution layer follows the process illustrated in
Figure 5. First, it receives byte streams organized according to the communication protocol. Next, the data are reconstructed and parsed based on byte length, after which the decoded joint angle commands are verified against predefined safety ranges. Finally, the reconstructed data are transmitted via the Controller Area Network (CAN) protocol to the motor control unit, thereby ensuring precise actuation. Real-time position feedback from the motor forms a closed-loop control system that ensures the overall performance meets the intended objectives.
2.3. Design of Motor Control System
The motor serves as a core actuator within the control system, playing a decisive role in achieving high-precision motion control. To ensure efficient and accurate position regulation, the system employs a self-developed motor driver control board (
Figure 6) integrated with Field-Oriented Control (FOC) technology. By decoupling the current and magnetic field, this technique enables precise regulation of motor torque and rotational speed, thereby significantly enhancing the system’s dynamic response and energy utilization efficiency.
The control block diagram presented in
Figure 7, outlines the process from sensor feedback to SVPWM signal generation. It delineates the functional modules and their interrelationships—including sensor feedback, coordinate transformation, PID control, and SVPWM signal generation—thereby facilitating high-precision motor position control in complex applications.
Within the FOC framework, accurate measurement of the three-phase stator currents (
,
, and
) is critical. In order to simplify the control algorithm and boost computational efficiency, the measured currents are transformed into a two-phase stationary coordinate system (
-
) via the Clarke Transformation, as depicted in
Figure 8. This mathematical transformation represents a three-phase system equivalently as a two-phase system.
Based on the motor angle computed during the previous control cycle, the Park Transformation converts the stator currents into orthogonal components
and
in the rotating reference frame (see
Figure 9).
The resulting and values are compared with the setpoints to form the input for the current loop PI controller. Adjustment of the PI parameters yields the voltage vectors and applied to the motor.
Encoder measurements capture the rotor’s mechanical position, which is converted into an electrical angle based on the number of pole pairs; the encoder also supplies the rotational speed. The measured three-phase currents undergo Clarke and Park transformations to yield the rotating frame components and , which are compared with the target values Tar() and Tar(). A current loop PI controller then generates voltage commands and . Subsequently, and are transformed back to the stationary frame as and via the inverse Park transformation. An SVPWM algorithm generates the switching signals for the three-phase inverter, ultimately driving the motor to complete closed-loop control.
Stability Analysis of Motor Control System
Consider the dq-frame model after Clarke/Park transform and feedforward decoupling:
where
is the q-axis current (A);
is the phase inductance (H);
is the phase resistance (
);
is the q-axis voltage command (V); and
denotes residual modeling error (assumed bounded:
).
where
is the rotor angular velocity (rad/s);
is the rotor inertia (kg·
);
is viscous damping (N·m·s);
is the torque constant (N·m/A); and
is the external load torque (N·m), assumed bounded:
.
The control architecture is a standard three cascaded loops: inner current PI, middle velocity PI (producing current reference), and outer position PID.
Assumption 1.
- 1.
(Decoupling) Feedforward/decoupling renders d–q channels approximately independent so that (6) holds with small residual . - 2.
(Timescale separation) Controller gains are chosen so that inner-loop (current) bandwidth ≫
middle-loop (velocity) bandwidth ≫
outer-loop (position) bandwidth, compactly written aswhere denote nominal time constants of the current, velocity, and position loops, respectively.
Theorem 1 (Cascaded stability and ISS)
. Under the above assumptions, let the inner current PI bewhere is the current error (A), the integrator state (such that has voltage dimension), and are PI gains. Let the middle-loop velocity controller be implemented in torque-normalized form:where s is the velocity error (rad/s), η the velocity integrator state (such that has torque dimension), and are torque-level gains (so that ). Then, under timescale separation, the cascaded closed-loop equilibrium is locally asymptotically stable. If disturbances are present and bounded, the closed-loop is input-to-state stable (ISS; i.e., bounded inputs imply bounded states, and inputs imply states ). Inner Loop. Consider the inner-loop Lyapunov candidate
where the first term represents electrical stored energy associated with current error and the second term represents integrator energy (units consistent since
has voltage dimension). Under the standard approximation that
and
are negligible on the current time scale (justified when inner-loop bandwidth ≫ middle-loop), direct differentiation yields
so
by LaSalle invariance. Including bounded inputs (
) leads to ISS-type bounds for the inner loop.
Middle Loop. With fast inner-loop tracking and the torque-normalized controller (
), the mechanical dynamics (neglecting
on this derivation step and assuming slowly varying reference) read
where the right-hand side is directly in torque units (N·m), so
carry torque dimension. Choose
where the first term is rotational kinetic-like energy and the second corresponds to the integrator (torque-scaled). Differentiation yields
hence,
under the idealized approximation; with bounded inner-loop error and load torque
, the middle loop satisfies ISS properties.
Composite Lyapunov. Define the composite candidate
with
(position energy-like term), weights
, and denote
(so
are Euclidean norms of the respective error vectors). Differentiation and substitution of subsystem derivatives yields an estimate of the form
where
depend on system parameters (
) and controller gains,
quantify cross-coupling strengths, and
collects bounded disturbance contributions (with constant upper bound
). Applying Young’s inequality
to the cross terms and choosing weights
and gains so that the diagonal (negative) terms dominate, one obtains constants
and
such that
Consequently, in the disturbance-free case (
) the equilibrium is locally asymptotically stable; for bounded
the system is input-to-state stable (ISS), i.e., steady-state error is bounded proportionally to disturbance magnitude.