Control of active lower limb prosthesis using human-in-the-loop scheme

Abstract In many cases robots are directly in touch with humans, this interaction is necessary to design control systems that take into account a human-machine relation. Particularly important is the case when humans share the control with a robot. So, in order to validate control schemes, it is necessary to test them in an environment where the human-machine interaction exists, what could be even dangerous for humans. We present a model of human useful to test controllers, and propose a scheme for human-in-the-loop under shared control. We test the model and the scheme in a lower limb prosthesis that implies naturally a human-machine interaction. Apart from this research, we propose an efficient and low-cost controller for the prosthesis, based on a sensory exoextension and a neuro-decoder consisting of a multilayer perceptrons. The results show the effectiveness of human model to emulate the human interaction.


PUBLIC INTEREST STATEMENT
The proposed method for prosthesis is useful to study the human correction of errors in automatic control. The participation of the human for fine adjustments due to disturbances. The active lower limb prosthesis has the advantage that the amputee can freely change the desired trajectory and does not depend on the healthy leg. It does not require a complex sensory system. Only hip reading status is required for mapping. The study would mainly benefit in the areas of medical robotic, automatic, and computational intelligent.

Introduction
Only in Mexico, according to Cruz (2016), there are 128 thousand amputations per year. With what arises the need to restore the motor capacity of amputees, and with it their autonomy. Scientific and technological advances increasingly allow the development of robotic devices with better performance, see, Martinez-Hernandez et al. (2018). However, more work is needed to make these devices not only tools but also able to completely replace missing limbs.
Prostheses can be classified according to the limb they replace in the upper and lower limbs. According to the actuation, the prostheses can be classified into passive and active. Ferreira et al. (2016) mention amputees who use passive limbs generally walk more slowly and expend significantly more energy, about 60% more according to Lawson et al. (2014). Active prostheses can restore locomotion functions and recognize human intention, see, Spanias et al. (2018). But the cost of a smart prosthesis is too high for most people, see, Wen et al. (2018). The reasons for the high cost are sensors and actuators, as well as control.
The most common control strategies are gait mode recognition, in combination with low impedance control and direct electromyography (EMG) control. Echo-control requires high mechanical impedance, it does not feel natural as it does not interact with the amputee, and is only useful for unilateral amputees. The finite state impedance control has the drawback of tuning many parameters as explained by Ferreira et al. (2016), while the EMG-based control is affected by the problem of fatigue, misalignment of electrodes and a low signal-to-signal ratio, see, Ryu et al. (2019); K. Zhang et al. (2019).
The acceptance of prostheses has been complicated by the fact that the control systems are not sufficiently intuitive and the sensory feedback is inadequate, as Yang and Liu (2021) comments in their work on hand prostheses. And as Wu et al. (2021) mentions, due to technological limitations, autonomous systems still cannot fully supply human participation. They suggest the definition of schemes where both elements interact to provide better performance together, creating more intelligent systems Dellermann et al. (2021). The development of this approach has been varied, based on forms of interaction Grønsund and Aanestad (2020); levels of human participation Mabrok et al. (2020); as well as application environments: labor Grønsund and Aanestad (2020), UAVs Feng et al. (2016), autonomous vehicles Li et al. (2020); Wu et al. (2021), economy, machine learning Dellermann et al. (2021), Goecks (2020), Mandel et al. (2017), and Perrusquía et al. (2021), social sciences Dautenhahn (1998), robotic prostheses Welker et al. (2021); Yang and Liu (2021) and rehabilitation Gao (2020).
Some researches have been developed in order to find human-robot interaction dynamics like in Roveda et al. (2020) where using a model-based reinforcement learning approach, they define an Artificial Neural Network to model the dynamics. This approach is not possible to modify directly each of the systems what compound the human. Shi et al. (2021) propose human-centred adaptive control of a lower limb rehabilitation robot based on an HRI dynamic model. An equivalent spring model in three-dimensional space is proposed to express the interaction force between the human and robot. Then, it is just defined one part of the human model, and it is not enough to describe a human in order to be possible to simulate, for example, a general human-machine environment avoiding the real, and most of the times dangerous, human participation, such that there is no a complete human model.
Human-in-the-loop (HITL) simply means a system completely or partially controlled by a human via a control manipulator Mabrok et al. (2020). HITL can be modeled as an input-output system. Mabrok et al. (2020) suggest three challenges in feedback control with HITL: • Understanding the spectrum of driver types with HITL.
• Derive models of human behavior • Incorporate human behavior into the formal feedback control methodology.
The importance of these schemes lies in the possibility of a quantitative evaluation of the impact of human behavior in dynamic systems Bae et al. (2019). They contribute to health care or reduction of energy consumption Mabrok et al. (2020). And they are mainly useful when robustness is a priority Yang and Liu (2021). From a control theory perspective.
Various HITL algorithms have been implemented in the area of prosthetics, orthotics, and lower extremity rehabilitation robots mainly for the off-line design of these devices, as well as in the configuration of controller parameters, for example, as in the work of J. Zhang et al. (2017) on optimization of exoskeletons and that of Welker et al. (2021) on optimization of ankle-foot prostheses, who comments on the disadvantages of such an approach. Since this scheme is recently investigated, there is not much research on human in the loop control for prostheses. Examples of these recent investigations are the works of Zhuang et al. (2019) and that of Yang and Liu (2021) where they carry out an implementation of HITL in hand prostheses.
In all these cases, the human has participated actively in the tests, which implies the submission to stress and risks typical of any experiment. Perrusquía et al. (2021) proposes a generalization of reinforcement learning to emulate human behavior. Grønsund and Aanestad (2020) consider humans as supervisors who are responsible for managing performance. Feng et al. (2016) designs human behavior based on cognitive architectures. Bae et al. (2019) regards the human as an intelligent, independent agent to maximize their idiosyncratic utility function. The nature of these schemes leads to the need for a model that mimics human behavior in loop human applications Mabrok et al. (2020).
According to Welker et al. (2021), robotic prostheses have not been sufficiently explored and there is still no definition of the basic principles of how humans and prostheses interact. It is not possible to design controllers based on a mathematical description of human-prosthesis dynamics Gao (2020). Feng et al. (2016) highlights models of human behavior based on cognitive architectures that include memory encoding and organization of elements in mental structures. Work is continuing on the human model, as in the work of Perrusquía et al. (2021), they propose a generalization of reinforcement learning that considers stimuli, skills, knowledge, and previous experiences to emulate human behavior. However, current models of the human are limited Mabrok et al. (2020).
• Human behavior has been considered as a random disturbance or as an error compensation mechanism, however humans cannot be considered as irrational decision makers that can be modeled as stochastic disturbances.
• HITL under shared control has not yet been implemented in active prostheses.
In order to study human interaction with active lower limb prostheses in efficient and safe ways, we propose a general scheme of HITL for active prostheses, which in turn avoids human involvement during controller testing. The contributions of the paper are • We propose an explicit human model-based system, which allows us to separately modify any part of the system. The model can be implemented for any system adapting the human model.
• Theory analysis of the proposed HITL • Application of the proposed HITL to active lower limb prosthesis

