ADCS.controller.controller module

class ADCS.controller.controller.Controller(est_sat, **kwargs)[source]

Bases: object

Base abstract controller class for all ADCS control law implementations.

This class defines the common interface and shared utility methods required by all attitude determination and control system controllers. A controller is responsible for computing actuator command inputs that achieve a desired attitude, angular rate, or torque objective.

Controllers derived from this base class typically implement a specific control law, such as magnetic detumbling, reaction-wheel stabilization, or pointing control. The base class additionally provides helper methods for sensor reconstruction and actuator allocation using Moore–Penrose pseudoinverses.

Any concrete controller must override find_u().

Parameters:

est_sat (EstimatedSatellite)

build_sensor_matrix_pinv(sensors, sensor_type)[source]

Constructs a sensor reconstruction matrix using a Moore–Penrose pseudoinverse.

This method builds a linear mapping that reconstructs a three-dimensional physical vector from a stacked sensor measurement vector. Only sensors of the specified type are used in the reconstruction.

Let \(y\) denote the flattened measurement vector and \(A \in \mathbb{R}^{3 \times N}\) the stacked sensing axis matrix of the selected sensors. The reconstructed vector is

\[\mathbf{v}_{\mathrm{body}} = A^{\dagger} \, y\]

where \(A^{\dagger}\) is the Moore–Penrose pseudoinverse.

Parameters:
  • sensors (list[Sensor]) – List of all satellite sensors

  • sensor_type (type) – Sensor type to include in the reconstruction

Returns:

Reconstruction matrix and corresponding measurement indices

Return type:

tuple[numpy.ndarray, list[int]]

build_torque_to_u_matrix_pinv(actuators, actuator_type)[source]

Builds an actuator allocation matrix mapping desired body torque to actuator command space.

This method constructs the pseudoinverse of the actuator direction matrix formed from the torque axes of the selected actuators.

Let \(A \in \mathbb{R}^{3 \times N}\) be the stacked actuator axis matrix. The minimum-norm actuator command vector satisfying a desired torque \(\boldsymbol{\tau}\) is

\[\mathbf{u} = A^{\dagger} \boldsymbol{\tau}\]
Parameters:
  • actuators (list[Actuator]) – List of all satellite actuators

  • actuator_type (type) – Target actuator type

Returns:

Allocation matrix and actuator command indices

Return type:

tuple[numpy.ndarray, list[int]]

build_u_to_torque_matrix_pinv(actuators, actuator_type)[source]

Builds the forward mapping matrix from actuator commands to body-frame torque directions.

This matrix represents the physical contribution of each actuator input to the generated body torque:

\[\boldsymbol{\tau} = A \, \mathbf{u}\]

where each column of \(A\) corresponds to an actuator torque axis.

For magnetorquers, the resulting torque is computed as

\[\boldsymbol{\tau} = [\mathbf{B}]_{\times} A \mathbf{u}\]

where \([\mathbf{B}]_{\times}\) denotes the skew-symmetric matrix of the geomagnetic field.

Parameters:
  • actuators (list[Actuator]) – List of all satellite actuators

  • actuator_type (type) – Target actuator type

Returns:

Forward torque mapping matrix

Return type:

numpy.ndarray

find_max_torque(actuators, actuator_type=None)[source]

Extracts maximum allowable actuator command magnitudes.

This method returns a vector of actuator saturation limits. These values are typically used to clip or normalize control inputs prior to command execution.

If no actuator type is specified, limits for all actuators are returned in command vector order.

Parameters:
  • actuators (list[Actuator]) – List of all satellite actuators

  • actuator_type (type or None) – Optional actuator type filter

Returns:

Vector of maximum actuator command values

Return type:

numpy.ndarray

find_u(x_hat, sens, est_sat, os_hat, goal, **kwargs)[source]

Computes actuator command inputs that satisfy the control objective.

This method defines the primary controller interface and must be implemented by all derived controller classes. Implementations typically compute a desired control torque in the body frame and then allocate actuator commands accordingly.

In abstract form, the control problem can be written as

\[\boldsymbol{\tau}_{\mathrm{des}} = f(x, y, g)\]

where the desired torque is a function of the estimated state, sensor measurements, and mission goal. Actuator commands are then computed as

\[\mathbf{u} = A^{\dagger} \boldsymbol{\tau}_{\mathrm{des}}\]

where \(A^{\dagger}\) denotes an actuator allocation pseudoinverse.

Parameters:
  • x_hat (numpy.ndarray) – Estimated spacecraft state vector

  • sens (numpy.ndarray) – Flattened sensor measurement vector

  • est_sat (EstimatedSatellite) – Estimated satellite model providing hardware properties

  • os_hat (Orbital_State) – Estimated orbital state

  • goal (Goal or None) – Optional mission goal definition

  • kwargs (dict) – Optional controller-specific parameters

Returns:

Actuator command vector

Return type:

numpy.ndarray