ADCS.satellite_hardware.sensors.sensor module¶
- class ADCS.satellite_hardware.sensors.sensor.Sensor(sample_time=0.1, output_length=1, bias=None, noise=None, estimate_bias=False, scale_factor=1.0, misalignment=None)[source]¶
Bases:
objectBase class for all Attitude Determination and Control System (ADCS) sensor models.
This class defines a unified measurement interface for all onboard sensors (e.g., gyroscopes, magnetometers, sun sensors, star trackers). It encapsulates the full sensor measurement pipeline, including:
Ideal (noise– and bias–free) measurement generation
Additive stochastic bias modeling
Additive measurement noise modeling
Time propagation of bias and noise processes
Analytical Jacobians for use in estimation filters (e.g., EKF, UKF)
Subclasses must implement at least
clean_reading()and may override Jacobian methods as required by the sensor physics.Mathematical measurement model¶
The generic sensor model implemented by this class is
\[\mathbf{z}_k = \mathbf{h}(\mathbf{x}_k, \mathcal{O}_k) + \mathbf{b}_k + \mathbf{n}_k\]where:
Notation¶ Symbol
Description
\(\mathbf{z}_k\)
Sensor measurement vector
\(\mathbf{x}_k\)
Full system state vector
\(\mathcal{O}_k\)
Orbital/environmental state
\(\mathbf{h}\)
Ideal (clean) sensor model
\(\mathbf{b}_k\)
Sensor bias
\(\mathbf{n}_k\)
Measurement noise
Bias and noise are modeled using instances of
BiasandNoise, respectively.Bias evolution is typically time-dependent:
\[\mathbf{b}_{k+1} = f_b(\mathbf{b}_k, t_k)\]while noise is assumed to be white or colored stochastic noise:
\[\mathbf{n}_k \sim \mathcal{N}(\mathbf{0}, \mathbf{R})\]- param sample_time:
Sampling period of the sensor in seconds.
- type sample_time:
float
- param output_length:
Dimension of the sensor measurement output.
- type output_length:
int
- param bias:
Bias model instance. If
None, a zero-bias model is used.- type bias:
Biasor None- param noise:
Noise model instance. If
None, a zero-noise model is used.- type noise:
Noiseor None- param estimate_bias:
Indicates whether the sensor bias is included in the estimator state.
- type estimate_bias:
bool
- return:
None
- rtype:
None
Notes
This class does not assume any specific state ordering.
Bias and noise updates are controlled via
ErrorMode.
- as_built(vector)[source]¶
A body-frame vector as this sensor reports it: in its actual (misaligned) frame, times the scale factor.
- Parameters:
vector (ndarray)
- Return type:
ndarray
- as_built_jacobian(jacobian)[source]¶
Apply
as_built()to a Jacobian whose rows are the derivatives of a body-frame vector.- Parameters:
jacobian (ndarray)
- Return type:
ndarray
- basestate_jac(x, os)[source]¶
Jacobian of the clean sensor measurement with respect to the base states.
This method returns the Jacobian
\[\mathbf{H}_x = \frac{\partial \mathbf{h}(\mathbf{x}, \mathcal{O})} {\partial \mathbf{x}_{\text{base}}}\]where \(\mathbf{x}_{\text{base}}\) denotes the non-bias portion of the system state.
The default implementation assumes that the measurement is independent of the base state and returns a zero matrix. Sensor subclasses should override this method to provide physically meaningful derivatives.
- Parameters:
x (ADCS.state.State) – Full system state vector.
os (
Orbital_State) – Orbital and environmental state.
- Returns:
Jacobian matrix of shape
(output_length, N_base_states).- Return type:
numpy.ndarray
- bias_jac(x, os)[source]¶
Jacobian of the measurement with respect to the sensor bias state.
If the measurement model is
\[\mathbf{z} = \mathbf{h}(\mathbf{x}, \mathcal{O}) + \mathbf{b},\]then the Jacobian with respect to the bias is
\[\mathbf{H}_b = \frac{\partial \mathbf{z}}{\partial \mathbf{b}} = \mathbf{I}\]where \(\mathbf{I}\) is the identity matrix of dimension
output_length.If the sensor does not include a bias model, an empty Jacobian is returned.
- Parameters:
x (ADCS.state.State) – Full system state vector (unused).
os (
Orbital_State) – Orbital state object (unused).
- Returns:
Identity matrix of shape
(output_length, output_length)if a bias model exists; otherwise an empty matrix.- Return type:
numpy.ndarray
- bias_process_psd(*, form='full')[source]¶
Return the continuous PSD of this sensor’s bias random walk.
- Parameters:
form (str)
- Return type:
- measurement_covariance(*, form='full')[source]¶
Return measurement-noise covariance owned by this sensor.
- Parameters:
form (str)
- Return type:
- reading(x, os, dmode=None)[source]¶
Compute the full sensor measurement including bias and noise.
This method evaluates the complete sensor pipeline:
Compute the clean (ideal) sensor reading
Add the current sensor bias
Update the bias process (if enabled)
Add measurement noise
Update the noise process (if enabled)
Formally, the measurement is computed as
\[\mathbf{z} = \mathbf{h}(\mathbf{x}, \mathcal{O}) + \mathbf{b}(t) + \mathbf{n}\]where:
\(\mathbf{h}\) is implemented by
clean_reading()\(\mathbf{b}(t)\) is provided by
Bias\(\mathbf{n}\) is provided by
Noise
The inclusion and propagation of bias and noise are controlled via
ErrorMode.- Parameters:
x (ADCS.state.State) – Full system state vector.
os (
Orbital_State) – Orbital and environmental state providing the current timeos.J2000.dmode (
ErrorModeor None) – Error mode configuration controlling bias and noise behavior. IfNone, all effects are enabled.
- Returns:
Sensor measurement vector.
- Return type:
numpy.ndarray
- reference_direction(os)[source]¶
Unit vector, in the inertial frame, of the direction this sensor observes.
Nonefor sensors that observe no fixed reference direction (the default) and for a star tracker that does not know which star it saw. Used to pair a body-frame observation with its inertial counterpart.- Parameters:
os (
Orbital_State) – Orbital state at the time of the reading.- Returns:
Unit reference direction in ECI, or
None.- Return type:
numpy.ndarray | None
- misalignment: ndarray | None = None¶
- mounting_rotation: ndarray = array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]])¶
- observation_kind: str | None = None¶
What the sensor observes, for single-frame attitude determination and estimator warm starts:
"magnetic_field","sun","nadir","star"(a direction),"attitude"(a full quaternion),"angular_rate", orNonewhen the reading is none of these. Single-axis direction sensors exposeaxis(and sun sensorsefficiency); vector sensors return the body-frame direction itself.
- scale_factor: float = 1.0¶
- property sensing_axis: ndarray¶
the nominal
axisrotated by the misalignment.A sensor without a misalignment has the identity mounting rotation, so its nominal
axisis returned directly. This sits on every reading and Jacobian of the single-axis sensors, and skipping the 3x3 product keeps the nominal device as fast as it was before mounting errors existed.- Type:
The sensitive axis of a single-axis sensor as mounted