Human-in-the-loop with shared control
The human-in-the-loop with shared control proposed in this paper is illustrated in Figure 1. It has the system where the human influenced by the environment controls an exogenous system (a machine) in a shared way with autonomous control (the inner control of the machine).
We consider that there exists a system (machine) that is controlled by human and an autonomous controller. That is, there exists a system _ x ¼ hðx; uÞ; (1) if this can be rewritten in the affine form, where hðx; uÞ is a nonlinear function that depends on the state, x, and the control u 2 . And f ðxÞ and gðxÞ are nonlinear functions that depend just in the state, x.
On the other hand, the human can be considered like That means that human is not considered to be explicitly controlled. That's the reason why there is no control signal in (3). Human is a system that just react in response to the perceived environment, described by the state, x, of the controlled system. Moreover, the state, y, of the human is a function of the control signal, u 1 , what is applied to the controlled system. That simply means that human produces a signal that is considered as a control signal for another system, and that system produces a state, x, that provoke to human to evolve and produce u 1 . That is, in general, the behavior of the system in close loop, for the human-machine interaction.
And if we consider that the machine has an inner controller that produces the control signal, u 2 , and at the same time, it receives an outer control signal, u 1 , to add both getting the total control signal, Then in the close loop, it's defined an interaction by shared control. That is, the machine is controlled by an inner and outer control, provided by itself and by human.

