Encouraging Volitional Pedaling in Functional Electrical Stimulation-Assisted Cycling Using Barrier Functions

Stationary motorized cycling assisted by functional electrical stimulation (FES) is a popular therapy for people with movement impairments. Maximizing volitional contributions from the rider of the cycle can lead to long-term benefits like increased muscular strength and cardiovascular endurance. This paper develops a combined motor and FES control system that tasks the rider with maintaining their cadence near a target point using their own volition, while assistance or resistance is applied gradually as their cadence approaches the lower or upper boundary, respectively, of a user-defined safe range. Safety-ensuring barrier functions are used to guarantee that the rider’s cadence is constrained to the safe range, while minimal assistance is provided within the range to maximize effort by the rider. FES stimulation is applied before electric motor assistance to further increase power output from the rider. To account for uncertain dynamics, barrier function methods are combined with robust control tools from Lyapunov theory to develop controllers that guarantee safety in the worst-case. Because of the intermittent nature of FES stimulation, the closed-loop system is modeled as a hybrid system to certify that the set of states for which the cadence is in the safe range is asymptotically stable. The performance of the developed control method is demonstrated experimentally on five participants. The barrier function controller constrained the riders’ cadence in a range of 50 ± 5 RPM with an average cadence standard deviation of 1.4 RPM for a protocol where cadence with minimal variance was prioritized and used minimal assistance from the motor (4.1% of trial duration) in a separate protocol where power output from the rider was prioritized.


INTRODUCTION
Stationary cycling assisted by functional electrical stimulation (FES) can lead to long-term benefits for people with movement impairments due to neurological conditions such as stroke, spinal cord injury, traumatic brain injury, cerebral palsy, multiple sclerosis, and others Johnston et al. (2008); Ferrante et al. (2008); Hooker et al. (1992); Janssen et al. (2008); Trevisi et al. (2012). Individuals with neurological conditions can exhibit varying degrees of muscle control. For people with little to no volitional control, the FES cycling therapy must be supported by an electric motor, which provides additional torque about the pedal crank to maintain a beneficial cadence, as in studies such as Cousin et al. (2020); Hooker et al. (1992); Bellman et al. (2017); Duenas et al. (2020); Trevisi et al. (2012). When possible, electric motor support should be minimized in lieu of torque produced by the rider's muscles via either FES or their own volition, which leads to higher intensity training by increasing the rider's heart rate and oxygen uptake Hooker et al. (1992). Higher intensity training is a key factor in attaining long-term outcomes like increased muscular strength, cardiovascular endurance, bone mineral density, and caloric consumption Ouellette et al. (2004); MacKay-Lyons and Makrides (2002); Mohr et al. (1997). In the rehabilitation literature outside of cycling, various assist-as-needed approaches such as Asl et al. (2020); Dao and Yamamoto (2018); Pehlivan et al. (2015); Ding et al. (2014) encourage volitional contributions from the user. Relatively few works have investigated FES-and motor-assisted cycling programs where the primary objective is to encourage volitional contributions Harrington et al. (2012); Rouse et al. (2020); Johnston and Wainwright (2011). The objective of this work is to design controllers for both the electric motor and FES stimulation that facilitate volitional cycling by minimizing machine assistance while ensuring that the rider's cadence is constrained to a userdefined range.
The kinematics of the rider's legs during stationary cycling are such that applying FES to their muscles produces non-negligible torque only in certain regions of the crank cycle. To maximize torque production, stimulation patterns often feature discontinuous jumps triggered as a function of the crank angle by discrete logic variables. The interaction of the resulting continuous-time and discrete dynamics results in a hybrid control system. Barrier functions, or control barrier functions (CBF), can be used to design controllers for hybrid systems that ensure safety by rendering sets of states either forward invariant or asymptotically stable Ames et al. (2019); Maghenem and Sanfelice (2021); Glotfelter et al. (2017). This technique builds on ideas from the theory of control Lyapunov functions (CLF). CLFs are used to enforce particular constraints on the control input that result in a decrease in a Lyapunov function for states outside of the safe set Freeman and Kokotovic (1996); Sanfelice (2013). However, CLF-based approaches have typically not provided constructive methods for designing the control input at states in the safe set. Recent developments regarding CBFs have filled this gap by providing a systematic approach for extending the input constraints onto the safe set in a way that reduces the control effort on the interior of the set Ames et al. (2016). A popular approach for implementing CLF-or CBF-induced input constraints is with pointwise optimal control laws which, for certain classes of dynamics, take the form of quadratic programs (QP). Compared to past assist-as-needed control schemes, which have used methods such as deadzone functions Asl et al. (2020) or impedance control Ding et al. (2014), barrier functions can constrain the state within a broader class of safe sets. Moreover, the cost function in the accompanying pointwise optimal control law is customizable, leading to a range of possible controllers. Our preliminary work in Isaly et al. (2020) integrated zeroing CBFs with robust control tools from Lyapunov theory to synthesize a QP for an uncertain, continuous-time, motor-only cycling system. The controller in Isaly et al. (2020) constrains the rider's cadence within a userdefined range while encouraging volitional pedaling by using minimal motor control effort. However, the more complex case where the rider is also stimulated by FES was not considered.
In this work, we extend the development of Isaly et al. (2020) to account for the hybrid dynamics introduced by adding FES stimulation. The resulting controller applies assistance based on the rider's performance. FES assistance is only applied when the cadence cannot be maintained at a target value through volitional effort alone. Similarly, assistance from the electric motor is applied only when the combined FES and volitional efforts are insufficient. The controller accommodates a broad range of functional impairments and volitional ability by featuring customizable parameters, including nominal control inputs and tunable width of the safe range. Moreover, the rider's safety is assured because the electric motor constrains the rider's cadence to a uniformly globally asymptotically stable set through a continuous feedback controller. The continuity of the motor control law is an improvement upon the breakthrough strategy in Rouse et al. (2020) for encouraging volitional pedaling. In that work, no control effort was applied within a user-defined region, while the electric motor and FES were turned on discontinuously at the boundary of the region. Outside the region, assistive control effort switched discretely between FES and electric motor assistance to ensure that the electric motor did not prevent FES from inducing power output by the rider. In contrast, we decouple the motor and FES controllers and use more sophisticated design tools to develop a motor control law that is a continuous function of the cadence tracking error. The result is more comfortable training for the rider, while the staggered application of FES before motor effort still allows power output from the rider to be prioritized.
Experimental trials were performed on five able-bodied participants to demonstrate the effectiveness and versatility of the developed control system. The barrier function controller was shown to effectively constrain the cadence to a range of 50 ± 5 RPM for all but a negligible amount of time, and to outperform the controller in Rouse et al. (2020) and uncontrolled volitional pedaling for a protocol where minimal cadence variation was prioritized. The barrier function controller had a lower cadence standard deviation (Avg. 1.4 RPM) and constrained the cadence to a smaller range relative to the comparison cases, but generally produced more assistive torque from the motor than the controller in Rouse et al. (2020). To show how motor assistance can be reduced to prioritize power output from the rider, an alternative protocol was designed where the customizable parameters were configured with a wider safe range and a nominal amount of resistance from the motor. In the alternative trial, the motor was producing assistive torque for only 4.1% of the entire trial duration.

