3D Spacecraft Attitude Stabilization
A spacecraft can rotate about all three body axes at the same time. Earlier control problems used simplified single-axis models, but real attitude stabilization requires a representation that remains valid for large rotations.
stabilize the spacecraft from an arbitrary initial attitude to a desired target attitude.
The controller must reduce both attitude error and angular velocity:
Why Euler Angles Become Limiting
Roll, pitch, and yaw are useful for visualization, but they are not ideal for global spacecraft attitude control. Near certain rotations, Euler-angle descriptions can become singular.
Quaternions are safer for control.
Representing Attitude with a Unit Quaternion
A quaternion stores the spacecraft attitude using one scalar part and one vector part:
The quaternion evolves according to angular velocity:
In this page, the simulation integrates quaternion motion directly and normalizes the quaternion at every time step to preserve the unit constraint.
The Rotation Needed to Reach the Target
Quaternion control uses the error quaternion:
The vector part of the error quaternion gives the correction direction. The scalar part helps represent the size of the rotation.
Quaternion-Based Control Law
The nonlinear PD controller applies torque based on quaternion attitude error and angular velocity:
The first term corrects orientation. The second term damps rotational motion.
Why Damping Is Needed
Quaternion error tells the controller which direction to rotate, but angular velocity damping controls how smoothly the spacecraft stops rotating.
oscillation in 3D → continuous tumbling
smooth convergence → physically realistic
Simulate 3D Quaternion Attitude Control
Adjust the initial attitude, target attitude, and gains. The simulation converts roll–pitch–yaw inputs into quaternions, computes quaternion error, applies nonlinear PD torque, and plots the attitude error, angular velocity, torque demand, and quaternion components.
Initial Attitude
Target Attitude
Control Gains
Automatic Diagnostics
These metrics summarize whether the controller is smooth, aggressive, or too slow for the selected gains and attitude command.
Waiting...
Waiting...
Waiting...
Waiting...
Waiting...
What This Problem Shows
Useful for display, but not ideal for global spacecraft attitude control.
Represent 3D attitude without Euler-angle singularities.
Uses quaternion error and angular velocity damping to stabilize orientation.
Quaternions are required for robust 3D control.
PD → PID → LQR → actuator limits → quaternion nonlinear control → MPC