Human model
The model of the human we propose consists of (1) Cognitive system. Within this system, the intention of the human is defined and transmitted to the motor system. Through an adaptation system, the human generates signals based on the perceived exogenous agents, which are transmitted to a control system that produces the extended actions necessary to achieve that the satisfaction error converges to zero. It can be simplified as a controller where u is the control signal produced by human, and f ðeðx; yÞÞ is a function that defines the controller dynamics, which is defined in terms of the satisfaction error eðx; yÞ, with x and y the states of the human and the exogenous system.
(1) Motor system. This system acts as a link between humans and exogenous systems. To convey his intention through movements and the imposition of states on the joints. Practically, this is regarded as an usual robot, that is, it can be described as where the states, y corresponds to the human-join states, what could regard the natural and extended actions at the same time, because the actions of the human are produced as a result of the states taken by each of the human-joints. Here, the control, u, is the produced signal by the cognitive system.
(1) Sensory system. It is a system that perceives (identifies and/or observes) exogenous systems or their states. Then, clearly a convenient representation is an observer, the sensors or the signal conditioning stage. Additionally, it can contain an identifier system.

Dð� xÞ
This equation represents an identified system, that describes an estimated dynamics of the exogenous system, where, � x is the estimated or sensed state for x.
The proposed human model has three signals: (1) Natural signals. These correspond to the physiological signals of a natural behavior, for example, the bio-mechanical signals that it produces when walking.
(2) Extended Signals. The signals that are produced for the manipulation of external agents, as in the manipulation of tools, are considered.
(3) Intentional signals. They correspond to those associated with human desires.

Human-robot interaction for active prosthesis
In human-robot interaction, the human defines the desired state of the joints through the residual limb, that is, through the natural actions, but human does not apply extended actions to share the control with the autonomous control of the prosthesis. Moreover, there isn't exist human feedback to present a human-machine scheme control where human just provides the human intention. In order to compare lately with a scheme where human provides a control signal by closing the loop. See, Figure 2.
To emulate the control of the prosthesis attached to the residual limb, we design a robot that represents the human-prosthesis system. The complete human-prosthesis system can be regarded as a 4-DOF robot.
The proposed scheme can be used as a test platform that involves the human being in active participation. The scheme allows to emulate human participation without risk to the human. In addition, the model's ability to learn allows it to be implemented with a real human in the same way that it can be implemented with any other plant, which can improve the performance of the model when learning from another human.
The 4-DOF robot is modeled as

Figure 2. Emulation of humanprosthesis interaction with a 4-DOF robot.
The residual limb is controlled by the human who perceives the prosthesis as a perturbation, which is defined where τ ¼ τ r þ τ p , τ r ¼ ½τ 1 ; τ 2 ; 0; 0� is the control for human hip and thigh τ p ¼ ½0; 0; τ 3 ; τ 4 � is the control over the prosthesis.