Hybrid Systems
The development in this work is based on the hybrid systems framework described in Goebel et al. (2012). A hybrid system H (C, F, D, G) with state x ∈ X ⊂ R n is modeled by When the state is in the flow set C ⊂ R n , it is allowed to evolve continuously according to the set-valued flow map F: R n 6R n . When the state is in the jump set D ⊂ R n , it is allowed to change discretely according to the jump map G: R n 6R n . When x ∈ C ∩ D, either behavior is possible. The notion of a solution to H is defined precisely in Goebel et al. (2012), Def. 2.6. Briefly, a solution to H is a function (t, j)1ϕ(t, j) defined on a hybrid time domain dom ϕ ⊂ R ≥0 × N and is parameterized by the ordinary time variable t ∈ R ≥0 and the discrete jump variable j ∈ N. The set-valued mappings F and G map points in R n to subsets of R n so that, for example, the inclusion x + ∈ G(x) represents the fact that if a trajectory jumps from the state ϕ(t, j), then its state ϕ(t, j + 1) at the next discrete time instant is a point in the set G(ϕ(t, j)).
Remark 1. Previous results (cf. Rouse et al. (2020);Bellman et al. (2017); Rouse et al. (2021)) have analyzed the dynamic model in the subsequent section using switched-systems tools. The decision to use a hybrid model here was motivated by the fact that forward invariance via barrier functions is not well characterized for switched systems, nor are many results available regarding the stability of noncompact sets. Hybrid systems can model broad classes of switched systems Goebel et al. (2012, Section 2.4).

Open-Loop Dynamics
Analogous to Eq. 1, one can also consider hybrid systems with inputs Sanfelice (2013). We use such a system to describe the control design but present our stability analysis in terms of a closed-loop system with the form in Eq. 1. The open-loop cyclerider system is modeled as a continuous-time system H u (C u , F u ). Subsequently, discrete dynamics will be introduced due to the design of the controller. Adapting the model from our previous work in Bellman et al. (2017) and Isaly et al. (2020), the cycle's Euler-Lagrange dynamics are modeled using the flow map and flow set C u bR 2 × U. In (2), the state is z ∈ R 2 , where z 1 denotes the cycle's measurable crank angle, and z 2 is the calculable angular velocity (equivalently, the rider's cadence). The system has control inputs 1 ub(u e , u M ), where u e ∈ R is the current input to the cycle's electric motor, and u M ∈ R 6 is a vector of the electrical stimulation intensity inputs u m ∈ R, for each muscle m ∈ Mb LQ, LG, LH, RQ, RG, RH { } . The elements of M indicate the quadriceps femoris (Q), gluteal (G), and hamstring (H) muscle groups for the left and right legs, respectively. The control inputs take values in the set u] 6 ⊂ R 6 indicates that the muscle control inputs are bounded by the constant u > 0 for the rider's safety and comfort. The continuously differentiable function M: R → R >0 denotes the inertial forces from the cycle and rider's legs. The set-valued mapping τ F : R 2 6R defines the dynamics of the system as where τ b : R → R denotes the unknown torque due to viscous damping in the cycle, and V p : R 2 → R, G: R → R, and P: R 2 → R are the unknown centripetal-Coriolis, gravitational, and passive viscoelastic tissue forces, respectively, applied by the combined human-cycle system. The aforementioned functions are continuous according to the dynamic models in Bellman et al. (2017) and Idsø (2002). According to the model in Bellman et al. (2017), the centripetal-Coriolis term is related to the mass and cadence by V p (z) 1 2 ∇M(z 1 )z 2 . In Eq. 3, T vol ⊂ R and T d ⊂ R are sets used to model all of the possible values of the rider's volitional effort and other unknown disturbances, respectively 2 . The continuous function τ u : R 2 × U → R describes the torque produced by the control inputs and is defined as where c e > 0 is the known electric motor control constant relating input current to output torque. The torque generated from FES inputs to the rider's muscles τ FES : R 2 × U M → R is given by where the continuous functions g m : R 2 → R denote the uncertain control effectiveness of each muscle. For each m ∈ M, let the closed set Q m ⊂ R denote the portion of the crank cycle when a particular muscle m is stimulated, which is selected based on a minimum threshold for the torque transfer ratio of each muscle group. In particular, there exist kinematic deadzones in the crank cycle where no muscle is able to produce useful torque Cousin et al. (2020).
The following properties of the cycle-rider system in Eq. 2 are derived from a detailed dynamic model, as discussed in Bellman et al. (2017). Property 1. The inertial term is upper-and lower-bounded as c I ≤ M(z 1 ) ≤ c I for all z 1 ∈ R, where c I , c I > 0 are known constants.
Property 2. The centripetal-Coriolis parameter is upperbounded as |V p (z)| ≤ c V |z 2 | for all z ∈ R 2 , where c V > 0 is a known constant.
Property 3. The torque generated by gravity is upper-bounded as |G(z 1 )| ≤ c G for all z 1 ∈ R, where c G > 0 is a known constant.
Property 5. The torque due to viscous damping is upperbounded as |τ b (z 2 )| ≤ c b |z 2 | for all z 2 ∈ R, where c b > 0 is a known constant. 1 For vectors x ∈ R n , y ∈ R m , (x, y)b[x T , y T ] T . 2 The addition of a point a ∈ R and a set B ⊂ R is defined as a + Bb a Frontiers in Robotics and AI | www.frontiersin.org November 2021 | Volume 8 | Article 742986 Property 6. The torques generated by system disturbances are bounded so that T d [−c d , c d ], where c d > 0 is a known constant.
Property 7. Due to physical limitations of the rider, the volitional muscle torque is bounded so that T vol [−c vol , c vol ], where c vol > 0 is a known constant.
Property 8. For each m ∈ M, the muscle control effectiveness is upper-bounded so that |g m (z)| ≤ c m for all z ∈ R 2 , where c m > 0 is a known constant.
Property 9. The set-valued mapping F u : R 2 × U6R 2 is outer semicontinuous, locally bounded, and convex-valued. These properties follow from continuity of the defining functions and from Properties 6 and 7.
3 CONTROL DESIGN Figure 1 shows a schematic of the staggered control regions for the developed system. The volitional range is a region near the setpoint z 2d where the control inputs are zero, thereby forcing the rider to pedal on their own volition (optionally, a nominal amount of assistance or resistance can be provided based on the needs of the rider). When the cadence is slower than z 2d , FES assistance is provided before assistance from the electric motor. When the cadence is faster than the setpoint, only the electric motor is used because creating resistive torque with FES by stimulating antagonistic muscles is undesirable. The rider or clinician can modify the amount of control effort provided and the size of the controlled regions using parameters adjusted for the specific individual.

