Adaptive Direct Teaching Control with Variable Load of the Lower Limb Rehabilitation Robot (LLR-II)

Most lower limb rehabilitation robots use fixed training trajectories and lack participation of physiotherapists. In addition, there is a lack of attention on combining direct teaching function with rehabilitation robots, which enables physiotherapists to plan trajectories directly. In this paper, an adaptive direct teaching function with variable load that can be applied to the sitting/lying lower limb rehabilitation robot-II (LLR-II) is proposed. First, the structural design and electrical system of LLR-II are introduced. The dynamic equation of LLR-II considering joint flexibility is derived and analyzed. Then, the impact of joint flexibility on LLR-II is reduced by introducing the intermediate input variables. Based on this, the control law of the dragging teaching stage and the replay stage in the direct teaching function with variable load is designed and the adaptive control strategy eliminates the influence of different patients. In addition, the control law is simulated and verified. Finally, some preliminary experiments of the adaptive direct teaching function with variable load on LLR-II are carried out, and the results showed that the control law has good performance, which lays the foundation for future work.


Introduction
More than 15 million people around the world suffer strokes every year, and about 5 million of them are permanently disabled, according to the World Health Organization (WHO). A stroke causes damage to the nervous system and leads to patients losing some or all of the ability of their lower limbs, which influences their quality of life [1][2][3]. The lower limb rehabilitation robot is an application of robotic technology for patients with lower limb dysfunction [4]. In recent years, several kinds of lower limb rehabilitation (LLR) robots have been developed [5]. These can be divided into single degree-of-freedom gait trainers [6], wearable gait trainers [7,8], suspended gait trainers [9][10][11][12], and sitting/lying gait trainers [13,14]. Carleton University proposed a virtual gait rehabilitation robot (ViGRR) for bed-ridden stroke patients, which can provide average gait motion training and other targeted exercises, such as leg press, stair stepping, and motivational gaming [15]. M. Bouri et al. developed a new rehabilitation robot called Lambda. The patient's hip, knee, and ankle can be mobilized conveniently based on two translational articulations and one rotational for ankle mobilization, for carrying out rehabilitation, fitness, or highlevel sport training [16]. Switzerland proposed a suspended gait trainer called Lokomat, whose left and right mechanism legs assist patients to simulate the walking gait of healthy people and restore the control ability of the nervous system [17,18]. Yildiz University of Science and Technology in Turkey made a sitting/lying gait trainer, Physiotherabot, to assist patients to do passive training and active training [19]. The Swortec company developed an advanced sitting gait trainer called MotionMaker [20], which consists of two robotic orthoses comprising motors and sensors, and a control unit that manages the transcutaneous electrical muscle stimulation with real-time regulation. A new applicable sitting/lying lower limb rehabilitation robot (LLR-II) is proposed in this paper. Compared with the above sitting/lying rehabilitation robots, it can adjust the leg length by motors and transfer the patient without the assistance tool by a multifunctional seat.
Teaching control is one of the control strategies for LLR robots, which enables the physiotherapist to conduct gait planning. As for the indirect teaching control, Zhao et al. [21][22][23] proposed a teaching strategy for a planar three degrees of freedom (DoF) LLR robot based on acceleration sensors. The physiotherapist drags the patient to train, and the motion information is extracted by the external accelerometers placed on the patient's lower limbs. Guo et al. [24,25] proposed a novel physiotherapist interaction gait planning method including a multi-joint wearable teaching device with adjustable operating force and an LLR robot. The physiotherapist can operate the teaching device to plan a personalized trajectory and perceive the interaction force from patients. Feng et al. developed a graphic teaching method for a planar 3-DoF LLR robot [26,27]. The physiotherapist can draw any personalized teaching trajectories by the touch screen to conduct gait planning. However, for the indirect teaching method by a wearable device wearing on the patient or the physiotherapist, it takes much time and effort to put on and take off the device. For the indirect teaching method by graphics, there is a lack of interactive participation of the physiotherapist. As for the direct teaching control, the physiotherapist conducts gait planning by dragging the robotic arm directly. Emken et al. proposed a direct teaching method for gait training of a lightweight planar 2-DoF LLR robot [28]. The motor is in release state when the physiotherapist drags the robotic arm. Sun et al. proposed a direct teaching method to program the ankle's complex motion path in a 3-RSS/S ankle rehabilitation parallel robot [29]. The controllers release drive voltages which enable torque motors to rotate freely with the outside force on the cranks. Neither of them uses force sensors and the physiotherapist must overcome the weight of the robotic arm. Yang et al. proposed a direct teaching method for a horizontal 3-DoF terminal traction LLR robot based on a six-dimensional terminal force sensor [30]. The physiotherapist drags the sensor at the end of the robot to conduct gait planning. However, the patient is not on the robot during this process. It cannot adapt to the weight of lower limbs of different patients. In this paper, a new adaptive direct teaching control is proposed. It enables the physiotherapist to conduct gait planning by dragging the robotic arm directly. In addition, it is adaptive for the weight of robotic arm and lower limbs of different patients, so that it can adapt to different patients on the robot during the teaching process.
This paper presents an adaptive direct teaching function with variable load that can be applied on the LLR-II shown in Figure 1. It enables physiotherapists to plan trajectory directly by dragging the robotic arm in the dragging teaching stage and then drives patients to train based on the teaching trajectory in the replay stage. The structural system and the electrical system are introduced, and the human-machine interaction mechanics model considering joint flexibility is analyzed. Based on this, the control law of the adaptive direct teaching function with variable load is designed and the simulation results verify the correctness of the control law. Finally, experiments with two subjects involved have been completed and proved that the physiotherapist can plan personalized trajectories for different patients based on the proposed adaptive direct teaching function with variable load on the LLR-II. Machines 2021, 9, x FOR PEER REVIEW 3 of 19 The rest of this paper is organized as follows. Section 2 introduces the LLR-II, including the structural design, the electrical system and the human-machine interaction mechanics model considering joint flexibility; Section 3 presents the control law of the adaptive direct teaching function with variable load and the related simulation; Section 4 shows the preliminary experiments conducted on the LLR-II and the related analysis; finally, Section 5 concludes this study and provides suggestions for future work.