PD control for human-robot system
Regarding the amputee-prosthesis system as the previously described 4-DOF robot, we base in the perspective of robotics to define a controller for all the complete systems.
Considering, dynamics for the DC motors are almost linear, we can use simple controllers for the joints. We used PD control for the joints (10), where k p and k d are positive gains, q ¼ q d À q ¼ ½e r ; e p � is the tracking error, it includes the error for residual limb part, e r , and for the prosthesis, p , q d ¼ ½q rha ; q le � T is the desired trajectory. We use first-order low pass filter to estimate the derivatives. Here, we use first-order low pass filter to estimate the derivatives In order to obtain good controller, k p and k d , we need to identify the simplified model. For each joint, we use the following second order linear model, where q i is the joint position, τ i is the control, a i and b i are the parameters to be identified, d i is the coupling perturbation. (12) can be written in matrix form, There are n data. We define The object of the parameter identification is where The training data are y k ð Þ and Φ k ½ �: The optimal solution of Θ is We can write the error dynamic for each of the joints as where X is the state variable The PD control (10) can be rewritten as τ i ¼k i X i , closed-loop system becomes In order to assure stability of (17), we chose k i ¼ ½k 1i k 2i �, such that A i þ B i k i is negative definite, i.e., the following polynomial has negative roots, where the roots are ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffiffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffiffi ðâ i þb i k di Þ 2 À 4b i k pi q So we need the controller gains Here PD gains are based on the estimated parameters.

PID control for human-robot system
In the human-in-the-loop (HITL) as in Figure 1, there are two controllers interacting to control the prosthesis. The human signal is given priority over the tracking control signal. We define the human as an intelligent system that acts on a system based on knowledge acquired by interaction. The human applies actions based on the errors obtained by comparing what he wants and what he observes.
So HITL also needs a human model, which considers the following: (1) Past. The human is based on what he has learned from the system. He accumulates the experience, and takes an action proportional to this accumulated.
(2) Present. He acts to the response of the stimulus, and observes the response with each stimulus, to minimize the error in each application.
(3) Future. The human interacts more with the system, he learns his behavior so that he can anticipate his action.
The above three actions can be modeled as, It has the form of PID control. We need to specify the parameters of k p , k i , k d , and N.
The human model can be written as For q 1 and q 2 we have where q 2ha corresponds to the anthropomorphic femur angle desired with a bounded influence of the environment, what is always bounded. So q 1 and q 2 are bounded states.
q 1 and q 2 are variables measured directly by the amputee, they are in ð0; 2πÞ. The active prosthesis estimates the states to produce gait based on q r ¼ ½q 1 ; q 2 � 2 D; which are the residual signals from the residual limb.
We define the discrete sets We use mapping M to describe an anthropomorphic trajectory followed by the amputee, Since the model of mapping M is not available, we use the following neural network to estimate it, where i ¼ 1; 2, M, V and W are the output, hidden and input layer weight matrices, respectively, and q ¼ ½q T r ; 1�, � q i is based on the data set of Winter (2009) to train the network.
For training, the Backpropagation algorithm was applied using a descending gradient.
V i uses the same form as (21).

Stability analysis of PD
When we apply the controller (10) to each joint (12), we need to assure the closed-loop system be stable. We rewrite (12) with state-space form In regulation case, _ q d i ¼ 0; we define We consider the following Lyapunov candidate function where b i ; k p >0: From (23) We should choose the gain k d such that then the closed-loop system is uniformly bounded, V 1 convergences to � d i : Here a i and b i are obtained from (13) In tracking case _ q d i �0; we use the same definitions as (23), and define an auxiliary variable

Figure 4. Human-in-the-loop control for prosthesis.
The PD control becomes The proposed Lyapunov function is We should choose the gain K such that K> 1 2b then the closed-loop system is uniformly bounded, V 2 convergences to � f : From the Lyapunov analysis, we concluded that the PD can stabilize the system. By the identification of the system, we can obtain good control gains.
So, amputee-prosthesis system is stable under previous consideration.