Control Objective
To formalize the control objective, we define the tracking error e as the deviation of the cadence state z 2 from a constant setpoint z 2d > 0, 3 The primary control objective is to guarantee a safe and effective therapy by constraining the rider's cadence to the safe set Sb{z ∈ R 2 : e L ≤ e ≤ e H }, where e L < 0 < e H are user-defined constants. The FES control inputs attempt to constrain the rider's cadence to the secondary set S FES b{z ∈ R 2 : e ≥ e FES }. Because the FES inputs are only intermittently available and must be less than the comfort threshold u, the cadence may not remain within S FES . However, this construction is useful for design purposes. To ensure that FES stimulation is active before torque is added by the electric motor, the design specifies that e L < e FES < 0.
The goal is to synthesize, in a systematic way, controllers that render a given set of states uniformly globally asymptotically stable (UGAS) while using the minimum required effort inside the set of interest. 4 Combining ideas from CLF theory with recent developments regarding CBFs, this task is accomplished by using a QP to enforce a constraint on the control input that is induced by a candidate barrier function. The following lemma, presented in a more generic form than in our preliminary work in Isaly et al. (2020), gives conditions under which a QP-based control law with a single constraint is feasible and locally Lipschitz continuous. The closed-form solution of the QP in the absence of a nominal controller (but including the case of multiple control inputs) has also been presented in Freeman and Kokotovic (1996, Section 4.2.2) and was developed in detail in Xu et al. (2015), Thm. 8. In those works, the feasibility condition was guaranteed by assuming the existence of a CLF or CBF, respectively. Because the addition of a nominal controller is a minor extension of the available literature, we do not present a proof of the result. Lemma 1 applies to the control laws developed in the subsequent sections.
Lemma 1. Let the functions a: R n → R, b: R n → R, and u nom : R n → R be locally Lipschitz on R n and satisfy the following feasibility condition: Then the set-valued mapping is locally Lipschitz on R n , and, for any point z p such that a(z p ) 0, there exists a neighborhood N (z p ) such that u * (z) u nom (z) for all z ∈ N (z * ). Furthermore, the controller in Eq. 7 has a closed-form solution given by FIGURE 1 | Illustration of the regions of applied control effort as a function of cadence. No control effort is applied in the volitional range near the setpoint z 2d . The electric motor control input increases when the cadence approaches the boundaries defined by e H and e L , and the FES control signal does the same near e FES . The size of each region is adjustable. The cadence range between e H and e L is rendered asymptotically stable by the developed control system.
Note that there is no division by zero in Eq. 8 since Eq. 6 implies that u * (z) u nom (z) when a(z) 0. Also note that the claim regarding the neighborhood about points for which a(z * ) 0 does not hold in general if the inequality in Eq. 6 is changed to b(z) ≤ 0.

