ADCS.satellite_hardware.sensors.star_tracker_quaternion module

class ADCS.satellite_hardware.sensors.star_tracker_quaternion.StarTrackerQuaternion(sample_time=0.1, bias=None, noise=None, estimate_bias=False, boresight=array([0., 0., 1.]), fov=np.float64(0.3490658503988659), sun_exclusion=np.float64(0.4363323129985824), min_stars=2, star_catalog=None)[source]

Bases: Sensor

Star tracker sensor with quaternion attitude output.

Unlike the single-vector StarTracker, this sensor solves for the full spacecraft attitude by observing multiple navigation stars simultaneously and applying Wahba’s attitude determination algorithm.

Measurement model

Given \(N \ge 2\) visible stars with known inertial directions \(\{\mathbf{r}_i\}\) and measured body-frame directions \(\{\mathbf{b}_i\}\), the sensor solves Wahba’s problem:

\[\hat{\mathbf{C}} = \arg\min_{\mathbf{C}} \frac{1}{2} \sum_{i=1}^{N} w_i \left\| \mathbf{b}_i - \mathbf{C}\,\mathbf{r}_i \right\|^2\]

The optimal rotation matrix \(\hat{\mathbf{C}}\) is obtained via SVD of the attitude profile matrix and converted to a quaternion:

\[\mathbf{q}_{\text{meas}} = \mathrm{quat}(\hat{\mathbf{C}})\]

Star weighting uses inverse visual magnitude so that brighter stars receive higher weight.

Including bias and noise, the full measurement is

\[\tilde{\mathbf{q}} = \mathbf{q}_{\text{clean}} + \mathbf{b} + \mathbf{n}\]

After corruption, the quaternion is renormalized and the scalar component is enforced positive.

Star selection

At each measurement epoch, the sensor:

  1. Projects the sensor boresight into the inertial frame

  2. Queries the StarCatalog for visible stars

  3. Applies field-of-view and exclusion constraints (Sun, optional Moon)

  4. Requires at least min_stars visible stars for a valid solution

If fewer than min_stars stars are available, the output is NaN.

Estimator properties

  • Output dimension: 4 (unit quaternion)

  • Depends only on attitude quaternion

  • Jacobian is nonzero only w.r.t. quaternion states

  • No coupling to angular velocity or momentum states

See also

StarTracker, StarCatalog, wahbas_svd()

basestate_jac(x, os)[source]

Jacobian of the quaternion measurement w.r.t. the base state.

The measurement depends only on the attitude quaternion. The angular velocity block is zero.

For the clean measurement (Wahba’s solution from noise-free star observations), the measured quaternion equals the true quaternion. Therefore the Jacobian w.r.t. the quaternion states is the identity:

\[\frac{\partial \mathbf{q}_{\text{meas}}}{\partial \boldsymbol{\omega}} = \mathbf{0}_{3 \times 4}, \qquad \frac{\partial \mathbf{q}_{\text{meas}}}{\partial \mathbf{q}} = \mathbf{I}_{4 \times 4}\]
Parameters:
  • x (numpy.ndarray) – Full spacecraft state vector.

  • os (Orbital_State) – Orbital state.

Returns:

Base-state Jacobian of shape (7, 4).

Return type:

numpy.ndarray

bias_jac(x, os)[source]

Jacobian of the measurement w.r.t. bias states.

The quaternion star tracker bias is not included in the estimator state, so the bias Jacobian is empty.

Parameters:
  • x (numpy.ndarray) – Full spacecraft state vector (unused).

  • os (Orbital_State) – Orbital state (unused).

Returns:

Empty bias Jacobian of shape (0, 4).

Return type:

numpy.ndarray

clean_reading(x, os)[source]

Compute the noise-free quaternion attitude measurement.

The method determines star visibility and, if at least min_stars navigation stars are observable, returns the true attitude quaternion. In the noise-free case, the star tracker perfectly recovers the spacecraft attitude from the observed star directions.

The visibility check is the key physical constraint: the sensor can only provide a measurement when sufficient stars fall within its field of view and are not occluded by the Earth, Moon, or Sun.

\[\mathbf{q}_{\text{clean}} = \mathbf{q}\]
Parameters:
  • x (numpy.ndarray) – Full spacecraft state vector.

  • os (Orbital_State) – Orbital state used for star visibility.

Returns:

Attitude quaternion (scalar-first), or NaN if insufficient stars are visible.

Return type:

numpy.ndarray

reading(x, os, dmode=None)[source]

Compute the full quaternion measurement including bias and noise.

After the base class applies bias and noise, the quaternion is renormalized and the scalar component is enforced positive.

Parameters:
  • x (numpy.ndarray) – Full spacecraft state vector.

  • os (Orbital_State) – Orbital state.

  • dmode (ErrorMode or None) – Error mode controlling bias and noise application.

Returns:

Normalized attitude quaternion measurement.

Return type:

numpy.ndarray

output_length: int = 4
Parameters:
  • sample_time (float)

  • bias (Bias)

  • noise (Noise)

  • estimate_bias (bool)

  • boresight (ndarray)

  • fov (float)

  • sun_exclusion (float)

  • min_stars (int)

  • star_catalog (StarCatalog | None)