Skip to main content

Quaternion Attitude Controller

1. Model Overview

The SDF attitude-control model provides two complementary rotational control modes for a spacecraft equipped with reaction-control-system thrusters:

  • Kill Rotation damps the spacecraft body angular velocity toward zero without prescribing an absolute target attitude.
  • Stabilize captures the spacecraft attitude at activation and subsequently drives the vehicle back toward this reference attitude while simultaneously damping angular motion.

The attitude-hold formulation operates directly in quaternion space. Euler-angle conversion is therefore not required inside the control model, avoiding the singularities associated with three-angle attitude parameterizations.

The controller output is interpreted as a three-axis rotational command. The physical torque acting on the spacecraft is generated by the separate RCS actuator and control-allocation models.


2. Quaternion Attitude Representation

Spacecraft orientation is represented by the normalized quaternion

q=[qwqxqyqz],∥q∥=1 q = \begin{bmatrix} q_w \\ q_x \\ q_y \\ q_z \end{bmatrix}, \qquad \lVert q \rVert = 1

with scalar component qwq_w and vector component

qv=[qxqyqz]. \mathbf{q}_v = \begin{bmatrix} q_x \\ q_y \\ q_z \end{bmatrix}.

Because the quaternions qq and−q-q describe the same physical orientation, the attitude-control formulation explicitly resolves this sign ambiguity when evaluating the rotational error.


3. Quaternion Attitude Error

In Stabilize mode, the current attitude at the activation instant is stored as the reference attitude:

qtarget=q(tactivation) q_{target} = q\left(t_{activation}\right)

The attitude error is then formed as

qe=qtarget−1⊗qcurrent q_e = q_{target}^{-1} \otimes q_{current}

where ⊗\otimes denotes quaternion multiplication. For a unit quaternion,q−1=q∗q^{-1}=q^*, so the inverse corresponds to the quaternion conjugate.

To enforce the shortest rotational representation, the sign of the error quaternion is selected such that

qe,w≥0. q_{e,w} \ge 0.

If qe,w<0q_{e,w}<0, all quaternion coefficients are multiplied by −1-1. The proportional attitude error used by the controller is the vector part

eq=[qe,xqe,yqe,z]. \mathbf{e}_q = \begin{bmatrix} q_{e,x} \\ q_{e,y} \\ q_{e,z} \end{bmatrix}.

4. Kill Rotation

Kill Rotation is a pure angular-rate damping mode. Its control objective is

ω→0\boldsymbol{\omega} \rightarrow \mathbf{0}

where ω\boldsymbol{\omega} is the spacecraft angular velocity expressed in the spacecraft body-fixed frame. The three axes are treated independently according to

uKR=−Kω⊙ω \mathbf{u}_{KR} = -\mathbf{K}_{\omega} \odot \boldsymbol{\omega}

with component-wise multiplication⊙\odot. A small angular-rate deadband avoids unnecessary RCS commands once the remaining rotation becomes sufficiently small:

∣ωi∣≤0.005  rad/s⇒uKR,i=0. |\omega_i| \le 0.005\;\mathrm{rad/s} \quad\Rightarrow\quad u_{KR,i}=0.

Unlike Stabilize mode, Kill Rotation does not contain an absolute attitude-restoration term. A stationary spacecraft therefore produces zero command even if its orientation differs from an earlier attitude.


5. Stabilize Control Law

Stabilize combines quaternion attitude-error feedback with direct angular-rate damping. The current control law is

uS=−KP⊙eq−KD⊙ω \mathbf{u}_{S} = -\mathbf{K}_{P} \odot \mathbf{e}_q - \mathbf{K}_{D} \odot \boldsymbol{\omega}

The proportional term drives the spacecraft toward the captured reference orientation, while the derivative term removes rotational kinetic motion and provides damping around the target state.

The resulting equilibrium objective is therefore

qcurrent→qtarget,ω→0. q_{current} \rightarrow q_{target}, \qquad \boldsymbol{\omega} \rightarrow \mathbf{0}.

6. Attitude Error Angle

For evaluation and switching logic, the quaternion error is converted into a single physically interpretable angular deviation. After shortest-path sign handling, the total attitude error angle is

θe=2arccos⁡(clamp⁡(qe,w,−1,1)). \theta_e = 2\arccos \left( \operatorname{clamp} \left( q_{e,w}, -1, 1 \right) \right).

The clamping operation protects the inverse cosine against small floating-point excursions outside the mathematically valid interval.


7. Hysteresis for Discrete RCS Actuation