Motor Control Design
In this section, the electric motor control input is designed to ensure that the safe set S {z ∈ R 2 : e L ≤ e ≤ e H } is UGAS for a given z 2d > 0. Our development is based on the design procedure described in Isaly et al. (2020) and the theoretical results for hybrid systems in Maghenem and Sanfelice (2021) and Goebel et al. (2012), where Maghenem and Sanfelice (2021) considers barrier functions specifically. The safe set S is encoded by the barrier function candidate B e : R 2 → R defined as Equivalent to the original definition, we have S {z ∈ R 2 : B e (z) ≤ 0}. The barrier function is designed to be continuously differentiable while encoding the potentially asymmetric (about e 0) boundary of the set S.
While barrier functions are typically associated with forward invariance, they are naturally extensible to enforcing the stronger property of asymptotic stability. Asymptotic stability is beneficial for real-world applications since it guarantees robustness to perturbations from the safe set. For continuous-time systems, the stronger asymptotic stability condition is embodied in the definition of a zeroing CBF (ZCBF) Xu et al. (2015). Inspired by the ZCBF approach in our preliminary work in Isaly et al. (2020) and the work regarding CLFs for hybrid systems in Sanfelice (2013), we constrain the control input according to the so-called regulation mapŨ: R 2 6U defined as and k b1 > 0 is a control gain. In the stability analysis of Section 4, we show that selecting a continuous controller fromŨ ensures that B e acts as a Lyapunov function for the closed-loop dynamics outside the set S. In particular, the condition in Eq. 10 will be used to apply Proposition 3.27 of Goebel et al. (2012) to conclude that S, redefined to include some additional states, is UGAS. Remark 2. The definition of a ZCBF requires that c e (z)bα(B e (z)) for an extended class K function a Xu et al. (2015). However, requiring dependence of γ e on the barrier function candidate can be restrictive, and is not necessary to obtain theoretical guarantees. Because the value of the function M in B e is unknown and cannot be implemented in a control law, we use γ e instead of the typical ZCBF-based selection when definingŨ in Eq. 10. For both ZCBFs and the choice of γ e in Eq. 11, the mapping in Eq. 10 enforces asymptotically stabilizing conditions on the barrier function at states outside the safe set.
The regulation map in Eq. 10 is not directly useful for design purposes because uncertainty in the dynamics prevents computation of the inequality (i.e., constraint) used to defineŨ. In the rest of this section, we develop a new regulation map based on a computable constraint that is implementable in a QP like Eq. 7. The resulting QP-based controller is a locally Lipschitz selection ofŨ. To compensate for the uncertainty introduced in Eq. 10 by F u , we employ Lyapunov-based robust control techniques to develop a worstcase upper bound of the inner product in Eq. 10. For any (z, u) ∈ C u and f ∈ F u (z, u), The product Using Properties 2-7, it can then be shown that the unknown terms in Eq. 12 are upper bounded, for some constants c 1 − c 3 , as for each (z, u) ∈ C u and each f ∈ F u (z, u), where C e (e)bc 1 + c 2 |e| + c 3 e 2 .
In Eq. 13, the function τ u depends on the motor control input u e and the muscle control inputs u M . Because the value of the subsequently designed muscle control input will jump at discrete instances, it is desirable to decouple the motor input from the muscle input to ensure the continuity of the motor controller. A continuous motor controller will be more predictable and comfortable for the rider. Using Property 8, there exists a constant c M > 0 such that for all z ∈ R 2 , u e ∈ R, and u M ∈ U M . Using the definition of U M in Section 2, Eq. 14 applies to any muscle controller for which the inputs are bounded by the positive constant u. One can then define Selecting 5 5 While the gain conditions in Eq. 16 will be needed to guarantee that the cadence is constrained to the set S, uniform global asymptotic stability ensures that the cadence remains nearby S even if the conditions do not hold (see Section 5.4).
Frontiers in Robotics and AI | www.frontiersin.org November 2021 | Volume 8 | Article 742986 5 implies that for all z ∈ R 2 , u e ∈ R, and u M ∈ U M . Since Eq. 17 is an upper bound for Eq. 13, we define a new regulation map U e : R6R as U e (e)b u e ∈ R: K e (e) + c e β(e) eu e ≤ − c e (e) .
The following result summarizes the preceding development and explains the utility of U e . Proposition 1. Assume k 1 , k 2 , and k 3 satisfy the gain conditions in Eq. 16 and z 2d > 0. Then, for any z ∈ R 2 and u M ∈ U M , if u e ∈ U e (e), it follows that (u e , u M ) ∈Ũ(z). The constraint used to define U e in Eq. 18 can be written in the generic form of Lemma 1. Additionally, since the terms in Eq. 18 are no longer uncertain, the constraint can be enforced with the following implementable QP: where u nom e : R → R is any locally Lipschitz nominal controller. According to Lemma 1, with b(z) K e (e) + c e (e), the controller is feasible if e 0 implies that Since the parameters in Eq. 20 are user-selected, they can be designed to ensure the inequality holds. Given this gain condition, the controller has the properties described in Lemma 1, in particular, it is continuous. The closed-form solution to Eq. 19 can be developed from Eq. 8. The controller is implementable in either form but the closed-form solution is computationally faster and does not require an optimization package. Note that the piecewise linear function e 1(c e /β(e))e is locally Lipschitz, from which we derive local Lipschitz continuity of the controller.
Remark 3. During the experiments in Section 5, we investigated constant nominal controllers u nom e bu 0 for some u 0 ∈ R. When u 0 0, the controller is a minimum norm controller and the motor is off whenever possible while still ensuring safety. When the rider requires additional assistance, selecting a positive u 0 leads to the motor being biased to assist, while a negative u 0 leads to additional resistance and a more challenging training program. However, there is no theoretical obstacle to using a more complex nominal controller (e.g., one that tracks power).

