Attitude control modules consume an AttGuidMsgPayload tracking-error message and produce commanded torques or rate commands that drive the spacecraft attitude toward the desired reference. The two primary controllers are mrpFeedback (direct torque output) and mrpSteering (rate command output with a separate servo loop).
MRP feedback (mrpFeedback)
mrpFeedback implements the full nonlinear MRP attitude feedback control law from Chapter 8 of Analytical Mechanics of Space Systems. It produces a body-frame torque vector that asymptotically tracks any general reference attitude trajectory. Optionally it compensates for reaction-wheel gyroscopic effects and includes integral feedback to reject constant disturbance torques.
Control law
The commanded control torque is:
L_r = -K σ - P δω - P K_i z
- I_RW(-dω_r/dt + ω̃ ω_r) - L
+ (ω̃_r + K_i z̃)(I_RW ω + G_s h_s)
where σ is the MRP attitude error, δω is the rate error, z is the integral of the attitude error, and h_s contains the RW angular momenta. Setting Ki to a negative value disables the integrator, leaving a PD-only control law.
Parameters
| Parameter | Units | Description |
|---|
K | rad/s | Proportional gain on MRP attitude error |
P | N·m·s | Rate error feedback gain |
Ki | N·m | Integral feedback gain. Set negative to disable integration. |
integralLimit | N·m | Element-wise saturation limit on the attitude error integral |
controlLawType | — | 0 (default): avoid quadratic ω terms. 1: simpler form with quadratic ω terms. |
knownTorquePntB_B | N·m | Known external disturbance torque (optional feed-forward) |
Messages
| Variable | Type | Direction | Description |
|---|
guidInMsg | AttGuidMsgPayload | Input | Attitude tracking errors from guidance module |
vehConfigInMsg | VehicleConfigMsgPayload | Input | Spacecraft inertia tensor (read once on reset) |
rwParamsInMsg | RWArrayConfigMsgPayload | Input | (optional) RW spin-axis geometry and inertias |
rwSpeedsInMsg | RWSpeedMsgPayload | Input | (optional) RW spin speeds |
rwAvailInMsg | RWAvailabilityMsgPayload | Input | (optional) RW availability flags |
cmdTorqueOutMsg | CmdTorqueBodyMsgPayload | Output | Total control torque command |
intFeedbackTorqueOutMsg | CmdTorqueBodyMsgPayload | Output | Integral-feedback portion of the torque |
If you connect rwParamsInMsg, you must also connect rwSpeedsInMsg. rwAvailInMsg is optional and lets you exclude individual wheels from the control solution at run time.
Configuration example
from Basilisk.fswAlgorithms import mrpFeedback
mrpControl = mrpFeedback.mrpFeedback()
mrpControl.ModelTag = "mrpFeedback"
# gains
mrpControl.K = 3.5 # [rad/s] proportional gain
mrpControl.P = 30.0 # [N*m*s] rate feedback gain
mrpControl.Ki = 0.0002 # [N*m] integral gain (set < 0 to disable)
mrpControl.integralLimit = 2.0 / mrpControl.Ki * 0.1 # [N*m]
# connect messages
mrpControl.guidInMsg.subscribeTo(attGuidMsg)
mrpControl.vehConfigInMsg.subscribeTo(vehConfigMsg)
mrpControl.rwParamsInMsg.subscribeTo(rwParamsMsg)
mrpControl.rwSpeedsInMsg.subscribeTo(rwSpeedMsg)
scSim.AddModelToTask(taskName, mrpControl)
Start with Ki disabled (Ki = -1) and tune K and P for the desired transient response before enabling integral action. Choose integralLimit to cap the integral term at roughly the magnitude of the expected disturbance torque.
MRP PD control (mrpPD)
A simplified version of mrpFeedback without reaction-wheel compensation or integral feedback. It directly implements the PD control law from Section 8.4.1 of Analytical Mechanics of Space Systems and outputs a torque intended for a thruster cluster.
Parameters
| Parameter | Description |
|---|
K | Proportional gain on MRP attitude error |
P | Rate error proportional gain |
knownTorquePntB_B | (optional) Known external torque feed-forward |
Messages
| Variable | Type | Direction | Description |
|---|
guidInMsg | AttGuidMsgPayload | Input | Attitude guidance tracking errors |
vehConfigInMsg | VehicleConfigMsgPayload | Input | Vehicle inertia |
cmdTorqueOutMsg | CmdTorqueBodyMsgPayload | Output | Commanded external torque |
MRP steering (mrpSteering)
mrpSteering produces commanded body rates rather than direct torques, following a kinematic steering law. A separate rate servo controller (such as rateServoFullNonlinear) converts the rate commands into physical torques. This two-loop architecture lets you impose a maximum slew rate while maintaining Lyapunov stability.
The steering function uses a smoothly saturating arctangent law with a cubic correction term:
f(σᵢ) = arctan((K₁ σᵢ + K₃ σᵢ³) · π / (2 ω_max)) · (2 ω_max / π)
For small errors this linearizes to K₁ σᵢ. As |σᵢ| → ∞ the output saturates at ±ω_max.
Parameters
| Parameter | Description |
|---|
K1 | Linear attitude error gain |
K3 | Cubic correction term — controls how quickly the rate saturates |
omega_max | Maximum commanded body rate [rad/s] |
Messages
| Variable | Type | Direction | Description |
|---|
guidInMsg | AttGuidMsgPayload | Input | Attitude guidance tracking errors |
rateCmdOutMsg | RateCmdMsgPayload | Output | Commanded body rates and rate derivatives |
from Basilisk.fswAlgorithms import mrpSteering
import numpy as np
steering = mrpSteering.mrpSteeringConfig()
wrap = mrpSteering.mrpSteeringWrap(steering)
wrap.ModelTag = "mrpSteering"
steering.K1 = 0.1 # linear gain
steering.K3 = 1.0 # cubic gain
steering.omega_max = np.deg2rad(3.0) # [rad/s] max slew rate
wrap.guidInMsg.subscribeTo(attGuidMsg)
scSim.AddModelToTask(taskName, wrap, steering)
PRV steering (prvSteering)
Implements an attitude steering law using the Principal Rotation Vector (PRV) parameterization instead of MRPs. Like mrpSteering, it outputs commanded body rates (RateCmdMsgPayload) for a downstream rate servo.
Messages
| Variable | Type | Direction | Description |
|---|
guidInMsg | AttGuidMsgPayload | Input | Attitude guidance tracking errors |
rateCmdOutMsg | RateCmdMsgPayload | Output | Rate command |
Rate servo — full nonlinear (rateServoFullNonlinear)
The rate servo loop that converts rate commands from mrpSteering or prvSteering into a physical torque command. It implements a full nonlinear feedback law that compensates for RW gyroscopic terms.
Low-pass filter torque command (lowPassFilterTorqueCommand)
Applies a first-order low-pass filter to a torque command message. Insert this module between a controller and an effector interface to reduce high-frequency chatter.
Magnetic torque-bar feedforward (mtbFeedforward)
Computes a feedforward magnetic torque-bar (MTB) command that cancels a portion of a known disturbance torque. Works alongside a feedback controller to improve disturbance rejection.
MTB momentum management (mtbMomentumManagement)
Manages reaction-wheel momentum using magnetic torque bars. The module computes MTB dipole moment commands that drive the net RW angular momentum toward a desired value.
MTB momentum management simplified (mtbMomentumManagementSimple)
A simplified version of mtbMomentumManagement that applies a proportional control law directly on the RW momentum error without the full optimization of the standard module.
Thruster momentum management (thrMomentumManagement)
Dumps accumulated RW momentum using on-off thruster firings. The module computes the required impulsive delta-V direction and magnitude to null the RW momentum, then triggers thruster commands.