Skip to content

API

Attitude

Attitude module.

This module provides the Attitude class, a wrapper around scipy's Spherical Linear Interpolation (SLERP) for smooth attitude interpolation. The attitude can be initialized from reference frames, quaternions, or Euler angles, and supports interpolation at arbitrary times within the defined domain.

Key Components

  • Attitude: Main class for attitude interpolation using SLERP.

    • Initialized with reference frames (N, 3, 3) and corresponding times
    • Supports interpolation via evaluate(time) method
    • Properties: reference_frames, times, domain
  • Factory methods for creating Attitude from different representations:

    • from_quaternions: Create from scalar-last quaternions (N, 4)
    • from_euler_angles: Create from yaw-pitch-roll angles (N, 3) with specified rotation order
  • Utility functions for computing attitude from sensor data:

    • compute_antenna_attitude_from_euler_angles: antenna attitude from Euler angles relative to sensor local axis
    • compute_sensor_attitude_from_state_vectors: sensor attitude directly from position/velocity vectors

All attitude reference frames are expressed as (N, 3, 3) matrices. The reference frame system is preserved through interpolation (e.g., ECEF input yields ECEF output).

Attributes

T module-attribute

Python
T = TypeVar('T', bound=np.generic)

__all__ module-attribute

Python
__all__ = ['Attitude', 'compute_antenna_attitude_from_euler_angles', 'compute_sensor_attitude_from_state_vectors']

Classes

Attitude

Bases: Generic[T]

Attitude based on a Spherical Linear Interpolation of Rotations (SLERP).

Attributes

reference_frames property
Python
reference_frames: NDArray[floating]

Attitude reference frames used for interpolation.

times property
Python
times: NDArray[T]

Attitude times vector.

domain property
Python
domain: tuple[T, T]

Attitude time domain.

Methods:

__init__
Python
__init__(reference_frames: NDArray[floating], times: NDArray[T]) -> None

Create an Attitude SLERP interpolator from times and attitude reference frames.

Time axis can be specified as relative or absolute (actual dates).

Attitude reference frames must be expressed as an array with shape (N, 3, 3), with N being the same length as the times array.

Parameters:

Name Type Description Default
reference_frames NDArray[floating]

array of attitude reference frames expressed in a reference System (i.e. ECEF), with shape (N, 3, 3) the interpolated reference frames will be in the same reference system of the input reference frames.

required
times NDArray[T]

relative or absolute (actual dates) time axis, monotonic increasing, with shape (N,) interpolation times must be of the same type as the initialization times axis

required
evaluate
Python
evaluate(time: T | NDArray[T]) -> npt.NDArray[np.floating]

Retrieve attitude reference frame at given times.

Parameters:

Name Type Description Default
time T | NDArray[T]

time of the same type of the initialization times axis. Can be a scalar or an array of shape (M,)

required

Returns:

Type Description
NDArray[floating]

interpolated attitude reference frame at each input time as a numpy array with shape (3, 3) or (M, 3, 3) depending on the input time shape. The interpolated reference frames are expressed in the same reference system of the input reference frames

from_quaternions classmethod
Python
from_quaternions(quaternions: NDArray[floating], times: NDArray[T]) -> Attitude

Create an Attitude from quaternions.

Time axis can be specified as relative or absolute (actual dates), while quaternions must be expressed as an array with shape (N, 4), with N being the same length as the times array.

Reference frame consistency

The reference frame in which quaternions are provided is kept as the reference frame of the interpolator, so the interpolated reference frames will be in the same reference system of the input quaternions.

For example, if the quaternions are defined as rotations from ECEF to the antenna reference frame, the interpolated reference frames will be in ECEF as well.

Parameters:

Name Type Description Default
quaternions NDArray[floating]

quaternions, scalar-last, with shape (N, 4)

required
times NDArray[T]

relative or absolute (actual dates) time axis, monotonic increasing, with shape (N,)

required

Returns:

Type Description
Attitude

interpolator object

from_euler_angles classmethod
Python
from_euler_angles(euler_angles_rad: NDArray[floating], rotation_order: RotationOrder, times: NDArray[T]) -> Attitude

Create an Attitude from euler angles.

Time axis can be specified as relative or absolute (actual dates).

Euler angles must be expressed in radians as an array with shape (N, 3), with N being the same length as the times array. The first column of the euler angles is the yaw, the second is the pitch and the third is the roll, but the order of application of the rotations is defined by the rotation_order parameter.

