{'fraction_non_alphanumeric': 0.041506122916110326, 'fraction_numerical': 0.01167359707015603, 'mean_word_length': 4.529213246150601, 'pattern_counts': {'":': 0, '<': 2, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Sliding on Manifolds: Geometric Attitude Control with Quaternions

This work proposes a quaternion-based sliding variable that describes exponentially convergent error dynamics for any forward complete desired attitude trajectory. The proposed sliding variable directly operates on the non-Euclidean space formed by quaternions and explicitly handles the double covering property to enable global attitude tracking when used in feedback. In-depth analysis of the sliding variable is provided and compared to others in the literature. Several feedback controllers including nonlinear PD, robust, and adaptive sliding control are then derived. Simulation results of a rigid body with uncertain dynamics demonstrate the effectiveness and superiority of the approach.


I. INTRODUCTION
Attitude control is a fundamental problem in robotics and aerospace that has a rich history of research. Several controllers have been proposed that vary in complexity, robustness, and tracking performance. However, many lack strong performance guarantees in diverse flight conditions -a facet that is becoming more critical as aerial and space robots find more real-world uses. Orientation dynamics evolve in a non-Euclidean space which poses challenges for synthesizing attitude controllers since all analysis must be done on the appropriate state space manifold. One natural manifold is that formed by the special orthogonal group SO(3) whose elements are all the orthogonal matrices with determinant 1. Several SO(3) controllers have been proposed in the literature, most notably [1]- [4], but, as shown in [5], control on SO(3) can at best achieve almost global stability, i.e., only trajectories in an open set converge to an equilibrium. Further, the complexity of working in SO(3) can make performance and robustness analysis difficult. This work will show that global closed-loop stability is possible by carefully defining quaternion-based feedback terms that capture the underling topology of their non-Euclidean state space.
An effective method to derive nonlinear controllers is through the use of so-called sliding variables. Sliding variables often simplify closed-loop stability and tracking analysis by forming a hierarchy of simple reduced order systems [6]. Once a sliding variable is chosen, several robust and adaptive nonlinear controllers can be immediately employed (see [6]). However, defining a sliding variable can be difficult when a state space is non-Euclidean. This is especially true for SO(3) as the error dynamics of rotation matrices are difficult to analyze and stability is limited to at best almost global. The aforementioned challenges can be circumvented by instead using quaternions, which live on the three-sphere (b) Method from [12]. (c) Method from [14]. S 3 , to represent orientations. Several works have synthesized attitude controllers using quaternions [7]- [11], and some have proposed quaternion-based sliding variables [12]- [16]. However, works that use sliding variables either 1) treat quaternions as if they evolve in Euclidean space and ignore the topology of S 3 or 2) do not address the double covering property where the so-called unwinding phenomenon [8] can lead to longer-than-necessary attitude maneuvers. The main contribution of this work is a quaternion-based sliding variable that represents exponentially convergent error dynamics. Exponential convergence is achieved despite explicitly capturing the geometry of the S 3 manifold. The unwinding behavior is eliminated by introducing a benign discontinuity in the sliding variable that maintains control input continuity when used in feedback. Additionally, the discontinuity results in global convergence when the sliding variable is used in feedback. When compared to other methods the proposed approach has faster convergence without unwinding and is easier to analyze. Moreover, the global stability results are much stronger than those obtainable in SO(3). Three controllers with strong performance guarantees (nonlinear PD, robust, and adaptive sliding control) are derived using the proposed sliding variable. The developed method stems from previous work on provably-safe UAV collision avoidance [17] where high-performance attitude control was necessary for establishing safety guarantees despite high model uncertainty. This work opens avenues for research in designing trajectories that explicitly consider how a maneuver can exacerbate or reduce the effects of model uncertainty. Simulation results confirm the predicted performance and demonstrate the benefits of the approach.