Stability analysis of PID
As described by (12), the prosthesis can be considered as a 2-DOF robot, subject to a perturbation due to the coupling with the residual limb, described in likewise as a 2-DOF robot subject to the perturbation due to the prosthesis coupling. And more over, each of the joints of the prosthesis can be considered as independent systems perturbed by the interconnections of the other links.
Then, the error dynamics can be described as where the dynamics of the human controller can be written as So the system in closed loop can be described as We extend the idea of Thenozhi and Yu (2014) for the PID with derivative filtering. The equilibrium point for the error dynamics must be at e ¼ 0, _ e ¼ 0 and € e ¼ 0. From (32) Figure 6. Comparison of trajectories in tracking control.
Defining u ¼ u À u s , so the equilibrium point results u ¼ 0. As the error converge, so € � b and _ � q are bounded and considering the perturbation, b, bounded too, we can consider constant the control at the equilibrium, so _ u ¼ 0 at equilibrium. Finally, the equilibrium point is defined at ð0; 0; 0; 0Þ.
In order to analyze the stability of the system, we propose the candidate Lyapunov function with k 1 ¼ α 1 þ 1 and α 2 ¼ α 3 À k 1 . Assuming positive constants, k 1 and k 2 so V>0.

Human-in-the-loop control for active lower limb prosthesis
In order to test the proposed scheme, we define an amputee-prosthesis system.
Here, the human model corresponds to an amputee with a lower residual limb made up of the hip and thigh, and with the ability to control this residual limb according to the desired intention under the influence of the environment. For a complete model, we consider an active transfemoral prosthesis rigidly connected to the stump of the residual limb where humans share control in two ways, 1) by connection of the stump, 2) by extended actions. The complete assemble can be regarded as a model where an active prosthesis includes the dynamics of human system or a human who has attached a prosthesis. See, Figure 3.
For this implementation, we define: (1) Natural signals. The human performs the usual movement (through the residual limb) to reach a desired state when walking. These signals, q 2h ; q 3h and q h4 , are defined as the trajectories followed by the joints during gait based on the work of Winter (2009). In addition, a synthetic signal is considered that is interpreted as the trajectory in the vertical direction of a fixed point on the hip, q 1h , during the walk, and is defined as where f 2 1; 2�hz is the walking frequency and modðt; f Þ is as usual the mathematical modulo function, what obtains the remainder when we divide t over f .
(1) Extended. These signal are obtained by the human control, and, in general, is defined as a function, f of the satisfaction error, e s with q l ¼ ½q 3 ; q 4 �, the state of the prosthesis.
(1) Signal of intention. It corresponds to the state of the prosthesis desired by the human.
The environment is considered as a system that generates a Boolean signal, as a differentiating means of two environmental conditions.
where k is the gain of influence in the system. So assuming interaction with environment and a unitary gain of influence, we have S a ¼ k ¼ 1. There are exogenous systems that humans can interact with. These systems have a behavior that does not depend at all on the existence of the human being in the system. The exogenous system is an autonomous and independent system. The trajectories of exogenous systems will be defined as exogenous behaviors.
Robotic systems, even other humans, are examples of exogenous systems. The environment is an exogenous system that modifies or motivates the generation of signals. That is, human signals are personal, which means that they differ between human and human, since during his life he is immersed in a unique environment, which provides the particularities of the genesis of his signals. Since each system is considered autonomous, there is a controller for each system that defines a certain behavior. Figure 4 shows the proposed scheme of human-in-the-loop control. Here, the human being influenced by the environment interacts with the prosthesis through the stump and extended actions.
The human intention is defined as where q ih are the hip, thigh, knee and ankle.
The environment influence is defined as s a ¼ k. This signal is added to the desired intention to modify the intention under environment interaction. The intention is where q rha and q lha are the desired human hip and thigh. q lha is the desired state of knee and ankle of the prosthesis.
The closed-loop representation with human control is shown in Figure 5.

Experimental results
The experimental results was obtained by simulation. The mechanical environment of the humanmachine system was developed in SimMechanics over Matlab, exporting designed elements previously designed in Catia based on anthropomorphic dimensions for optimal gait. The control system was implemented in Simulink connected to SimMechanics. The integration method used was ode45, with maximum step size of 0:01s.
The implementation of prostheses makes human-machine interaction inevitable. In the first test, we consider the case when the human does not have an intervention beyond the imposition of states to the system.