Structural Design and Electrical System
Based on modular design principle, LLR-II consists of five parts including left mechanism leg module, right mechanism leg module, multifunctional seat, control box and touch screen.
As shown in Figure 2a, in order to correspond to human joints of the hip, knee, and ankle, the mechanical leg is designed as a 3-DOF mechanism with electrically adjustable length of thigh and calf. As shown in Figure 2b, in order to enhance the stability of frame and reduce the weight of the two mechanism leg modules, the hip motor (SMP8024B, by Shanghai Mindong Mechanism Electron Co., Ltd., Shanghai, China) is installed on the frame below the hip rotation axis and connected with the input end of the hip joint through a synchronous belt, and transmits motion through the hip harmonic reducer (LHSG-40-100-C-III, by Suzhou Shiyue Transmission Technology Co., Ltd., Suzhou, China). In order to solve the excessive driving power of the hip joint, the knee motor (SMP8024B, by Shanghai Mindong Mechanism Electron Co., Ltd., Shanghai, China) is installed at the back of the hip rotation axis to balance part of the weight of the mechanical leg. The ankle motor (TBM-6025-A, by Hangzhou Mosen Electromechanical Technology Co., Ltd., Hangzhou, China) is directly connected to the ankle harmonic reducer (HMHS-20-100-1, by Shanghai Haiju Electrical Technology Co., Ltd., Shanghai, China) to ensure the ankle module is lightweight and compact. In order to guarantee the safety of training, variable joint limitation including fastened limit groove and driven limit groove was designed. The rest of this paper is organized as follows. Section 2 introduces the LLR-II, including the structural design, the electrical system and the human-machine interaction mechanics model considering joint flexibility; Section 3 presents the control law of the adaptive direct teaching function with variable load and the related simulation; Section 4 shows the preliminary experiments conducted on the LLR-II and the related analysis; finally, Section 5 concludes this study and provides suggestions for future work.