II. BACKGROUND & PROBLEM FORMULATION
A unit quaternion q is a four vector that lies on the threesphere S 3 and consists of a real and vector part, i.e., q = ( q • , q ). The set of unit quaternions form a Lie group under the multiplication operator ⊗, where given two quaternions p and q the quaternion product is The inverse of quaternion q is the conjugate quaternion q * := ( q • , − q ) which satisfies q ⊗q * = q * ⊗q = (1, 0, 0, 0). In the context of mechanics, quaternions are particularly useful for representing orientation. A rotation about a vector n through angle φ can be compactly expressed as q = (cos( φ /2), sin( φ /2)n). Quaternions double cover the special orthogonal group SO(3) so q and −q represent the same orientation. There are then two potential "shortest paths" that connect any two quaternions (see Fig. 2). The socalled unwinding phenomenon occurs when the longer path (blue curve in Fig. 2) is selected resulting in a longer-thannecessary maneuver. From a practical and theoretical point of view, any quaternion-based algorithm must capture the geometric properties of the Lie group they form. Put simply, quaternions must not be treated as vectors in R 4 . The quaternion attitude dynamics can be expressed aṡ with q and ⊗ are defined as before, angular velocity ω ∈ R 3 , symmetric positive-definite inertia tensor J ∈ S 3 + , control input M b ∈ R 3 , unknown dynamics f : S 3 × R 3 → R 3 , and unknown disturbance d ∈ R 3 .
The goal of this work is to define a sliding variable that represents exponentially convergent error dynamics while capturing the geometry of the Lie group formed by quaternions. By directly considering the topology of S 3 the proposed sliding variable should result in faster tracking error convergence than if they were treated as vectors in Euclidean space. Additionally, global convergence results, rather than almost global, should be achieved if the sliding variable is designed carefully.

A. Overview
Stability analysis and tracking performance evaluation can be simplified through the use of so-called sliding variables. If an appropriate sliding variable can be defined then all analysis can be performed on a simpler reduced-ordered system. For instance, if a hierarchical system is formed by selecting the sliding variable s to describe the desired tracking error dynamics, then the trajectory tracking problem reduces to finding a feedback policy that makes the manifold S := {( q e , ω e ) : s( q e , ω e ) = 0} invariant. In most cases defining a sliding variable is trivial since many systems operate in R n . For systems that lie on a manifold other than R n , such as S 3 Two valid paths (red and blue) connect the actual q and desired quaternion q d . The so-called unwinding phenomenon occurs when a longer path (blue) is taken to reach the desired quaternion q d . or SO (3), it can be difficult to construct a sliding variable with simple exponentially convergent error dynamics. This section will first present a quaternion-based sliding variable that captures the geometry of S 3 with tracking error dynamics that are globally exponentially convergent. The proposed quaternion-based sliding variable is then compared to a few common S 3 × R 3 and SO(3) × R 3 alternatives.

B. Sliding Variables in S 3 × R 3
Consider the error quaternion q e := q * d ⊗ q where q * d is the conjugate of the desired quaternion and q is the current quaternion. The error quaternion has dynamicṡ Let the sliding variable s be defined as with ω e := ω − ω d , λ > 0, and Note that all operations in (3) are element-wise. The function sgn + in (4) is different than its standard definition but is necessary for establishing global exponential convergence. Proposition 1 shows that if the manifold S is made invariant via feedback then the the error quaternion q e converges to the identity quaternion exponentially.
s( q e , ω e ) = 0} is invariant. Then, for any trajectory initialized on S, the quaternion error q e converges to the identity quaternion exponentially.
Proof. First assume the manifold S is invariant, i.e., s = 0 for all t ≥ t 0 . Then, from (3), Now consider the candidate Lyapunov function V = q e 2 . Differentiating along the quaternion error dynamics (2), where the third equality is obtained by noting the cross product between q e and ω e produces a vector perpendicular to q e . Since s = 0 by assumption, (5) can be substituted into which shows q e converges exponentially to zero with rate (5) is again utilized. With the definition of sgn + in (4), thenq • e > 0 when q • e = 0 which guarantees that d dt q e 2 = 0 for all t ≥ t 0 only when q e = 0. Hence, q e converges to zero exponentially. Furthermore, the error quaternion q e globally converges to the identity quaternion exponentially.
Proposition 1 shows that global exponential convergence to the identity quaternion occurs with (3) when s = 0 indefinitely. This is a much stronger result than what is obtainable in SO (3). Additionally, since the convergence is exponential, if s = 0 but tends to zero then the error quaternion will tend to the identity quaternion. This property is key to show convergence with adaptive controllers that utilize sliding variables, and will be discussed further in Section IV-D.
The importance of capturing the topology of S 3 in (3) can be understood by analyzing the convergence of the sliding variable proposed in [12]; the key difference being how the quaternion error is defined. First let [·] × be the operator that maps a vector to a skew symmetric matrix, i.e., whereω For the Lyapunov-like function V = q 2 , using (9) leads toV = d dt which showsq → 0 exponentially for q • > 0. While (10) is similar to (7), the convergence behavior is quite different: it takes longer to reach the desired quaternion q d using the sliding variable (8) than with (3). From a differential geometry perspective, this is not surprising since the shortest path between two points in S 3 is known to be a great arc on S 3 . By treating quaternions as vectors in R 4 , the vector difference in (8) inherently leads to slower convergence sincẽ q ∈ S 3 . By properly defining the quaternion error q e in (3), the sliding variable s is guaranteed to remain on the manifold S 3 ×R 3 resulting in faster convergence. Hence, the geometric properties of the state space manifold must be captured when designing sliding variables if the desired performance is to be achieved. Another noteworthy comment on (3) is the definition of sgn + in (4). If the standard function sgn were to be used in (3) in place of (4) then the sliding surface S would have two stable equilibria 1 , mainly (q • e , q e ) = (±1, 0) and (q • e , q e ) = (0, ±1). With the choice of (4), the second equilibrium is made unstable and q e exponential convergences to (±1, 0). Moreover, since q and −q represent the same orientation, exponential convergence is indeed global. While the discontinuity in (3) may seem disconcerting, the sgn + function actually maintains continuity of a control input when s is used in feedback. Furthermore, it ensures the controller selects the shortest path to the desired orientation q d subsequently avoiding the unwinding phenomenon that can be observed with other quaternion-based controllers (such as [14], [18]). This behavior can be deduced by noting if q • e < 0 then the rotation is more the π radians. Taking the conjugate of q e , i.e., negating q e , results in a rotation less than π radians as desired. If, for instance, sgn + is omitted from (3) then (7) becomesV = −2λq • e q e 2 which is unstable for q • e < 0 and unwinding occurs. The above points will be further confirmed with the results presented in Section V.