The current RCS actuation model is binary. A non-zero rotational command can therefore result in full thruster activation even when the continuous-valued controller output is very small. Initial attitude-hold tests showed that a single deadband leads to repeated switching around the target state.

SDF therefore applies a two-threshold hysteresis to the Stabilize correction state.

Correction OFF condition

θe<0.5∘∧∥ω∥∞<0.005  rad/s \theta_e < 0.5^{\circ} \quad\land\quad \lVert\boldsymbol{\omega}\rVert_{\infty} < 0.005\;\mathrm{rad/s}

Correction ON condition

θe>1.0∘∨∥ω∥∞>0.010  rad/s \theta_e > 1.0^{\circ} \quad\lor\quad \lVert\boldsymbol{\omega}\rVert_{\infty} > 0.010\;\mathrm{rad/s}

Between these inner and outer thresholds, the previous correction state is retained. The resulting Schmitt-trigger-like behavior reduces rapid RCS chatter while preserving a bounded attitude-hold region.


8. Model Variables and Parameters

SymbolDescriptionUnitFrame / Domain
qtargetq_{target}Captured target attitude quaternion–Attitude representation
qcurrentq_{current}Current spacecraft attitude quaternion–Attitude representation
qeq_eQuaternion attitude error–Relative attitude
eq\mathbf{e}_qVector part of the quaternion attitude error–3-axis control error
ω\boldsymbol{\omega}Spacecraft body angular velocityrad/sSBF
KP\mathbf{K}_PAttitude-error proportional gain vector–Controller parameter
KD\mathbf{K}_DAngular-rate damping gain vector–Controller parameter
θe\theta_eTotal quaternion attitude error anglerad / degScalar error metric
uS\mathbf{u}_SStabilize rotational control command–SBF control axes

9. Assumptions and Simplifications

  • The attitude quaternion is assumed to remain normalized within numerical tolerance.
  • The target attitude remains fixed for the complete duration of one Stabilize activation.
  • Angular velocity is directly available in the spacecraft body-fixed frame.
  • Controller gains are currently constant and axis-wise.
  • No integral control term is applied.
  • The controller itself does not model actuator delay or thrust-transient dynamics.
  • The hysteresis thresholds are currently engineering parameters rather than analytically optimized switching surfaces.
  • RCS allocation remains binary in the present SDF Light formulation.

10. Verification Results

The following figures are generated from exported SDF telemetry and illustrate the measured closed-loop behavior of the current quaternion attitude controller.

Quaternion attitude error during Stabilize mode
Figure 1 — Stabilize attitude error.The reference attitude is captured when Stabilize is activated at approximately 14.5 s. The initial angular momentum causes a substantial transient attitude excursion before the quaternion feedback drives the error back toward the target. In the tested trajectory, the error first enters the inner 0.5° settling region at approximately 27.5 s.
Angular-rate envelope during Stabilize mode
Figure 2 — Stabilize angular-rate envelope.The maximum absolute body-axis angular velocity is reduced from the initial rotational state toward the hysteresis hold region. The inner and outer angular-rate thresholds illustrate the separation between correction deactivation and re-engagement.
Body angular velocity response during Kill Rotation mode
Figure 3 — Kill Rotation response.The three body-axis angular velocities are damped toward zero. The final residual rates remain within the ±0.005 rad/s deadband used by the current Kill Rotation formulation.

The telemetry also reveals the limitations of the present binary actuator interaction: after the main transient has decayed, short RCS correction bursts remain visible as the state moves between the hysteresis thresholds. This behavior is bounded and suitable for the SDF Light model, while providing a measurable basis for future work on pulse modulation, control allocation, and actuator-aware switching laws.


11. Validity and Limitations

The current formulation provides a compact quaternion-based attitude-control model that is suitable for closed-loop 6DoF simulation with discrete RCS actuation. It correctly distinguishes between pure angular-rate damping and absolute attitude hold, avoids Euler-angle singularities, and produces bounded attitude regulation in the tested multi-axis cases.

The controller should not yet be interpreted as an optimized spacecraft attitude-control law. In particular, the continuous PD output is coupled to a binary thruster system, while the hysteresis limits are fixed engineering values. Future extensions may therefore formulate the control problem directly in rotational phase space and include minimum-impulse-bit behavior, pulse modulation, actuator constraints, and improved control allocation.


12. References

  • Wertz, J. R. (Ed.), Spacecraft Attitude Determination and Control, D. Reidel Publishing Company, 1978.
  • Wie, B., Space Vehicle Dynamics and Control, 2nd ed., AIAA Education Series, 2008.
  • Schaub, H. and Junkins, J. L., Analytical Mechanics of Space Systems, AIAA Education Series.