Table Of Contents

Search

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

simulation module

Simulation module for attitude determination and control system.

This module forms the core of the simulation engine and utilizes the classes and functions written elsewhere to model the system and perform numerical integration.

simulation.derivatives_func(t, x, satellite, nominal_state_func, perturbations_func, position_velocity_func, delta_t)

Computes the derivative of the spacecraft state

Parameters:
  • t (float) – the time (in seconds)
  • x (numpy ndarray) – the state (10x1) where the elements are: [0, 1, 2, 3]: the quaternion describing the spacecraft attitude [4, 5, 6]: the angular velocity of the spacecraft [7, 8, 9]: the angular velocities of the reaction wheels
  • satellite (Spacecraft) – the Spacecraft object that represents the satellite being modeled
  • nominal_state_func (function) – the function that should compute the nominal attitude (in DCM form) and angular velocity; its header must be (t)
  • perturbations_func (function) – the function that should compute the perturbation torques (N * m); its header must be (satellite)
  • position_velocity_func (function) – the function that should compute the position and velocity; its header must be (t)
  • delta_t (float) – the time between user-defined integrator steps (not the internal/adaptive integrator steps) in seconds
Returns:

the derivative of the state (10x1) with respect to time

Return type:

numpy ndarray

simulation.simulate_adcs(satellite, nominal_state_func, perturbations_func, position_velocity_func, start_time=0, delta_t=1, stop_time=6000, verbose=False)

Simulates an attitude determination and control system over a period of time

Parameters:
  • satellite (Spacecraft) – the Spacecraft object that represents the satellite being modeled
  • nominal_state_func (function) – the function that should compute the nominal attitude (in DCM form) and angular velocity; its header must be (t)
  • perturbations_func (function) – the function that should compute the perturbation torques (N * m); its header must be (satellite)
  • position_velocity_func (function) – the function that should compute the position and velocity; its header must be (t)
  • start_time (float, optional) – Defaults to 0. The start time of the simulation in seconds
  • delta_t (float, optional) – Defaults to 1. The time between user-defined integrator steps (not the internal/adaptive integrator steps) in seconds
  • stop_time (float, optional) – Defaults to 6000. The end time of the simulation in seconds
  • verbose (bool, optional) – integrator output to the console while running.
Returns:

a dictionary of simulation results. Each value is an NxM numpy

ndarray where N is the number of time steps taken and M is the size of the data being represented at that time (M=1 for time, 3 for angular velocity, 4 for quaternion, etc.) Contains:

  • times (numpy ndarray): the times of all associated data
  • q_actual (numpy ndarray): actual quaternion
  • w_actual (numpy ndarray): actual angular velocity
  • w_rxwls (numpy ndarray): angular velocity of the reaction
    wheels
  • DCM_estimated (numpy ndarray): estimated DCM
  • w_estimated (numpy ndarray): estimated angular velocity
  • DCM_desired (numpy ndarray): desired DCM
  • w_desired (numpy ndarray): desired angular velocity
  • attitude_err (numpy ndarray): attitude error
  • attitude_rate_err (numpy ndarray): attitude rate error
  • M_ctrl (numpy ndarray): control torque
  • M_applied (numpy ndarray): applied control torque
  • w_dot_rxwls (numpy ndarray): angular acceleration of
    reaction wheels
  • M_perturb (numpy ndarray): sum of perturbation torques
  • positions (numpy ndarray): inertial positions
  • velocities (numpy ndarray): inertial velocities

Return type:

dict

simulation.simulate_estimation_and_control(t, satellite, nominal_state_func, delta_t, log=False)

Simulates attitude estimation and control for derivatives calculation

Parameters:
  • t (float) – the time (in seconds)
  • satellite (Spacecraft) – the Spacecraft object that represents the satellite being modeled
  • nominal_state_func (function) – the function that should compute the nominal attitude (in DCM form) and angular velocity; its header must be (t)
  • perturbations_func (function) – the function that should compute the perturbation torques (N * m); its header must be (t, q, w)
  • 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)

dict: a dictionary containing results logged for this simulation step;
Contains:
  • DCM_estimated (numpy ndarray): estimated DCM
  • w_estimated (numpy ndarray): estimated angular velocity
  • DCM_desired (numpy ndarray): desired DCM
  • w_desired (numpy ndarray): desired angular velocity
  • attitude_err (numpy ndarray): attitude error
  • attitude_rate_err (numpy ndarray): attitude rate error
  • M_ctrl (numpy ndarray): control torque
  • M_applied (numpy ndarray): applied control torque
  • w_dot_rxwls (numpy ndarray): angular acceleration of
    reaction wheels

Return type:

numpy ndarray

Scroll To Top