Open loop HITL control
When the human participates, he does not execute actions additional to the natural ones, and there is not a feedback of the states of the prosthesis influencing its control. We defined it as open loop with the human interaction.
The implementation and simulation of the HITL control are for the knee and the ankle for the prosthesis attached to the human, physically represented by the hip and the thigh as the residual limb such that these provide the more significant information of the desired trajectory for gait. The autonomous control is a PD trajectory tracking control. A comparison of tracking trajectory of the gait pattern obtained by the neuro-decoder is shown in Figure 6 The neural decoders receive the signals from the hip and thigh, and return the trajectory of the knee. They apply out-of-range signal to the decoder to emphasize the need for human participation, the behavior shown in Figure 7. The experiment considered a variation of the range of the signal for which the neural decoder was designed. Instead of having a ½0; 2π� signal, we defined a ½0; 4π� signal, see, Figure 8. The tracking errors are shown in Figure 9. Comparison of the human signal and the signal achieved by autonomous control is presented in Figure 10.
Neural networks provide the robustness of the system. Since the value is outside the design parameters of the network, it is very possible that the trajectory achieved is not the one expected by the amputee. However, we consider that there is no such intervention to observe the behavior of the system. The error increases, because the neuro-decoding system cannot adequately identify the intention, when the parameters are outside the design ranges.

Close-loop HITL control
The system receives intention signal, which is out of range. An environmental signal is included to justify this signal. The human intention signal is taken into account, which is under HITL scheme. The extended human signal is applied to the prosthesis-controller system.
In Figure 11, the result of the intention tracking based on PID model is shown. Due to the difference in the initial conditions, the participation of the human is small. It only seeks to compensate the signal that was added to the reference. In the second cycle, its participation is greater, because the tracking control fails in the decoding. Figure 12 shows the human must influence with greater effort, managing to better track the intention signal but with a lag. This delay comes from human observation to act. It can be solved by adapting an interaction prediction system through intelligent mechanisms.

Human interaction
The human-robot interaction force is defined in this implementation as the extended actions. The energy used to control the prosthesis is observed through the control signal applied by the human as the force need in the shared control in order to achieve the human desired state. Figure 12 shows the human control needed to correct the state of the prosthesis in order to get the correct desired gait.
So, according to the observations, the human model proposed is useful to study the payload when it shares the control in the proposed scheme. And is clearly than the autonomous tracking control is not the best option to interact with human, so it is not so convenient to do a real-human implementation with this scheme using that control. First to do a real implementation, we could use the proposed human model to design and test better autonomous controller in order to prevent dangerous test for human.
It must be notice, that even when the human signal control, human-robot interaction force, looks high, it is not applied with that magnitude, this is because motors have a previous saturation stage, that is, to prevent overload in motors, the control signal passes through a saturator that limits the signal to À 10 to 10V. That means, human perceive, and actually apply, a higher force than applied to joints. This suggests again that it is better to choose another different control than tracking control, according to literature a possible option to improve this behavior is impedance control.

Conclusions
The proposed HITL scheme for prosthesis is useful to study the human correction of errors in autonomous controller dynamics due, for example, to modeling, identification or synchronization errors. As well as the participation of the human for fine adjustments due to disturbances such as environmental ones. In such a way as to guarantee his satisfaction, comfort and safety.
The active lower limb prosthesis has the advantage that the amputee can freely change the desired trajectory and does not depend on the healthy leg, like the eco-control schemes. It does not require a high computational cost treatment like the EMG-based implementation. It does not require a complex sensory system. Only hip reading status is required for mapping.
To improve the model, it is possible to add an adaptive and learning capacity, even psychological. It is still necessary to study stability, and furthermore, an inherently stable model should be considered to make it more suitable to emulate a real human.
In the future, we are going to extend human model in order to incorporate more physical and psychological behavior, and add more DOFs to the motor system, also include hip and thigh as residual limb. This will improve balance of walking process.