C. Comparison to Sliding Variables in
The two stated advantages of using the quaternion-based sliding variable (3) are 1) exponential convergence of the error quaternion and 2) the convergence result is global; both of which are straightforward to show. If a sliding variable is instead defined in SO (3), then neither of the previous statements are necessarily true let alone easy to prove. For one, stability analysis with rotation matrices can become fairly difficult. For another, at best only almost global convergence results are possible. This section will briefly discuss a recently proposed SO(3) sliding variable [18], which, despite its simple structure, is quite difficult to analyze until it is represented with quaternions.
First let R ∈ SO(3) which has kinematicsṘ = R[ω] × . If R d is the desired rotation matrix then the error rotation matrix is R e = R d R with kinematicṡ whereω e := ω − R e ω d . Let P(A) := 1 2 A − A be the skew symmetric part of matrix A. Additionally, let (·) ∨ denote the inverse map of [·] × . A candidate SO(3) sliding variable is then For the candidate Lyapunov function V R = trace (3I − R e ) and under the condition s R = 0 indefinitely, one can shoẇ which indicates almost global asymptotic convergence of R e to I. This is a much weaker result than Proposition 1 and would preclude (12) from being used for feedback in adaptive control. However, if one were to convert (13) to a quaternion representation, then almost global exponential stability can be established in a straightforward manner [19].
Of course other SO(3) sliding variables can be defined, e.g., [20], but are not as simple in structure to (12) and are just as complicated -if not more so -to analyze. This not only demonstrates the complexity of defining sliding variables in SO(3) but also how quaternions can simplify analysis and lead to stronger results.

A. Overview
This section shows how the quaternion-based sliding variable presented in Section III can be used by several feedback controllers, including robust and adaptive controllers. The following assumptions are made regarding system (1). Assumption 1. The disturbance d belongs to a known closed convex set, i.e., d ∈ D := {d : |d| ≤ D}.
≥0 . Assumption 3. The uncertainty in inertia tensor is additive and bounded, i.e., J =Ĵ +J whereĴ is the nominal inertia tensor and |J i,j | ≤ J i,j is the uncertain part.