Functional Electrical Stimulation Design
To describe the FES control input, we define a concatenated state vector xb(z, σ M , τ) ∈ X , where σ M ∈ 0, 1 { } 6 is a vector of switching signals σ m ∈ 0, 1 { } defined for each muscle m ∈ M, τ ∈ R is a timer variable, and X bR 2 × 0, 1 { } 6 × R is the state space. The stimulation input to the rider's muscle groups u p M : X → R 6 is defined for each muscle as 6 u p where u p FES : R → R will be defined subsequently. The switching signals are updated at jumps according to the rule where Q m was defined in Section 2. The update rule specifies that the rider's muscles are stimulated in regions where they are able to produce positive torque. The rule for σ m and the timer variable τ will be used to define a hybrid system in Section 4. As discussed in Section 3.1, it is generally not possible to maintain the cadence in the set S FES {z ∈ R 2 : e ≥ e FES } because the stimulation input u p m is limited in magnitude and only intermittently available. The function u p FES in Eq. 21 represents a selection of the input that would render the set S FES asymptotically stable in the absence of these obstacles (and subject to some gain conditions). The development of u p FES is very similar to the one in Section 3.2 and is therefore omitted to avoid redundancy. Moreover, we do not make claims in the forthcoming stability analysis regarding S FES . The FES input is defined by the following QP: where u nom FES : R → R is any locally Lipschitz nominal controller, K FES (e)bk 4 + k 5 |e| + k 6 e 2 , c FES (e)bk b2 e 2 β 2 (e) − 1 , and β 2 (e)b e 2 FES e ≤ 0 e 2 H e > 0.
When e 0, the feasibility condition (6) in Lemma 1 requires that under which the function u p FES has the properties described in the lemma. Similar to the previous section, the parameters in Eq. 24 are user-selected and can be designed to ensure the inequality holds.
When the nominal controller in Eq. 23 is set to u nom FES b0, then from the closed-form solution in Eq. 8 it can be determined that u p FES (e) ≤ 0 for all e ≥ 0. In this case, because of the use of the saturation function in Eq. 21, it follows that u * m (x) 0 for all x ∈ X such that e ≥ 0. The inclusion of a nominal controller in the 6 The positive saturation function sat + u : R → R is defined as sat + u], and sat + Frontiers in Robotics and AI | www.frontiersin.org November 2021 | Volume 8 | Article 742986 6 QP defining u * FES gives the operator flexibility to provide stimulation at points where e ≥ 0. When using a nominal controller with u nom FES (e) > 0 for e ≥ 0, FES stimulation produces torque to increase the cadence above the setpoint z 2d . However, it is always the case that u * FES (e) → 0 as e → e H . By combining nominal assistance from FES with nominal resistance from the electric motor, a more intense training program can be designed where the rider must work against resistive torque from the electric motor to stay near the setpoint. We provide experimental results for a higher intensity configuration of the control system in Section 5.

STABILITY ANALYSIS
We model the closed-loop system as a hybrid system H (C, F, D, G) with state x (z, σ M , τ) ∈ X , where the state space X was defined in Section 3.3. The hybrid system will periodically update the muscle switching signals σ m according to the rule in Eq. 22. The timer variable τ increases at a constant rate until reaching a dwell-time τ D > 0, at which point a jump occurs and each signal in σ M is updated. Governing jumps by a dwell-time prevents multiple jumps from occurring in the same time instant, and models a computational implementation of the switching signals, where the values of the logic variables would be updated periodically at a fixed sampling frequency. In practice, the dwell-time τ D will be the sampling frequency.
The hybrid system H is defined as follows. The flow map F: X 6X is where u p (x)b(u p e (e), u p M (x)) and F u is defined in Eq. 2. The flow set is Jumps occur when the timer state τ grows to τ D , The jump map G: X 6X is defined component-wise as G(x)b(z, G σ (x), 0), where the state z does not change at jumps (z + z), the timer τ resets to zero at jumps (τ + 0), and G σ : X 6 0, 1 { } 6 is the outer semicontinuous Krasovskii regularization of the map in Eq. 22 Goebel et al. (2012), Def. 4.13. For each m ∈ M, the corresponding component of G σ is equal to The set-valued case in Eq. 25 indicates that if τ reaches τ D when the state z 1 is precisely on the boundary of Q m , the signal σ m may or may not jump. Performing such a regularization leads to some robustness properties due to the fact that H is a well-posed hybrid system Goebel et al. (2012, Ch. 6).
Remark 4. The gain conditions in Eqs. 20, 24 must be satisfied because they lead to the feasibility of the QP-based controllers. The conditions are restated here for emphasis: Theorem 1. Consider the closed-loop cycle-rider system H. Assume the control gains satisfy the conditions in Eqs. 16, 20, 24, and z 2d > 0. Then the safe setSb x ∈ C ∪ D: e L ≤ e ≤ e H { } is UGAS for H. Additionally, H is a well-posed hybrid system.
Proof. Since B e in Eq. 9 is such that S x ∈ C ∪ D: B e (z) ≤ 0 { } , the function B e is a valid barrier function candidate Maghenem and Sanfelice (2021), Def. 3. Using Lemma 1, the gain conditions in Eqs. 20, 24 guarantee that the controllers in Eqs. 19, 21, respectively, are feasible. By design, u * e (e) ∈ U e (e) for all e ∈ R and u * m (x) ∈ U M for all x ∈ X . Proposition 1 then shows that u * (x) ∈Ũ(z) for all x ∈ X . It follows from the definition ofŨ in Eq. 10 that for all x ∈ C and each f ∈ F(x). Moreover, the jump map is such that for all x ∈ D and each (z + , σ + M , τ + ) ∈ G(x). The barrier function does not decrease at jumps, but there is sufficient flow time to guarantee an overall decrease along solutions. More specifically, the dwell-time τ D ensures that for any solution ϕ to H, if (t, j) ∈ dom ϕ, then t ≥ τ D (j − 1). Thus, for any T ≥ 0 and (t, j) ∈ dom ϕ, if t + j ≥ T then t ≥ (τ D /(1 + τ D ))(T − 1). We use this bound on the flow time to apply Proposition 3.27 of Goebel et al. (2012).
The conditions in Eqs. 26, 27, and the fact that G(x) ⊂ C ∪ D for all x ∈ D allow us to apply Theorem 1 of Maghenem and Sanfelice (2021) to conclude that the setS is forward preinvariant for H. Furthermore, the barrier function B e is a Lyapunov function for the restricted hybrid system H r (C r , F, D r , G) with C r bC ∩ I and D r bD ∩ I, where I b x ∈ X : B e (z) ≥ 0 { } , which is the restriction of H to the zero superlevel set of B e . It can be shown that there exists 7 a continuous, positive definite function ρ: R ≥0 → R ≥0 such that ρ(|x|S) ≤ c e (e) for all x ∈ C r . Using Property 1, there are class K ∞ functions 8 α 1 and α 2 such that α 1 (|x|S) ≤ B(z) ≤ α 2 (|x|S) for all x ∈ C r ∪ D r ∪ G(D r ). Thus, Proposition 3.27 of Goebel et al. (2012) can be applied to conclude thatS is uniformly globally pre-asymptotically stable (UGpAS) for H r Goebel et al. (2012), Def. 3.6. ThatS is UGpAS for the unrestricted system H follows from forward pre-invariance ofS for H, since for any solution ϕ to H, if ϕ(t, j) ∈S then |ϕ(t ′ , j ′ )|S 0 for all (t ′ , j ′ ) ∈ dom ϕ with t′ ≥ t, j′ ≥ j. Therefore, solutions to H r that terminate on the boundary ofS can be extended as solutions to H that remain inS.
To conclude thatS is UGAS 9 , it remains to show that each maximal solution to H is complete. Towards this end, we invoke Proposition 6.10 of Goebel et al. (2012). We first note that the dynamics satisfy the hybrid basic conditions Goebel et al. (2012), Asm. 6.5 because C and D are closed; G is outer semicontinuous and locally bounded; and F is outer semicontinuous, locally bounded, and convex-valued by Property 9 and Lemma 3.2 in Sanfelice (2013). It follows that H is a well-posed hybrid system Goebel et al. (2012), Thm. 6.30. Next, every point x ∈ zC\D has the component τ 0. The fact that _ τ 1 implies that F(x) ∩ T C (x) ≠ ∅ at any x ∈ zC\D, where T C (x) is the tangent cone to C at x. It is then straightforward to conclude that the condition (VC) in Proposition 6.10 holds for all x ∈ C\D. Moreover, G(D) ⊂ C ∪ D. Thus, Proposition 6.10 shows that a maximal solution is either complete or escapes in finite time by flowing.
To eliminate the possibility that maximal solutions escape in finite time by flowing, we first let ϕ be a solution to H. From the definition of UGpAS in Definition 3.6 of Goebel et al. (2012), the distance of ϕ fromS is bounded. From the definition ofS, the component of ϕ corresponding to the state e is bounded. Using this information, we conclude from continuity of e 1 u * e (e) and the use of the saturation function in the definition of u * M in Eq. 21 that for the concatenated controller u*, the set u * (rge ϕ) is bounded, where rge ϕb{ϕ(t, j): (t, j) ∈ dom ϕ}. Then, from boundedness of the e component of ϕ and Properties 2-7, it can be shown that the set F(rge ϕ) is bounded. It follows that solutions do not terminate in finite time by flowing (cf. Kamalapurkar et al. (2020)). Thus, each maximal solution to H is complete, andS is UGAS for H. ■

