ADCS.helpers.plotting.animate_estimator module

ADCS.helpers.plotting.animate_estimator.animate_attitude(time, state_hist=None, est_state_hist=None, os_hist=None, boresight_goal_hist=None)[source]

Animate spacecraft attitude, estimated attitude, environment vectors, and boresight goals in 3D.

UPDATED boresight_goal_hist:
  • Nx3 legacy: [gx, gy, gz] (ECI) -> draw vector

  • Nx4 mixed:
    • [nan, gx, gy, gz] -> draw vector

    • [q0, q1, q2, q3] -> draw target body axes (Body->ECI)

Parameters:
  • time (ndarray)

  • state_hist (ndarray | None)

  • est_state_hist (ndarray | None)

  • os_hist (List | None)

  • boresight_goal_hist (ndarray | None)

Return type:

None

ADCS.helpers.plotting.animate_estimator.rot_mat(q)[source]

Construct the direction cosine matrix (DCM) corresponding to a quaternion using the Hamilton quaternion convention.

The returned matrix performs a rotation from the body frame to the inertial (ECI) frame, such that

\[\mathbf{v}_{\mathrm{ECI}} = \mathbf{R}(\mathbf{q})\,\mathbf{v}_{\mathrm{body}}\]

where the quaternion is defined as

\[\mathbf{q} = \begin{bmatrix} q_0 & q_1 & q_2 & q_3 \end{bmatrix}^\mathsf{T}\]

with scalar-first ordering.

The rotation matrix is explicitly given by

\[\begin{split}\mathbf{R}(\mathbf{q}) = \begin{bmatrix} q_0^2+q_1^2-q_2^2-q_3^2 & 2(q_1q_2-q_0q_3) & 2(q_1q_3+q_0q_2) \\ 2(q_1q_2+q_0q_3) & q_0^2-q_1^2+q_2^2-q_3^2 & 2(q_2q_3-q_0q_1) \\ 2(q_1q_3-q_0q_2) & 2(q_2q_3+q_0q_1) & q_0^2-q_1^2-q_2^2+q_3^2 \end{bmatrix}\end{split}\]
Parameters:

q (numpy.ndarray) – Unit quaternion in Hamilton form [q0, q1, q2, q3].

Returns:

Direction cosine matrix mapping body-frame vectors to inertial frame.

Return type:

numpy.ndarray