Structural Design and Electrical System
Based on modular design principle, LLR-II consists of five parts including left mechanism leg module, right mechanism leg module, multifunctional seat, control box and touch screen.
As shown in Figure 2a, in order to correspond to human joints of the hip, knee, and ankle, the mechanical leg is designed as a 3-DOF mechanism with electrically adjustable length of thigh and calf. As shown in Figure 2b, in order to enhance the stability of frame and reduce the weight of the two mechanism leg modules, the hip motor (SMP8024B, by Shanghai Mindong Mechanism Electron Co., Ltd., Shanghai, China) is installed on the frame below the hip rotation axis and connected with the input end of the hip joint through a synchronous belt, and transmits motion through the hip harmonic reducer (LHSG-40-100-C-III, by Suzhou Shiyue Transmission Technology Co., Ltd., Suzhou, China). In order to solve the excessive driving power of the hip joint, the knee motor (SMP8024B, by Shanghai Mindong Mechanism Electron Co., Ltd., Shanghai, China) is installed at the back of the hip rotation axis to balance part of the weight of the mechanical leg. The ankle motor (TBM-6025-A, by Hangzhou Mosen Electromechanical Technology Co., Ltd., Hangzhou, China) is directly connected to the ankle harmonic reducer (HMHS-20-100-1, by Shanghai Haiju Electrical Technology Co., Ltd., Shanghai, China) to ensure the ankle module is lightweight and compact. In order to guarantee the safety of training, variable joint limitation including fastened limit groove and driven limit groove was designed. In order to detect dynamic information of thigh and calf accurately and sensitively, two joint torque sensors (M2210B, by Junde Technology Co., Ltd., Shenzhen, China) are installed at the output end of the harmonic reducer in the hip joint and knee joints respectively. A three-dimensional force sensor (R121C, by Changzhou Right Measurement and Control System Co., Ltd., Changzhou, China) is installed at the output end of the ankle joint to detect dynamic information of the foot pedal. The profile and detailed parameters of main sensors are shown in Figure 3a. With the thigh push rod (LEC606-1000-100-7-24-235-DW, by Suzhou Yuancheng Mingchuang Technology Co., Ltd., Suzhou, China) and the calf push rod (LEC606-1000-100-7-24-200-DW, by Suzhou Yuancheng Mingchuang Technology Co., Ltd., Suzhou, China) installed inside the mechanical leg, LLR-II can fit patients of different heights. With the electric push rod (LEC606-1000-60-7-24-195-DW, by Suzhou Yuancheng Mingchuang Technology Co., Ltd., Suzhou, China) installed in the direction of the human coronal axis at the bottom of the frame, LLR-II can fit patients of different sizes. In addition, as shown in Figure 3b, the multifunctional seat can be extended and retracted through an electric push rod (LEC606-1000-265-7-24-400-DW, by Suzhou Yuancheng Mingchuang Technology Co., Ltd., Suzhou, China) to facilitate patients to get on and off the robot. Meanwhile, the seat is adjustable in height through a lifting column (DC24V, 3000N load, 8 mm/s speed, by Yueqing Xunchi Electric Co., Ltd., Yueqing, China) to align the hip axis of rotation of the patient and LLR-II.   In order to detect dynamic information of thigh and calf accurately and sensitively, two joint torque sensors (M2210B, by Junde Technology Co., Ltd., Shenzhen, China) are installed at the output end of the harmonic reducer in the hip joint and knee joints respectively. A three-dimensional force sensor (R121C, by Changzhou Right Measurement and Control System Co., Ltd., Changzhou, China) is installed at the output end of the ankle joint to detect dynamic information of the foot pedal. The profile and detailed parameters of main sensors are shown in Figure 3a. With the thigh push rod (LEC606-1000-100-7-24-235-DW, by Suzhou Yuancheng Mingchuang Technology Co., Ltd., Suzhou, China) and the calf push rod (LEC606-1000-100-7-24-200-DW, by Suzhou Yuancheng Mingchuang Technology Co., Ltd., Suzhou, China) installed inside the mechanical leg, LLR-II can fit patients of different heights. With the electric push rod (LEC606-1000-60-7-24-195-DW, by Suzhou Yuancheng Mingchuang Technology Co., Ltd., Suzhou, China) installed in the direction of the human coronal axis at the bottom of the frame, LLR-II can fit patients of different sizes. In addition, as shown in Figure 3b, the multifunctional seat can be extended and retracted through an electric push rod (LEC606-1000-265-7-24-400-DW, by Suzhou Yuancheng Mingchuang Technology Co., Ltd., Suzhou, China) to facilitate patients to get on and off the robot. Meanwhile, the seat is adjustable in height through a lifting column (DC24V, 3000N load, 8 mm/s speed, by Yueqing Xunchi Electric Co., Ltd., Yueqing, China) to align the hip axis of rotation of the patient and LLR-II. In order to detect dynamic information of thigh and calf accurately and sensitively, two joint torque sensors (M2210B, by Junde Technology Co., Ltd., Shenzhen, China) are installed at the output end of the harmonic reducer in the hip joint and knee joints respectively. A three-dimensional force sensor (R121C, by Changzhou Right Measurement and Control System Co., Ltd., Changzhou, China) is installed at the output end of the ankle joint to detect dynamic information of the foot pedal. The profile and detailed parameters of main sensors are shown in Figure 3a. With the thigh push rod (LEC606-1000-100-7-24-235-DW, by Suzhou Yuancheng Mingchuang Technology Co., Ltd., Suzhou, China) and the calf push rod (LEC606-1000-100-7-24-200-DW, by Suzhou Yuancheng Mingchuang Technology Co., Ltd., Suzhou, China) installed inside the mechanical leg, LLR-II can fit patients of different heights. With the electric push rod (LEC606-1000-60-7-24-195-DW, by Suzhou Yuancheng Mingchuang Technology Co., Ltd., Suzhou, China) installed in the direction of the human coronal axis at the bottom of the frame, LLR-II can fit patients of different sizes. In addition, as shown in Figure 3b, the multifunctional seat can be extended and retracted through an electric push rod (LEC606-1000-265-7-24-400-DW, by Suzhou Yuancheng Mingchuang Technology Co., Ltd., Suzhou, China) to facilitate patients to get on and off the robot. Meanwhile, the seat is adjustable in height through a lifting column (DC24V, 3000N load, 8 mm/s speed, by Yueqing Xunchi Electric Co., Ltd., Yueqing, China) to align the hip axis of rotation of the patient and LLR-II.   Electrical control system of LLR-II contains the central control, human-machine interaction control, sensing feedback control and motion control, as shown in Figure 4. The human-machine interaction system displays the operation interface of control system and feeds back training status to the physiotherapist. The motion control system realizes the function of patients' getting on and off the robot and rehabilitation training. The sensor system receives the value of sensors including pressure sensors (RX-M3232L, by Rouxi Techonology Co., Ltd., Changzhou, China, potentiometers (KTC2-100 mm, by Miran Technology Co., Ltd., Shenzhen, China), encoders (8 bits, RS485 Modbus, RTU 24 V, by Realwetech Techonology Co., Ltd., Beijing, China) and angle sensors (LVT416T, 0~±180 • , by Msensor Technology Co., Ltd., Wuxi, China). Based on the physiotherapist's instruction, and sensing system's feedback, the central control system guides the motion control system to complete tasks of planning and training.
Machines 2021, 9, x FOR PEER REVIEW 5 of 19 Electrical control system of LLR-II contains the central control, human-machine interaction control, sensing feedback control and motion control, as shown in Figure 4. The human-machine interaction system displays the operation interface of control system and feeds back training status to the physiotherapist. The motion control system realizes the function of patients' getting on and off the robot and rehabilitation training. The sensor system receives the value of sensors including pressure sensors (RX-M3232L, by Rouxi Techonology Co., Ltd., Changzhou, China, potentiometers (KTC2-100 mm, by Miran Technology Co., Ltd., Shenzhen, China), encoders (8 bits, RS485 Modbus, RTU 24 V, by Realwetech Techonology Co., Ltd., Beijing, China) and angle sensors (LVT416T, 0 ~ ±180°, by Msensor Technology Co., Ltd., Wuxi, China). Based on the physiotherapist's instruction, and sensing system's feedback, the central control system guides the motion control system to complete tasks of planning and training.

Human-Machine Interaction Mechanics Model Considering Joint Flexibility
As shown in Figure 5a, the joint torque sensor mainly changes resistance value through deformation, which leads to a voltage change on both sides of the sensor and feeds back a torque value for each joint. As shown in Figure 5b, the harmonic reducer is mainly composed of rigid gear, flexible gear and a harmonic generator. When the joint is in motion, the driving end drives harmonic generator to rotate, and the flexible wheel deforms accordingly. After deformation, the partial teeth of the flexible gear mesh with the partial teeth of the rigid gear to complete the transmission of motion. Therefore, the torque sensor and harmonic reducer mentioned above result in LLR-II's joint flexibility.

Human-Machine Interaction Mechanics Model Considering Joint Flexibility
As shown in Figure 5a, the joint torque sensor mainly changes resistance value through deformation, which leads to a voltage change on both sides of the sensor and feeds back a torque value for each joint. As shown in Figure 5b, the harmonic reducer is mainly composed of rigid gear, flexible gear and a harmonic generator. When the joint is in motion, the driving end drives harmonic generator to rotate, and the flexible wheel deforms accordingly. After deformation, the partial teeth of the flexible gear mesh with the partial teeth of the rigid gear to complete the transmission of motion. Therefore, the torque sensor and harmonic reducer mentioned above result in LLR-II's joint flexibility.
Machines 2021, 9, x FOR PEER REVIEW 5 of 19 Electrical control system of LLR-II contains the central control, human-machine interaction control, sensing feedback control and motion control, as shown in Figure 4. The human-machine interaction system displays the operation interface of control system and feeds back training status to the physiotherapist. The motion control system realizes the function of patients' getting on and off the robot and rehabilitation training. The sensor system receives the value of sensors including pressure sensors (RX-M3232L, by Rouxi Techonology Co., Ltd., Changzhou, China, potentiometers (KTC2-100 mm, by Miran Technology Co., Ltd., Shenzhen, China), encoders (8 bits, RS485 Modbus, RTU 24 V, by Realwetech Techonology Co., Ltd., Beijing, China) and angle sensors (LVT416T, 0 ~ ±180°, by Msensor Technology Co., Ltd., Wuxi, China). Based on the physiotherapist's instruction, and sensing system's feedback, the central control system guides the motion control system to complete tasks of planning and training.