B. Nonlinear PD Sliding Control with Feedforward
Before considering the more general case of uncertain dynamics, it is instructive to analyze the scenario where only an unknown but bounded disturbance acts on (1). Section IV-D will address the scenario where the model is only partially known. Theorem 1 shows that with (3) and under Assumption 1 a nonlinear PD controller with feedfoward results in global exponential closed-loop stability for forward complete desired trajectories. Theorem 1. Consider system (1) with known dynamics f and inertia tensor J. For a bounded disturbance d, the tracking error convergences exponentially to a region near the identity quaternion with the control law (14) where s is the sliding variable (3), K = [k 1 , k 2 , k 3 ] , and Ks is a vector with elements k i s i for i = 1, 2, 3.
Proof. Consider the candidate Lyapunov function V = s Js where s = ω e + λsgn + (q • e ) q e . Differentiating along the s dynamics, Since J is symmetric and positive-definite matrix thenᾱI ≤ J ≤ᾱI forᾱ,ᾱ > 0. By Assumption 1, each s i satisfies which shows |s i (t)| ≤ Di /ki √ᾱ as t → ∞ exponentially. Therefore, since s and the error dynamics form a hierarchy, the error dynamics converge exponentially to region near the identity quaternion.
Remark 3. The sgn + term ensures M b remains continuous if the error quaternion q e were to slip sign during a maneuver.
Smooth control is therefore guaranteed because the sliding variable contains a discontinuity.
Theorem 1 showed that a nonlinear PD controller with feedforward and the sliding surface defined in (3) results in global exponential closed-loop stability. The term "nonlinear PD" is appropriate due to the presence of˙ q e in (14), which, from (2), is˙ q e = q • e ω e + q e ×ω e and arises from the geometry of S 3 . For comparison, a commonly used quaternion-based PD controller without feedforward originally proposed in [7], later applied to aerial robots in [9], and used in [21] is of the form where K p , K d > 0 and all products are element-wise. It is straightforward to show global asymptotic closed-loop stability via the LaSalle invariance principle for any q d and ω d = 0. However, little can be said about the performance of the controller for arbitrary ω d . In applications where ω d is not trivially zero, such as time-varying attitude tracking for spacecraft pointing or even UAV obstacle avoidance, a controller like the one presented in Theorem 1 is required for better closed-loop performance.

C. Robust Sliding Control
The controller presented in Section IV-B works well when only an unknown but bounded disturbance is present. As discussed previously, the main advantage of using sliding variables is that several robust and adaptive controllers can be immediately employed. One such controller is the wellknown sliding mode controller which is able to achieve zero tracking error exponentially through high-frequency control switching. This so-called chattering behavior is synonymous with sliding mode control and makes it unusable for many applications. This section will instead present a continuous version known as the boundary layer sliding controller. Theorem 2 shows how the sliding variable defined in (3) in conjunction with a robust controller gain leads to global exponential closed-loop stability despite model uncertainty.
Theorem 2. For system (1) with unknown disturbances, dynamics, and inertia tensor that satisfy Assumptions 1-3, the sliding variable s from (3) converges in finite time to the region |s| ≤ Φ with the control law where sat is the saturation function, Φ ∈ R 3 >0 is the boundary layer thickness, and Ksat ( s /Φ) is a vector of elements k i sat ( si /Φi). The robust gains k i satisfy where η i > 0 and (·) i denotes the i th element of vector (·). Furthermore, the error quaternion converges exponentially to a region near the identity quaternion.
Proof. Let s ∆ := s − Φ sat ( s /Φ) and consider the candidate Lyapunov function V = s ∆ Js ∆ where V = 0 when |s| = Φ and V > 0 when |s| ≥ Φ. Differentiating along the s ∆ dynamics (which are identical to the s dynamics in this case), Using the control law (15) and noting sat ( s /Φ) = sgn(s ∆ ), where the inequality is obtained by using the robust gain K from (16). (17) shows that s ∆ converges in finite time to zero and, since s ∆ = s − Φ sat ( s /Φ), s converges in finite time to the region |s| ≤ Φ. Therefore, since s and the error quaternion form a hierarchy, the error quaternion globally converges exponentially to a region, defined by the boundary layer thickness Φ, near the identity quaternion.
Remark 5. The boundary layer in Theorem 2 can be made time-varying to capture the effects of state-dependent uncertainty on the tracking error [6]. A time varying-boundary layer is extremely useful in the context of motion planning and predictive control since they essentially represent a dynamic robust control invariant tube which can be used to robustly tighten safety constraints (see, e.g., [22], [23]).
Theorem 2 showed that the error quaternion globally converges exponentially to a region near the identity quaternion despite the presence of model error and external disturbances. This is made possible by making the manifold S Φ = {( q e , ω e ) : |s( q e , ω e )| ≤ Φ} invariant with the robust control gain defined in (16). However, the robust gain K can become large for systems with high model uncertainty as it must handle all possible model and disturbance realizations. Adaptive control is one such method to reduce the robust gain K and lower the control effort from feedback.

D. Adaptive Sliding Control
The performance of the nonlinear PD controller and the robust controller derived in Sections IV-B and IV-C can be improved by learning the unknown model parameters. The nonlinear PD controller can be extended to systems with uncertain dynamics (not handled in Theorem 1), while the robust gain K in Theorem 2 can be reduced. To proceed the following standard assumption is made about (1). (1) can be expressed as a linear combination of unknown parameters a ∈ R p , i.e.,

