opengnc.classical_control package
Submodules
opengnc.classical_control.bdot module
B-Dot controller for spacecraft magnetic detumbling.
- class opengnc.classical_control.bdot.BDot(gain: float)[source]
Bases:
objectB-Dot controller for magnetic detumbling.
Control Law: $mathbf{m} = -K_{gain} dot{mathbf{B}}$
- Parameters:
gain (float) – Feedback gain $K$ ($Am^2 s / T$).
- calculate_control(b_dot: ndarray | list[float]) ndarray[source]
Calculate the required magnetic dipole moment from the B-field rate.
- Parameters:
b_dot (np.ndarray or list) – The time derivative of the magnetic field vector ($dot{B}$) in the Body frame (3,). Units: [T/s].
- Returns:
Magnetic dipole moment vector $m$ in Body frame (3,). Units: $[A cdot m^2]$.
- Return type:
np.ndarray
- calculate_control_discrete(b_field_curr: ndarray | list[float], b_field_prev: ndarray | list[float], dt: float) ndarray[source]
Calculate B-Dot control using discrete finite differences.
Useful when only B-field measurements are available instead of explicit rates.
- Parameters:
b_field_curr (np.ndarray or list) – Current magnetic field vector measurement (Body frame). Units: [T].
b_field_prev (np.ndarray or list) – Previous magnetic field vector measurement (Body frame). Units: [T].
dt (float) – Time step between measurements (s).
- Returns:
Magnetic dipole moment vector $m$ in Body frame (3,).
- Return type:
np.ndarray
opengnc.classical_control.momentum_dumping module
Reaction wheel momentum desaturation using magnetic torque.
- class opengnc.classical_control.momentum_dumping.CrossProductLaw(gain: float, max_dipole: float | None = None)[source]
Bases:
objectReaction wheel momentum desaturation using the cross-product law.
This controller calculates a magnetic dipole moment
msuch that the resulting magnetic torqueT = m x Bopposes the component of the angular momentum error perpendicular to the magnetic field.Control law:
m = k * (H_err x B) / ||B||^2.
opengnc.classical_control.pid module
Generic PID controller implementation with anti-windup logic.
- class opengnc.classical_control.pid.PID(kp: float, ki: float, kd: float, output_limits: tuple[float, float] | None = None, anti_windup_method: str = 'clamping')[source]
Bases:
objectGeneric PID controller with anti-windup.
Control Law: $u(t) = K_p e(t) + K_i int_0^t e(tau) dtau + K_d frac{de(t)}{dt}$
- Parameters:
kp (float) – Proportional gain.
ki (float) – Integral gain.
kd (float) – Derivative gain.
output_limits (tuple[float, float] | None, optional) – (min, max) saturation limits.
anti_windup_method (str, optional) – Method (e.g., “clamping”). Default “clamping”.
opengnc.classical_control.rate_damping module
Proportional rate damping controller for torque-based detumbling.
- class opengnc.classical_control.rate_damping.RateDampingControl(gain: float, max_torque: float | None = None)[source]
Bases:
objectProportional angular rate damping controller for spacecraft detumbling.
Generates torque commands to reduce the spacecraft’s angular rates, typically using thrusters or other active actuators.
Control law:
T = -K omega.
Module contents
- class opengnc.classical_control.BDot(gain: float)[source]
Bases:
objectB-Dot controller for magnetic detumbling.
Control Law: $mathbf{m} = -K_{gain} dot{mathbf{B}}$
- Parameters:
gain (float) – Feedback gain $K$ ($Am^2 s / T$).
- calculate_control(b_dot: ndarray | list[float]) ndarray[source]
Calculate the required magnetic dipole moment from the B-field rate.
- Parameters:
b_dot (np.ndarray or list) – The time derivative of the magnetic field vector ($dot{B}$) in the Body frame (3,). Units: [T/s].
- Returns:
Magnetic dipole moment vector $m$ in Body frame (3,). Units: $[A cdot m^2]$.
- Return type:
np.ndarray
- calculate_control_discrete(b_field_curr: ndarray | list[float], b_field_prev: ndarray | list[float], dt: float) ndarray[source]
Calculate B-Dot control using discrete finite differences.
Useful when only B-field measurements are available instead of explicit rates.
- Parameters:
b_field_curr (np.ndarray or list) – Current magnetic field vector measurement (Body frame). Units: [T].
b_field_prev (np.ndarray or list) – Previous magnetic field vector measurement (Body frame). Units: [T].
dt (float) – Time step between measurements (s).
- Returns:
Magnetic dipole moment vector $m$ in Body frame (3,).
- Return type:
np.ndarray
- class opengnc.classical_control.CrossProductLaw(gain: float, max_dipole: float | None = None)[source]
Bases:
objectReaction wheel momentum desaturation using the cross-product law.
This controller calculates a magnetic dipole moment
msuch that the resulting magnetic torqueT = m x Bopposes the component of the angular momentum error perpendicular to the magnetic field.Control law:
m = k * (H_err x B) / ||B||^2.
- class opengnc.classical_control.PID(kp: float, ki: float, kd: float, output_limits: tuple[float, float] | None = None, anti_windup_method: str = 'clamping')[source]
Bases:
objectGeneric PID controller with anti-windup.
Control Law: $u(t) = K_p e(t) + K_i int_0^t e(tau) dtau + K_d frac{de(t)}{dt}$
- Parameters:
kp (float) – Proportional gain.
ki (float) – Integral gain.
kd (float) – Derivative gain.
output_limits (tuple[float, float] | None, optional) – (min, max) saturation limits.
anti_windup_method (str, optional) – Method (e.g., “clamping”). Default “clamping”.
- class opengnc.classical_control.RateDampingControl(gain: float, max_torque: float | None = None)[source]
Bases:
objectProportional angular rate damping controller for spacecraft detumbling.
Generates torque commands to reduce the spacecraft’s angular rates, typically using thrusters or other active actuators.
Control law:
T = -K omega.