Human-Machine Interaction Mechanics Model Considering Joint Flexibility
As shown in Figure 5a, the joint torque sensor mainly changes resistance value through deformation, which leads to a voltage change on both sides of the sensor and feeds back a torque value for each joint. As shown in Figure 5b, the harmonic reducer is mainly composed of rigid gear, flexible gear and a harmonic generator. When the joint is in motion, the driving end drives harmonic generator to rotate, and the flexible wheel deforms accordingly. After deformation, the partial teeth of the flexible gear mesh with the partial teeth of the rigid gear to complete the transmission of motion. Therefore, the torque sensor and harmonic reducer mentioned above result in LLR-II's joint flexibility.

Lagrange Functions Considering Joint Flexibility
The joint flexibility of the hip and knee is generated by a joint torque sensor and harmonic reducer in series. The joint flexibility of ankle is generated by harmonic reducer independently. In the modeling process, the joint flexibility of hip, knee and ankle is unified and expressed by a series linear spring of virtual rigid reducers. The linear spring stiffness in the ankle joint model is the harmonic reducer stiffness, and the linear spring stiffness in the hip and knee joint model is the series stiffness of the joint torque sensor and harmonic reducer. The relationship is expressed as: where, k i represents the total stiffness of linear spring, k si the represents stiffness of torque sensor, and k hi represents the stiffness of harmonic reducer. A flexible joint model is established in Figure 6a. τ mi represents the output torque of the permanent magnet synchronous motor i. J mi represents the rotational inertia of the permanent magnet synchronous motor i. m ri represents the rotor mass of the permanent magnet synchronous motor i. θ ri represents the rotation angle of the permanent magnet synchronous motor i. τ ci represents the output torque of the permanent magnet synchronous motor i through the virtual rigid reducer. θ i represents the rotation output angle of the permanent magnet synchronous motor i through the virtual rigid reducer. N i represents the reduction ratio of the virtual rigid reducer i. k i represents the stiffness coefficient of the linear spring i. τ i represents the torque of joint i. I li represents the rotational inertia of link i and m li represents the mass of link i. Besides, θ i = N i θ ri and τ ci = N i τ mi . The joint flexibility of the hip and knee is generated by a joint torque sensor and harmonic reducer in series. The joint flexibility of ankle is generated by harmonic reducer independently. In the modeling process, the joint flexibility of hip, knee and ankle is unified and expressed by a series linear spring of virtual rigid reducers. The linear spring stiffness in the ankle joint model is the harmonic reducer stiffness, and the linear spring stiffness in the hip and knee joint model is the series stiffness of the joint torque sensor and harmonic reducer. The relationship is expressed as: where, ki represents the total stiffness of linear spring, ksi the represents stiffness of torque sensor, and khi represents the stiffness of harmonic reducer. A flexible joint model is established in Figure 6a. τmi represents the output torque of the permanent magnet synchronous motor i. Jmi represents the rotational inertia of the permanent magnet synchronous motor i. mri represents the rotor mass of the permanent magnet synchronous motor i. θri represents the rotation angle of the permanent magnet synchronous motor i. τci represents the output torque of the permanent magnet synchronous motor i through the virtual rigid reducer. θi represents the rotation output angle of the permanent magnet synchronous motor i through the virtual rigid reducer. Ni represents the reduction ratio of the virtual rigid reducer i. ki represents the stiffness coefficient of the linear spring i. τi represents the torque of joint i. Ili represents the rotational inertia of link i and mli represents the mass of link i. Besides, θi = Niθri and τci = Niτmi. On the premise that the control effect is not affected during modeling, it is usually assumed that: 1. The motor rotor is an axisymmetric rigid body. 2. The joint electrodynamics is fast enough compared with its mechanical dynamics, and the influence of motor dynamics is not considered in flexible joint model. 3. Joint deformation is regarded as a linear torsion spring in the range of linear elasticity.
The dynamic characteristics of LLR-II will change due to the difference in patients, so the dynamic equation deduced is under no load. It can be simplified into a three-link model as shown in Figure 6b On the premise that the control effect is not affected during modeling, it is usually assumed that: The motor rotor is an axisymmetric rigid body.

2.
The joint electrodynamics is fast enough compared with its mechanical dynamics, and the influence of motor dynamics is not considered in flexible joint model.

3.
Joint deformation is regarded as a linear torsion spring in the range of linear elasticity.
The dynamic characteristics of LLR-II will change due to the difference in patients, so the dynamic equation deduced is under no load. It can be simplified into a three-link model as shown in Figure 6b, where l i represents the length of link i, d i represents the distance between the mass center of link i and the rotation center of joint i. The dynamic equation of LLR-II deduced by Lagrange method is expressed as: where, L represents the Lagrange function; K represents the total kinetic energy; P represents the total potential energy; Q i represents the generalized force and Θ i represents the generalized coordinates.
For LLR-II considering joint flexibility, there are two groups of generalized coordinates. One is the rotation angle coordinates of the motor through virtual rigid re- , and the other is the rotation angle coordinates of each link q = q 1 q 2 q 3 . Different from rigid robots, the total kinetic energy K of LLR-II is composed of the kinetic energy K mi of each joint motor and the kinetic energy K li of each link. The total potential energy P of LLR-II is composed of the total gravitational potential energy P g generated by each link and motor, and the total elastic potential energy P k generated by each joint. Therefore, the Lagrange function of LLR-II considering joint flexibility is expressed as:

Dynamics Equation of Motor End Considering Joint Flexibility
For the generalized coordinate θ = θ 1 θ 2 θ 3 , the corresponding generalized torque is the output torque τ ci of the motor through virtual rigid reducer. The dynamic equation can be established by the Lagrange method. The output torque τ c of the motor of the hip, knee, and ankle joints through the virtual rigid reducer can be obtained by consolidating τ c1 , τ c2 and τ c3 into matrix form: where, J represents the matrix of rotational inertia, .. θ represents the angular acceleration matrix of each joint motor through virtual rigid reducer, S represents the matrix of coupling, .. q represents the angular acceleration matrix of each link, K represents the equivalent stiffness matrix, θ represents the angle matrix of each joint motor through virtual rigid reducer, q represents the angle matrix of each link and τ c represents the torque matrix generated by each motor through the virtual rigid reducer.
The coupling terms are much smaller than the other terms, so it is ignored. Then the motor end dynamic equation of LLR-II considering joint flexibility is simplified as:

Dynamics Equation of Link End Considering Joint Flexibility
For the generalized coordinate q = q 1 q 2 q 3 , the corresponding generalized torque is the human-machine interaction torque τ exti applied at each link. The dynamics equation can be established by Lagrange method.
The human-machine interaction torques of each link τ ext1 , τ ext2 , and τ ext3 can be obtained and reduced to a matrix as: where, M(q) represents the inertial matrix, . q represents the velocity coupled vector matrix, g(q) represents the gravity matrix, τ ext represents the human-machine interaction torque matrix, θ represents the position matrix of each joint motor through virtual rigid reducer, and q represents the position matrix of each link.
The coupling term is far less than other terms, so it is ignored. Then the link end dynamic equation of LLR-II considering joint flexibility is simplified as:

Control Law of the Adaptive Direct Teaching Function with Variable Load
The adaptive direct teaching function with variable load contains the dragging teaching stage and the replay stage, as shown in Figure 7. In the dragging teaching stage, the physiotherapist directly imposes human-machine interaction force on the robotic arm. Then, the system generates and records the teaching trajectory. In the replay stage, the system assists patients to train according to the teaching trajectory.
where, M(q) represents the inertial matrix, q represents the velocity coupled vector matrix, g(q) represents the gravity matrix, ext τ represents the human-machine interaction torque matrix, θ represents the position matrix of each joint motor through virtual rigid reducer, and q represents the position matrix of each link. The coupling term is far less than other terms, so it is ignored. Then the link end dynamic equation of LLR-II considering joint flexibility is simplified as: ext M(q)q + C(q,q)q + g(q) = + K(θ -q τ )

Control Law of the Adaptive Direct Teaching Function with Variable Load
The adaptive direct teaching function with variable load contains the dragging teaching stage and the replay stage, as shown in Figure 7. In the dragging teaching stage, the physiotherapist directly imposes human-machine interaction force on the robotic arm. Then, the system generates and records the teaching trajectory. In the replay stage, the system assists patients to train according to the teaching trajectory.

Analysis of Factors Affecting Joint Flexibility and Ways of Intermediate Output Variables
Each joint of LLR-II has certain joint flexibility due to the use of torque sensors and the harmonic reducer, which makes it a rigid-flexible coupling nonlinear system. And there is a certain steady-state error and jitter while training. Therefore, the joint flexibility must be restrained before the control law is designed. Both sides of the link end dynamic equation and the motor end dynamic equation are multiplied by Jacobian inverse transpose matrix  J(q) and we can get:

Analysis of Factors Affecting Joint Flexibility and Ways of Intermediate Output Variables
Each joint of LLR-II has certain joint flexibility due to the use of torque sensors and the harmonic reducer, which makes it a rigid-flexible coupling nonlinear system. And there is a certain steady-state error and jitter while training. Therefore, the joint flexibility must be restrained before the control law is designed. Both sides of the link end dynamic equation and the motor end dynamic equation are multiplied by Jacobian inverse transpose matrix J(q) − and we can get: where q), J(q) − g(q) = g x (q), J(q) − K = K x and J(q) − J = J x .
Since (8) is derived in joint space, it is applicable to multiple-degree of freedom systems as well as single-degree of freedom systems, so the equivalent plane model of a single flexible joint can be obtained, as shown in Figure 8a. There are two main factors affecting joint flexibility including joint stiffness K x and equivalent inertia moment J x . If the joint stiffness K x is increased or the equivalent inertia moment J x is reduced, the influence of joint flexibility can be weakened. joint robots, which can effectively suppress the influence of joint flexibility. The equivalent plane model of a flexible single joint with reduced inertia moment is shown in Figure 8b. After the inertia moment of motor end is reduced to Jθx, the motor can be kept in balance by introducing the intermediate input variable ux. Then, the balance equation of the motor in equivalent plane model of flexible single joint, and the relationship between the intermediate input variable ux and the output force Fc at motor end can be expressed as:

Control Law of Dragging Teaching Stage
The position-based impedance control has a good robustness which can effectively compensate for the dynamic parameter identification error and the influence of friction. The increase of joint stiffness K x can be achieved by adding passive flexible elements to the joint through mechanical design. However, this is complex, and the suppression effect is limited by machining accuracy and assembly error.
The reduction of equivalent inertia moment J x can be achieved by introducing an intermediate input variable. A large number of experiments have been done on DLR flexible joint robots, which can effectively suppress the influence of joint flexibility. The equivalent plane model of a flexible single joint with reduced inertia moment is shown in Figure 8b. After the inertia moment of motor end is reduced to J θx , the motor can be kept in balance by introducing the intermediate input variable u x . Then, the balance equation of the motor in equivalent plane model of flexible single joint, and the relationship between the intermediate input variable u x and the output force F c at motor end can be expressed as: By extending the equivalent plane model of a flexible single joint to multiple degrees of freedom, the system equation of LLR-II that introduces the intermediate input variables can be expressed as:

Control Law of Dragging Teaching Stage
The position-based impedance control has a good robustness which can effectively compensate for the dynamic parameter identification error and the influence of friction. Therefore, the position-based impedance control form is chosen to design the control law of dragging teaching stage.

Control Law of Dragging Teaching Stage with No Load
LLR-II is a human-machine coupling system. When dragging the robotic arm with patients to teach, the system cannot obtain accurate dynamic equations due to the differences between patients. Thus, the influence of patients is ignored first and the control law of dragging teaching stage with no load is designed.
It is necessary to establish the mapping relationship between the human-machine interaction torque and the speed of each link through target impedance characteristics. For different patients, the speed of each link is variable to adapt to different disease levels under the same human-machine interaction torque. For same patient, the speed of each link is variable according to the magnitude of human-machine interaction torque. Meanwhile, the inherent inertia should remain unchanged to prevent excessive motor output gain. Therefore, the target impedance characteristics of the dragging teaching stage and the expected positions of the system under different human-machine interaction torques q d are defined. Besides, the control law for realizing the target impedance characteristics u tt is defined as: where, B θ represents the coefficient of the expected speed . q d . K p represents the proportional term coefficient matrix and K d represents the coefficient matrix of the derivative term, which are both positive definite matrixes.
Take the state space variable of dynamic equations as θ. Then, the state space variable equations of LLR-II are expressed as: Each joint has four state space variables (θ i , . θ i , q i , . q i ), and the control law u tt cannot meet the requirements of system stability. Therefore, the position of the link under quasisteady-state is estimated online by detecting the output position θ of the motor through the virtual rigid reducer to improve the control law u tt [31].
When the LLR-II is in a quasi-steady state, the acceleration ..
q and the velocity . q of the link end are both zero, and the relationship between θ and q can be obtained. There is a unique q corresponding to any given θ in the workspace, as shown in (13). After establishing the functional relationship between q and θ, its inverse solution is taken, and the link end position q(θ) is online estimated by the motor through virtual rigid position θ [31].
Since h l −1 (θ) is not easy to solve, the value of q(θ) can be obtained through iteration for any given joint angleq. The iterative equation is obtained. They are expressed as: where, T l (q) = θ − K −1 g(q) andq l,i is the i'th iteration value.
In the actual control, considering high real-time requirements of position-based impedance control form, the initial iteration valueq l,0 is set to be the initial position. Satisfactory results can be obtained after one or two iterations.
The control law u tt of the dragging teaching stage with no load consists of two parts according to above derivation. One is the input item u g , which offsets the influence of each link's gravity, and the other is the input item u imp , which makes each link obey the target impedance characteristics.
The gravity compensation term u g in the control law of the dragging teaching stage with no load and the target impedance characteristics can be obtained. Since the expected position q d under different human-machine interaction moments is solved, the impedance term u imp in the control law of dragging teaching stage with no load can be obtained. They are written as: ..
Machines 2021, 9, 142 11 of 19 Finally, the control law u tt of the dragging teaching stage with no load is expressed as:

Control Law of the Dragging Teaching Stage with Variable Load
When LLR-II is loaded, the influence of patients on dynamic characteristics results in that u g deduced from (14) cannot fully compensate for the actual influence of variable load from different patients. Thus, the adaptive control strategy is added to solve this problem based on the control law of the dragging teaching stage with no load [32].
Due to the linear separability of dynamic parameters, the estimation model can be designed by using the dynamic parameters with no load as a reference. Then the gravity compensation termû g of the estimated model can be obtained. The generalized error e tt in the dragging teaching stage with variable load can be expressed. The gravity term of the actual model can be obtained through torque sensors and three-dimensional force sensors. The adaptive control law of dragging teaching stage with variable load is constructed as: (16) where, γ tt is the adaptive gain coefficient,P g is the value of dynamic parameters of the estimation model, and Y g (q) is the angle matrix associated with the gravity term.
The indicator C tt of the adaptive convergence in dragging teaching stage with variable load is set in (17), where C dt is the starting threshold for the completion of adaptive convergence. The value C dt can be artificially defined to achieve the best compliance. C tt = 1, e tt e tt ≤ C dt 0, e tt e tt > C dt (17) The control law u adp_tt of the dragging teaching stage with variable load is Then, the control system of the dragging teaching stage with variable load is shown in Figure 9.
The control law uadp_tt of the dragging teaching stage with variable load is Then, the control system of the dragging teaching stage with variable load is shown in Figure 9.

Simulation of the Control Law of Dragging Teaching Stage
In the simulation of the control law in the dragging teaching stage, the relevant parameters are set, including the stiffness of each joint K = 100 (Nm/rad), B θ = 500 550 550 , K P = 100, K d = 10, JJ θ = 3. Subject 1 is set to be the criterion group and its weight of thigh, calf, and foot are 10(Kg), 10(Kg), and 5(Kg), respectively. Subject 2 is set to be the compared group and its weight of thigh, calf, and foot are 9.8(Kg), 9.7(Kg) and 4.5(Kg), respectively. Conforming to the human-machine interaction torque, the position contrast curves of three links in the dragging teaching stage are shown in Figure 10.

Simulation of the Control Law of Dragging Teaching Stage
In the simulation of the control law in the dragging teaching stage, the relevant parameters are set, including the stiffness of each joint K = 100 (Nm/rad), 500 550 550      B , KP = 100, Kd = 10, JJθ = 3. Subject 1 is set to be the criterion group and its weight of thigh, calf, and foot are 10(Kg), 10(Kg), and 5(Kg), respectively. Subject 2 is set to be the compared group and its weight of thigh, calf, and foot are 9.8(Kg), 9.7(Kg) and 4.5(Kg), respectively. Conforming to the human-machine interaction torque, the position contrast curves of three links in the dragging teaching stage are shown in Figure 10.  Figure 10 shows that when the adaptive error is in a certain range, the dragging trajectories of the same link are smooth and basically the same. Besides, with the same τ ext , the smaller the B θ is, the faster the dragging speed is. And with the same B θ , the larger the τ ext is, the faster the dragging speed is.
The simulation results have verified the correctness of the control law in the dragging teaching stage. This enables physiotherapists to carry out teaching trajectories by smoothly dragging the robotic arm. For subjects with same weight, the speed of the links can be changed according to the human-machine interaction torque. For subjects with different weights, the speed of links is variable by setting the target impedance characteristic B θ . It has proved that the teaching trajectory and the desired trajectory are the same when the adaptive error is in a certain range.