EXPERIMENTAL RESULTS
The developed barrier function controller was tested on five participants and compared against uncontrolled volitional pedaling and the 3-Mode (3M) controller developed in Rouse et al. (2020), Section 3. As described in Section 1, the main idea behind the 3M controller is to create a region near the setpoint z 2d where no assistance is provided, with discontinuous control effort being applied on the boundary of the region. In contrast to the barrier function controller, the electric motor controller for the 3M controller is coupled with FES stimulation via the angular position state z 1 , so that the motor is inactive whenever FES is active, and vice versa.
The barrier function controller can be configured for various purposes based on the needs of the rider. Generally, there is a trade-off where smaller user-defined cadence ranges lead to greater applied control effort. Protocol A was designed to investigate whether the controller can reduce the variance in the rider's cadence by constraining their cadence within a small range. Such a trial provides a point of comparison with the 3M controller and uncontrolled volitional pedaling and generates data where the controller is more active. Protocol B was designed to show how assistance from the motor can be reduced by selecting a wider safe range, thereby encouraging more volitional contributions from the rider. In fact, Protocol B featured a nominal amount of resistance from the motor, making the program more challenging and requiring additional power output from the rider.
Due to COVID-19 related difficulties in scheduling participants with neurological conditions, the trials for this demonstration were done with able-bodied subjects. Each participant gave written informed consent approved by the University of Florida Institutional Review Board (IRB201600881). Participants 1-3 were male, participants 4 and 5 were female, and all ranged in age from 21-29 years old.

Testbed
The experimental testbed consisted of a stationary recumbent tricycle (TerraTrike Rover) with a 250 W, 24 V motor (Unite Motor Co.) coupled to the drive chain as described in Bellman et al. (2017), Section 5.1. To measure position and cadence, an optical encoder with an angular resolution of 20,000 pulses per revolution (US Digital H1) was mounted to the crank using spur gears. The motor was actuated using an Advanced Motion Controls 10 motor driver and current-controlled power supply. Stimulation was delivered to the rider's quadricep, hamstring, and gluteal muscle groups via self-adhesive electrodes provided compliments of Axelgaard Manufacturing Co., Ltd. A currentcontrolled stimulator (Hasomed Rehastim) delivered symmetric, rectangular, and bi-phasic pulses at fixed amplitude (90 mA, 80 mA, and 70 mA for the quadriceps, hamstrings, and gluteals, respectively) and frequency (60 Hz), while the pulse width was used as the control input. A desktop computer running real-time control software (QUARC integrated with Simulink) was used to interface the controllers and hardware through a data acquisition board (Quanser QPIDe) with a sampling rate of 1,000 Hz. For additional safety, an emergency stop switch was mounted on the cycle to allow the participant to end the experiment if required.