Reference frame consistency

The reference frame in which euler angles are provided is kept as the reference frame of the interpolator, so the interpolated reference frames will be in the same reference system of the input euler angles.

For example, if the euler angles are defined as rotations from sensor local axis to the antenna reference frame, the interpolated reference frames will be defined in the sensor local frame.

In such a case, if you need the antenna reference frames in a global reference system (i.e. ECEF), an additional change of coordinates from the sensor local frame to a global reference system (i.e. ECEF) will be needed to get the attitude reference frames in the global reference system. In this case, you can use the compute_antenna_attitude_from_euler_angles function to directly compute the overall attitude of the system in the same reference system of the sensor local axis.

Parameters:

Name Type Description Default
euler_angles_rad NDArray[floating]

euler angles in radians, with shape (N, 3). The first column of the euler angles is the yaw, the second is the pitch and the third is the roll, but the order of application of the rotations is defined by the rotation_order parameter. The interpolated reference frames will be in the same reference system of the input euler angles.

required
rotation_order RotationOrder

order of application of the rotations defined by the euler angles. values are: "YPR", "YRP", "PYR", "PRY", "RYP", "RPY"

required
times NDArray[T]

relative or absolute (actual dates) time axis, monotonic increasing, with shape (N,)

required

Returns:

Type Description
Attitude

interpolator object

Functions:

compute_antenna_attitude_from_euler_angles

Python
compute_antenna_attitude_from_euler_angles(ypr_rad: NDArray[floating], rotation_order: RotationOrder, times: NDArray[T], sensor_local_axis: NDArray[floating]) -> Attitude

Compute the attitude of an antenna from euler angles and sensor local axis.

Euler angles must be expressed in radians as an array with shape (N, 3), with N being the same length as the times array. The first column of the euler angles is the yaw, the second is the pitch and the third is the roll, but the order of application of the rotations is defined by the rotation_order parameter.

The sensor local axis must be expressed as an array with shape (3, 3) or (N, 3, 3) representing the reference frame of the sensor.

Reference frame consistency

The reference frame in which the sensor local axis is provided is kept as the reference frame of the interpolator, so the interpolated reference frames will be in the same reference system of the input sensor local axis.

The euler angles are assumed to be defined as rotations from the sensor local axis to the antenna reference frame.

For example, if the sensor local axis is defined in ECEF, the antenna attitude will be in ECEF as well.

Parameters:

Name Type Description Default
ypr_rad NDArray[floating]

euler angles in radians, with shape (N, 3). The first column of the euler angles is the yaw, the second is the pitch and the third is the roll, but the order of application of the rotations is defined by the rotation_order parameter.

required
rotation_order RotationOrder

order of application of the rotations defined by the euler angles. values are: "YPR", "YRP", "PYR", "PRY", "RYP", "RPY"

required
times NDArray[T]

relative or absolute (actual dates) time axis, monotonic increasing, with shape (N,)

required
sensor_local_axis NDArray[floating]

reference frame of the sensor, with shape (3, 3) or (N, 3, 3). The Attitude reference frames will be defined in the same reference system as the input sensor local axis.

required

Returns:

Type Description
Attitude

interpolator object

compute_sensor_attitude_from_state_vectors

Python
compute_sensor_attitude_from_state_vectors(position: NDArray[floating], velocity: NDArray[floating], times: NDArray[T], reference_frame: ReferenceFrame) -> Attitude

Compute the attitude of a sensor from its state vectors.

The sensor local axis is computed from the state vectors and the specified reference frame, and then the attitude is created with the sensor local axis as reference frame.

Reference frame consistency

The reference frame in which the position and the velocities are provided is kept as the reference frame of the attitude, so the interpolated reference frames will be in the same reference system as the input state vectors.

For example, if the state vectors are defined in ECEF, the sensor attitude will be in ECEF as well.

Parameters:

Name Type Description Default
position NDArray[floating]

position state vectors of the sensor, with shape (N, 3)

required
velocity NDArray[floating]

velocity state vectors of the sensor, with shape (N, 3)

required
times NDArray[T]

relative or absolute (actual dates) time axis, monotonic increasing, with shape (N,)

required
reference_frame ReferenceFrame

kind of reference frame to compute. The options are: "GEOCENTRIC", "GEODETIC" and "ZERODOPPLER".

required

Returns:

Type Description
Attitude

interpolator object