Control Law of the Replay Stage
In the replay stage, the LLR-II drives patients to train according to the motion information in dragging teaching stage. Thus, the design purpose in the control law of the replay stage is to establish the relationship between the teaching trajectory and the motion of motors. There is no human-machine interaction torque applying on the robot system, which means τ ext = 0. The dynamics equation of LLR-II which uses the intermediate input variables u to suppress the influence of joint flexibility is expressed as:

Control Law of the Replay Stage with No Load
In the dragging teaching stage, the system cannot obtain an accurate dynamic equation due to the difference bewteen patients, which affects its control effect. Therefore, the control law of the replay stage with no load is designed first.
The PD control at the motor end with an appropriate feedforward compensation term can carry out the specified trajectory [32]. The nonlinear part of the system dynamics equation is selected as the feedforward compensation term. Thus, the control law in the replay stage with no load u tr is composed of two parts. One compensates the nonlinear feedforward item u tr_ffI of nonlinear part, and the other controls the position tracking item u tr_pos of each link to track the teaching trajectory.
By combining the dynamic equations at the motor end and the link end, it can be concluded that there is a relationship between the nonlinear terms and intermediate variables u. And the nonlinear feedforward compensation term u tr_ffI with no load can be obtained. Then, the relationship between the expected position of motor end θ d and the link end q d is obtained. The trajectory tracking control of the link end position q in replay stage can be transformed into the trajectory tracking control of the actual position θ of the motor end. Therefore, the position tracking item u tr_pos in the replay stage can be obtained. They are expressed as: Finally, the control law of the replay stage with no load u tr can be written as:

Control Law of the Replay Stage with Variable Load
The nonlinear compensation term u tr_ffI cannot fully compensate the nonlinear part of system dynamics due to the influence of different patients. Therefore, the adaptive control strategy is used to solve this problem, which is similar to the dragging teaching stage.
Due to the linear separability of dynamic parameters, the estimation model is designed taking dynamic parameters with no load as reference and the estimation model of the nonlinear compensation termû tr_ f f I can be obtained. Y(q, . q, .. q) represents the angle matrix related to dynamic parameters, andP c represents the value of dynamic parameters of the estimated model.
Then, the generalized error e tr of the replay stage with variable load can be obtained. The nonlinear compensation of the actual model can be fed back by sensors. The adaptive control law of the dragging teaching stage with variable load is constructed, where γ tr represents the adaptive gain factor. They are written as: The adaptive convergence indicator C tr of the dragging teaching stage is determined when the load is set. C dr represents the trigger threshold for the completion of adaptive convergence in the dragging teaching stage with variable load. It is the same as the drag instruction and can be set manually. C tr is expressed as: 1, e tr e tr ≤ C dr 0, e tr e tr > C dr (23) Finally, the control law of the dragging teaching stage with variable load u adp_tr can be expressed as: and the control system of the replay stage with variable load is shown in Figure 11.
adaptive control law of the dragging teaching stage with variable load is constructed, where γtr represents the adaptive gain factor. They are written as:  (22) The adaptive convergence indicator Ctr of the dragging teaching stage is determined when the load is set. Cdr represents the trigger threshold for the completion of adaptive convergence in the dragging teaching stage with variable load. It is the same as the drag instruction and can be set manually. Ctr is expressed as: Finally, the control law of the dragging teaching stage with variable load uadp_tr can be expressed as: Y q q q P K θ θ K θ θ (24) and the control system of the replay stage with variable load is shown in Figure 11.

Simulation of the Control Law in the Replay Stage
In the simulation of the control law, the relevant parameters are the same as they are in the dragging teaching stage. Besides, K P = 100, K d = 10, JJ θ = 3. In addition, two subjects are also the same as they are in the dragging teaching stage.
The comparison diagrams of the dragging teaching trajectory and the replay trajectory of subject 1 s different parts driven by the link are shown in Figure 12a-c. The comparison diagrams of dragging teaching trajectory and replay trajectory of subject 2 s different parts driven by the link are shown in Figure 12d-f. Figure 12 shows that the dragging teaching trajectory and the replay trajectory are highly coincident. In addition, the replay trajectories are smooth. The simulation results have verified the correctness of the control law of the replay stage. It enables LLR-II to track the teaching trajectory accurately. It has proved that the teaching trajectory and the desired trajectory are the same when the adaptive error is in a certain range. ferent parts driven by the link are shown in Figure 12d-f. Figure 12 shows that the dragging teaching trajectory and the replay trajectory are highly coincident. In addition, the replay trajectories are smooth. The simulation results have verified the correctness of the control law of the replay stage. It enables LLR-II to track the teaching trajectory accurately. It has proved that the teaching trajectory and the desired trajectory are the same when the adaptive error is in a certain range.

Experiment
The experimental platform is shown in Figure 13 and the length of each link are set as l1 = 0.44 m, l2 = 0.34 m, and l3 = 0.17 m. According to the obtained dynamic parameters of LLR-II, the adaptive direct teaching function with variable load was experimentalized. The length of each link is the same as it was in the dynamic identification experiment. Two subjects with basically the same height and different weights were selected to drag their right legs for a comparative experiment. The weight of subject 1 was 75 Kg and the weight of subject 2 was 90 Kg.

