Table Of Contents

Search

Enter search terms or a module, class or function name.

spacecraft module

Spacecraft module for attitude determination and control system.

This module stores a number of composed objects that describe the overall spacecraft and its associated controller, gyros, etc. It is primarily used to simplify the process of passing parameters between methods, and it has aliases for a number of methods of its sub-objects for simplicity.

class spacecraft.Spacecraft(J=array([[100, 0, 0], [ 0, 100, 0], [ 0, 0, 100]]), controller=<controller.PDController object>, gyros=None, magnetometer=None, earth_horizon_sensor=None, actuators=<actuators.Actuators object>, dipole=array([0, 0, 0]), q=array([0, 0, 0, 1]), w=array([0, 0, 0]), r=array([0, 0, 0]), v=array([0, 0, 0]))

Bases: object

A class to store system objects and state over time

Parameters:
  • J (numpy ndarray) – the spacecraft’s inertia tensor (3x3) (kg * m^2)
  • controller (PDController) – the controller that will compute control torques to meet desired pointing and angular velocity requirements
  • gyros (Gyros) – an object that models gyroscopes and simulates estimated angular velocity by introducing bias and noise to angular velocity measurements
  • actuators (Actuators) – an object that stores reaction wheel state and related methods; actually applies control torques generated by the controller object
  • dipole (numpy ndarray) – the spacecraft’s residual magnetic dipole vector (A * m^2)
  • q (numpy ndarray) – the quaternion representing the attitude (from the inertial to body frame) of the spacecraft (at a given time)
  • w (numpy ndarray) – the angular velocity (rad/s) (3x1) in body coordinates of the spacecraft (at a given time)
  • r (numpy ndarray) – the inertial position of the spacecraft (m)
  • v (numpy ndarray) – the inertial velocity of the spacecraft (m/s)
J

numpy ndarray – the spacecraft’s inertia tensor (3x3) (kg * m^2)

controller

PDController – the controller that will compute control torques to meet desired pointing and angular velocity requirements

gyros

Gyros – an object that models gyroscopes and simulates estimated angular velocity by introducing bias and noise to angular velocity measurements

actuators

Actuators – an object that stores reaction wheel state and related methods; actually applies control torques generated by the controller object

dipole

numpy ndarray – the spacecraft’s residual magnetic dipole vector (A * m^2)

q

numpy ndarray – the quaternion representing the attitude (from the inertial to body frame) of the spacecraft (at a given time)

w

numpy ndarray – the angular velocity (rad/s) (3x1) in body coordinates of the spacecraft (at a given time)

r

numpy ndarray – the inertial position of the spacecraft (m)

v

numpy ndarray – the inertial velocity of the spacecraft (m/s)

apply_control_torques(M_ctrl, t, delta_t)

Wrapper method for Actuators.apply_control_torques

Parameters:
  • M_ctrl (numpy ndarray) – the control torque (3x1) produced by the PD controller (N * m)
  • w_sc (numpy ndarray) – the angular velocity (rad/s) (3x1) in body coordinates of the spacecraft (at a given time)
  • t (float) – the current simulation time in seconds
  • delta_t (float) – the time between user-defined integrator steps (not the internal/adaptive integrator steps) in seconds
Returns:

the control moment (3x1) as actually applied on

the reaction wheels (the input control torque with some Gaussian noise applied) (N * m)

numpy ndarray: the angular acceleration of the 3 reaction wheels

applied to achieve the applied torque (rad/s^2)

Return type:

numpy ndarray

approximate_gravity_gradient_torque()

Computes the gravity gradient torque acting on a spacecraft

Returns:
the gravity gradient torque acting on the spacecraft
coordinatized in the body frame
Return type:numpy ndarray
approximate_magnetic_field_torque()

Computes the magnetic field torque acting on a spacecraft

Returns:
the magnetic field torque acting on the spacecraft
coordinatized in the body frame
Return type:numpy ndarray
calculate_control_torques(attitude_err, attitude_rate_err)

Wrapper method for Controller.calculate_control_torques

Parameters:
  • attitude_err (numpy ndarray) – the attitude error (3x1) of the spacecraft at a given time
  • attitude_rate_err (numpy ndarray) – the attitude rate error (3x1) of the spacecraft at a given time
Returns:

the control torque (3x1) produced by the PD

controller (N * m) or [0, 0, 0] if there is no controller

Return type:

numpy ndarray

estimate_angular_velocity(t, delta_t)

Wrapper method for gyros.estimate_angular_velocity

Parameters:
  • t (float) – the current simulation time in seconds
  • delta_t (float) – the time between user-defined integrator steps (not the internal/adaptive integrator steps) in seconds
Returns:

the estimated angular velocity in rad/s

Return type:

numpy ndarray

estimate_attitude(t, delta_t)

Provides an estimated attitude (adding measurement noise to the actual)

This method uses the TRIAD algorithm to compute the attitude from two direction measurements.

Parameters:
  • t (float) – the current simulation time in seconds
  • delta_t (float) – the time between user-defined integrator steps (not the internal/adaptive integrator steps) in seconds
Returns:

the estimated DCM representing the attitude (from

the inertial to body frame) of the spacecraft (at a given time)

Return type:

numpy ndarray

Scroll To Top