Procedure
The primary testing procedure (Protocol A) consisted of 180-s tests for each of the three configurations (barrier function, 3M, and volition-only) under consideration. The volitional pedaling trial was always first, followed by a random selection of either the barrier function or 3M controller. The riders were asked to track a setpoint of z 2d 50 RPM. The safe set boundary for the barrier function controller was encoded by e L − 5 RPM and e H 5 RPM, while e FES − 3 RPM. The inactive region for the 3M controller was 48-52 RPM, which is comparable to the range 50-55 RPM that was used for the experiments in Rouse et al. 9 A set A is UGAS for a hybrid system H if it is UGpAS and every maximal solution to the system is complete, meaning the solution is defined on an unbounded hybrid time domain. 10 Advanced Motion Controls supported the development of the testbed by providing discounts on their branded items.
Frontiers in Robotics and AI | www.frontiersin.org November 2021 | Volume 8 | Article 742986 8 (2020). The rider was shown a live plot of their cadence featuring a visible indication of the setpoint. Due to differences between the barrier function and 3M controllers, participants were not shown the boundaries of the safe set 11 .
The 180 s tests started with a 20 s ramp-up phase where the rider sat passively while the motor brought their cadence to the setpoint. To ensure that the presented data represented steady-state operation, the ramp-up and an additional 20 s after it was excluded from each dataset in post-processing. For each configuration, there was a separate warm-up run before the recorded session so the rider could become accustomed to the controller.
Measurements of the position of the rider's legs with respect to the cycle were used to determine the regions of effective torque transfer Q m for each muscle (see Bellman et al. (2017), Section 5.2) for more details). The cycle was initially operated at 50 RPM and open-loop stimulation was applied to one muscle group at a time to determine the comfort limit u for each muscle. The FES inputs are scaled by the comfort threshold in addition to being saturated 12 . The nominal controllers were u nom e u nom FES 0. The control gains were adjusted by plotting the control inputs as a function of the cadence error, which produced a visualization of the regions of applied control effort. Small adjustments to the gains were made for each participant based on their preferences during the warm-up run, which is a cause for variation in the data between participants. Some detailed discussion about the effect of the barrier function controller gains on performance is provided in Isaly et al. (2020) (see Remark 1 and Section 5.4).
Additional trials were conducted to highlight unique aspects of the barrier function controller, which were performed with only one participant. Protocol B was designed to prioritize power output from the rider over cadence tracking. For this alternative trial, the width of the safe range was larger, with e L − 12 RPM, e H 10 RPM, and e FES − 6 RPM. Because the rider (Participant #2) was able-bodied, we chose to make the program more challenging by adding nominal controllers with u nom e < 0 and u nom FES > 0, which means that near the setpoint the electric motor produced resistive torque while FES provided assistance. The boundaries e L and e H were displayed on-screen for this trial. In Protocol C, Participant #1 was asked to provide no volitional effort for both the 3M and barrier function controllers (Figure 4). Because of problems with the 3M controller for this trial, we did not proceed with testing the no-volition configuration on other participants. Table 1 shows relevant statistics for the three configurations tested for Protocol A, including the average and standard deviation of the cadence, percentage of the trial duration for which FES was actively stimulating, and time spent outside of the safe set S. Two integrals of the electric motor input are given to distinguish resistive torque, for which the rider must pedal harder to compensate, and assistive torque, which implies work done by the motor and not the rider. The barrier function controller produced the lowest standard deviation in cadence for each participant and led to greater FES usage, but generally used more assistive torque from the motor than the 3M controller. The 3M controller produced less assistive torque because the electric motor was off in regions of the crank cycle where FES was active. The discrete switching between motor and FES, along with switching on the boundary of the inactive zone, caused numerous discontinuities in the 3M motor controller; Table 1 shows an average of 493 switches per trial. For all participants, the riders' cadence took values in the range 40.7-56.1 RPM for the 3M controller, 45.4-55.3 RPM for the barrier function controller, and 40.5-59.2 RPM for uncontrolled pedaling. The barrier function controller constrained each rider's cadence to the user-defined range of 45-55 RPM for all but a negligible amount of time; an average of six sampled data points or approximately 0.004% of the trial duration. Segments of the trials for three randomly selected participants are shown in Figure 2. A zoomed view featuring the FES stimulation input for a single participant is shown in Figure 3. Figure 4 shows the trials using Protocol C, where Participant #1 provided no volitional effort. The barrier function controller was still able to keep the rider's cadence within the safe set, while the 3M controller caused large oscillations; the mean ± SD cadence for the 3M controller was 43.74 ± 4.94 RPM. The cadence dropped as low as 31.54 RPM during the 3M trial because the electric motor was inactive in the shaded regions of Figure 4. When the motor was next switched on, it compensated using control action with a maximum magnitude of 17.74 A, which was relatively large compared to a maximum of 8.13 A for the 3M controller during the Protocol A trials.

Results
The results for Protocol B, where there were nonzero nominal controllers and a wider safe range, are displayed in Figure 5 and Table 2. There was high utilization of the electric motor to produce resistive torque, but low assistive torque production. The assistive torque was smaller than the Protocol A average and, in particular, was smaller than Participant #2's results. The resistive torque was large and FES was more active for Protocol B due to the design of the nominal controllers. The electric motor deviated from its nominal value for only 7.7% of the trial duration and was providing assistance for 4.1% of the trial. The cadence standard deviation was higher than uncontrolled volitional pedaling, which was most likely because the control inputs were actively pushing the rider away from the setpoint. The assistive torque from the barrier function controller in Protocol B was comparable to the 3M controller in the Protocol A trials.

Discussion
The results for Protocol A demonstrate that the barrier function controller can assist a rider in tracking the cadence setpoint while constraining their cadence within a user-defined range. Figure 3 shows that the control inputs ramp up before the cadence reaches the boundaries defined by e H , e L , and e FES , yet are inactive when the cadence is near the setpoint. Such a ramp-up is demonstrative of how barrier function methods can ensure a gradual transition from a nominal controller, which should be active on the interior of the safe set, to an invariance-ensuring controller on the boundary of the safe set. For Protocol A, the width of the nominal control range was fairly small, while the width was increased for Protocol B.
In some situations, increasing the training intensity for the rider will be preferred over improved cadence tracking. The relevant statistics are the assistive and resistive torques produced by the electric motor. Higher assistive torque indicates that less power is being produced by the rider. The barrier function controller is versatile and can be tuned to provide more or less interference from the control inputs. Figure 5 shows a trial using Protocol B where power output from the rider was prioritized by allowing larger cadence errors. The system's operator can allow larger cadence errors by selecting a wider safe range, which also facilitates the design of a wider nominal control range. The use of nominal controllers for Protocol B intensified the training by providing more FES stimulation and resistance from the motor. The control inputs were at their nominal values for a significant portion of the experiment, validating that a wider safe range leads to less modification of the nominal inputs. The nominal inputs can alternatively be designed so there is less resistance from the motor or less control input overall. The fact that the assistive torque from the barrier function controller was comparable to the 3M controller suggests that staggering FES assistance before motor assistance, as in the barrier function controller, is a viable alternative to discrete switching between FES and motor control, as in the 3M controller.
A continuous motor controller is more comfortable for the rider. Continuity is the primary difference between the barrier function and 3M controller. The 3M controller is discontinuous whenever the cadence crosses the boundary of the inactive zone, or the angular position crosses the boundary of the FES stimulation regions Q m . The resulting large number of switches for the 3M motor controller is quantified in Table 1. A particular advantage of the motor being active in the Q m regions is that the barrier function controller is effective even when the rider produces little or no volitional effort, as shown in the trials using Protocol C (Figure 4). The 3M controller caused large oscillations in the rider's cadence during Protocol C due to the discrete switching between FES and motor control. Since FES cannot always produce enough torque on its own, the cadence dropped in the FES stimulation regions, which was then met with large control effort from the motor upon exiting the region. FIGURE 2 | Cadence and motor control input for 30-s segments of the trials using Protocol A. Random selection was used to choose which participants and time periods were plotted. The time axis is offset to zero for readability. The dashed orange line in the barrier function cadence plot indicates the boundary of the safe set S, which was not meaningful for the other two configurations.
Frontiers in Robotics and AI | www.frontiersin.org November 2021 | Volume 8 | Article 742986 FIGURE 3 | Zoomed view of a 5-s time period during a trial using Protocol A showing the cadence, motor control input, and stimulation pulse-width (PW) for Participant 5. Random selection was used to choose which participant and time period were plotted. The time axis is offset to zero for readability. A pulse-width feedforward term of 10 μs was used to facilitate stimulation. The stimulation does not significantly affect the participant at or below 10 μs.
FIGURE 4 | Cadence from a trial using Protocol C, where Participant #1 was asked to provide no volitional effort. The 3M controller was problematic in this scenario due to switching between FES and motor control. The shaded red regions in the 3-Mode plot correspond to times when the electric motor was switched off.
Frontiers in Robotics and AI | www.frontiersin.org November 2021 | Volume 8 | Article 742986 There were some small deviations from the safe set because the asymptotic stability of S is contingent on the selection of control gains, which must be large enough to compensate for the rider's volitional effort and other dynamic effects. In practice, designing the gains to account for large volitional contributions from the rider leads to overly constraining the rider during normal operation. Designing controllers for asymptotic stability, rather than the weaker property of forward invariance, helps mitigate these effects. A property known as input-to-state stability, which is a consequence of the UGAS result in Theorem 1, can be interpreted as guaranteeing that some nearby set is asymptotically stable despite unaccounted-for disturbances of bounded magnitude Xu et al. (2015); Cai and Teel (2009). Thus, the control gains can be relaxed to favor comfortable and effective therapy while still ensuring that the cadence remains nearby the safe set.

CONCLUSION
This paper developed new FES and motor controllers that encourage the rider of a stationary cycle to provide volitional effort while constraining their cadence within a user-defined range. Using theoretical advances for barrier functions, the controllers are minimally invasive while transitioning gradually to a safety-ensuring controller on the boundary of the safe set. The control inputs are selected from regulation maps with sufficient regularity to ensure that optimal selections are locally Lipschitz functions of the cadence error. Robust control tools were used to develop the regulation maps, which are subsets of an original, uncertain map. The uniform global asymptotic stability of the user-defined safe set was certified with a hybrid system analysis. In the future, the performance of the controller can be improved by extending the development to a more complete dynamic model which accounts for muscle activation effects such as electromechanical delay in the rider's muscles.
Experimental results showed that the control system improved the rider's cadence tracking and effectively constrained their cadence within the safe set. The versatility of the controller was demonstrated with trials featuring two different objectives: improved cadence tracking or more power output from the rider. A significant next step is to perform more rigorous experiments on a set of participants with neurological conditions. These riders have a reduced ability to provide volitional contributions, so the results are expected to be significantly different from those of able-bodied riders, and would be of interest in more clinically focused literature.

DATA AVAILABILITY STATEMENT
The raw data supporting the conclusions of this article will be made available by the authors, without undue reservation.

ETHICS STATEMENT
The studies involving human participants were reviewed and approved by University of Florida Institutional Review Board (IRB201600881). The patients/participants provided their written informed consent to participate in this study.

AUTHOR CONTRIBUTIONS
AI designed the controller and experiment, wrote the manuscript, and processed experimental results. BA provided multiple reviews of the manuscript and conducted the experiments. WD and RS provided technical guidance and edited the article. All authors contributed to manuscript revision, read, and approved the submitted version.

FUNDING
This research is supported in part by AFOSR award no. FA9550-19-1-0169, award no. FA9550-19-1-0053, and award no. FA9550-20-1-FIGURE 5 | Segment of a trial using Protocol B, where alternative parameters for the barrier function controller were used. The safe set was much wider for this run, leading to less deviation of control inputs from the nominal value. Nonzero nominal inputs were used to intensify the training. The data was collected with Participant #2.