Experiment
The experimental platform is shown in Figure 13 and the length of each link are set as l 1 = 0.44 m, l 2 = 0.34 m, and l 3 = 0.17 m. According to the obtained dynamic parameters of LLR-II, the adaptive direct teaching function with variable load was experimentalized. The length of each link is the same as it was in the dynamic identification experiment. Two subjects with basically the same height and different weights were selected to drag their right legs for a comparative experiment. The weight of subject 1 was 75 Kg and the weight of subject 2 was 90 Kg.

Experiment of Dragging Teaching Stage
In the experiment of the dragging teaching stage, the experiment duration was set to be 25 s. During this period, the instructor dragged link 2 to drive two subjects to train. We set the parameters in the control law of the dragging teaching stage with load as: JJθ = 5,

Experiment of Dragging Teaching Stage
In the experiment of the dragging teaching stage, the experiment duration was set to be 25 s. During this period, the instructor dragged link 2 to drive two subjects to train. We set the parameters in the control law of the dragging teaching stage with load as: JJ θ = 5, B θ = 1900, K P = 150, K d = 150, γ tt = 10. The human-machine interaction force was received through the thin film pressure sensors and the position of link 2 was received through the angle sensor, and the sampling frequency f s = 100 Hz was set. The actual human-machine interaction force curve is shown in Figure 14a, and the actual position curve is shown in Figure 14b. is received, and the speed of the subject is changed. The experiment proves that the control law of the dragging teaching stage with variable load can eliminate the differences between subjects and the LLR-II is able to drive patients of different weights to carry out compliant teaching trajectories according to the human-machine interaction force.

Experiment of the Replay Stage
In the experiment of the dragging teaching stage, the positions received from link 2′s angle sensors were filtered offline. Regarding it as teaching trajectory, LLR-II led two subjects to track the corresponding teaching trajectory respectively. We set each parameter in the control law of the dragging teaching stage with load as JJθ = 5, Bθ = 1900, KP = 150, Kd = 150, γtt = 10. Figure 15a,b are the comparison curves of the teaching trajectory and the replay trajectory of subject 1 and subject 2, respectively. It can be seen from Figure 15 that the teaching trajectories of two subjects are basically the same as the replay trajectories, and the maximum error between the teaching trajectory and the replay trajectory is less than 0.1 rad. The experimental results have proved the correctness and rationality of the adaptive direct teaching function of LLR-II.

Conclusions and Future Work
This paper proposes an adaptive direct teaching function with variable load on LLR-II for rehabilitative physiotherapists to plan trajectories directly. The control law of the dragging teaching stage and the replay stage were designed, with which the physiotherapist can plan personalized trajectories for different patients by dragging the It can be seen from Figure 14 that the instructor began to exert the human-machine interaction force in 1 s, and it reached a constant force state in about 2 s. Link 2 basically drives the subjects to move at the same time when the human-machine interaction force is received, and the speed of the subject is changed. The experiment proves that the control law of the dragging teaching stage with variable load can eliminate the differences between subjects and the LLR-II is able to drive patients of different weights to carry out compliant teaching trajectories according to the human-machine interaction force.

Experiment of the Replay Stage
In the experiment of the dragging teaching stage, the positions received from link 2 s angle sensors were filtered offline. Regarding it as teaching trajectory, LLR-II led two subjects to track the corresponding teaching trajectory respectively. We set each parameter in the control law of the dragging teaching stage with load as JJ θ = 5, B θ = 1900, K P = 150, K d = 150, γ tt = 10. Figure 15a,b are the comparison curves of the teaching trajectory and the replay trajectory of subject 1 and subject 2, respectively. In the experiment of the dragging teaching stage, the positions received from link 2′s angle sensors were filtered offline. Regarding it as teaching trajectory, LLR-II led two subjects to track the corresponding teaching trajectory respectively. We set each parameter in the control law of the dragging teaching stage with load as JJθ = 5, Bθ = 1900, KP = 150, Kd = 150, γtt = 10. Figure 15a,b are the comparison curves of the teaching trajectory and the replay trajectory of subject 1 and subject 2, respectively. It can be seen from Figure 15 that the teaching trajectories of two subjects are basically the same as the replay trajectories, and the maximum error between the teaching trajectory and the replay trajectory is less than 0.1 rad. The experimental results have proved the correctness and rationality of the adaptive direct teaching function of LLR-II. It can be seen from Figure 15 that the teaching trajectories of two subjects are basically the same as the replay trajectories, and the maximum error between the teaching trajectory and the replay trajectory is less than 0.1 rad. The experimental results have proved the correctness and rationality of the adaptive direct teaching function of LLR-II.

Conclusions and Future Work
This paper proposes an adaptive direct teaching function with variable load on LLR-II for rehabilitative physiotherapists to plan trajectories directly. The control law of the dragging teaching stage and the replay stage were designed, with which the physiotherapist can plan personalized trajectories for different patients by dragging the robotic arm directly and LLR-II trains the patient by tracking the trajectory. Different from a robot with rigid joints, the joint flexibility caused by harmonic reducers and torque sensors was considered while establishing the dynamic model. The dynamic equations were derived and analyzed, which are the basis of the adaptive direct teaching function with variable load. Then, the joint flexibility of the LLR-II was decreased by introducing intermediate input variables, and the control law of the dragging teaching stage and the replay stage were designed. Moreover, an adaptive control strategy was added for compensating for the impact of different patients. Based on this, the control law was simulated and its correctness was verified. Finally, the experiments of adaptive direct teaching control with variable load were completed and the preliminary experimental trials verify the effectiveness of the proposed adaptive direct teaching function, including the dragging teaching stage and the replay stage. It proves that the physiotherapist can plan personalized trajectories based on the proposed adaptive direct teaching function with variable load on LLR-II.
In the future, further improvements are to be made on LLR-II based on the adaptive direct teaching function with variable load. For example, the dragging teaching trajectory can be optimized by combining rehabilitation knowledge to better adapt to patients. It is also noted that the proposed function of LLR-II needs to be tested on real patients instead of volunteers, which may expose more problems for the mechanical design and control strategy, i.e., clinical tests should be made in the future work.