Assumption 4. The dynamics in
Adaptive control for systems like (1) have been extensively studied and a number of approaches exists. However, only recently have methods been developed that impose physical consistency on parameters, e.g., the inertia tensor being positive-definite, during adaptation [24], [25]. This is possible by employing the Bregman divergence operator where ψ is a strictly convex, continuously differentiable function on a closed convex set. The time derivative of the Bregman divergence iṡ which will be useful in the context of adaptive control. Physical consistency is enforced by appropriately selecting ψ, such as the log-det function for positive-definite matrices or the log function for bounded parameters. Another useful property of the Bregman divergence, eloquently shown in [26], is enforcing sparsity inâ through appropriate selection of ψ. Theorem 3 shows how the controller in (15) can be extended to uncertain systems by adding parameter adaptation that enforces physical consistency.
Theorem 3. Consider system (1) subject to Assumptions 3 an 4. The error quaternion asymptotically converges to the identity quaternion with the nonlinear PD controller and adaptation laẇ (a) Tracking error along body x-axis.
(b) Tracking error along body y-axis.
(c) Tracking error along body z-axis. Fig. 3: Comparison of tracking error with q d = (0.707, 0, −0.707, 0) and q = (0, 1, 0, 0) for a nonlinear PD controller with the proposed sliding variable and those in [12], [14]. The pink circle represents the initial error. The quaternion flips sign midway through maneuver. The tracking error with the proposed sliding variable (blue) converges to one of the two possible sliding manifolds (black). The controller from [12] exhibits undesirable convergence because quaternions are treated as Euclidean vector. The controller in [14] is similar to the proposed but exhibits unwinding (switches to different sliding manifold).
where ω r = ω d − λsgn + (q • e )˙ q e and ψ is a continuously differentiable convex function.
Differentiating along the s dynamics and utilizing Eqs. (19) and (20), With the adaptation law (21) It is easy to verify thatṡ is bounded under the condition that the desired angular accelerationω d is bounded. By Barbalat's lemma, s approaches zero asymptotically. Therefore, by Proposition 1, the error quaternion q e also tends to the identity quaternion as desired.
Remark 6. The adaptation law (21) can be immediately used with the robust sliding controller (15) if adaptation is performed on a subset of unknown parameters. This is advantageous because the robust gain (16) has fewer uncertain parameters to compensate for resulting in lower control effort. Proof omitted for brevity but similar to Theorem 3.

V. RESULTS
The proposed quaternion sliding variable and the controllers presented in Section IV were compared to other quaternion-based sliding controllers found in the literature. Fig. 3 shows the evolution of the tracking error for the nonlinear PD sliding controller (blue) and those presented in [12], [14] (red and orange) when the quaternion q flips sign midway through an orientation pointing maneuver. Because of the sgn + term in (3), the sliding surface S contains two manifolds that correspond to the desired error dynamics. The tracking error with the nonlinear PD controller (blue) exhibits smooth, exponentially convergent behavior despite the sign flip in q. The controllers proposed in [12], [14] exhibit poor performance as convergence is slow and unwinding (switching between the two S manifolds) is observed. Simulation parameters are J = diag ( Fig. 4a shows the two-norm of the vector part of the error quaternion when the nonlinear PD, robust, and adaptive controller are used to stabilize (1) with uncertainty in the inertia tensor J = diag (3,2,4). The boundary layer thickness for (15) is Φ = 0.1. The Bregman Divergence with ψ(x) = log det(x) was used to ensureĴ 0 during model adaptation. The tracking error with (15) converges faster than that with (20) and (14) but at the expense of larger control effort, shown in Fig. 4b. Model adaptation can significantly lower control effort while also improving convergence rate when compared to pure nonlinear PD control.

VI. DISCUSSION
This work presented a quaternion-based sliding variable that represents exponentially convergent quaternion error dynamics. The two defining characteristics of the proposed sliding variable are that it 1) explicitly captures the topology of S 3 and 2) contains a benign discontinuity -which actually guarantees the control input is continuous -to eliminate the unwinding behavior. Although several quaternion and SO(3) controllers have been proposed, the results presented here are easy to analyze, have guaranteed performance, and are straightforward to implement. One research avenue of particular interest is the use of the proposed method for provably safe motion planning of aerial robots flying at high-speeds. Aerodynamic effects can severely degrade the performance of standard attitude controllers making claims on guaranteed safety, i.e., not colliding with obstacles, very difficult to establish. Moreover, the ability to understand how a planned trajectory impacts performance (through time-varying boundary layers), is an element not yet fully leveraged in planning. This, and experimental testing on a physical system, is future work.