Module: spacecraftPlus

This is an instantiation of the Module: dynamicObject abstract class that is a spacecraft with Module: stateEffector’s and Module: dynamicEffector’s attached to it. The spacecraftPlus allows for both translation and rotation. Module: stateEffector’s such as RWs, flexible solar panel, fuel slosh etc can be added to the spacecraft by attaching stateEffectors. Module: dynamicEffector’s such as thrusters, external force and torque, SRP etc can be added to the spacecraft by attaching dynamicEffectors. This class performs all of this interaction between stateEffectors, dynamicEffectors and the hub.

The module PDF Description contains further information on this module’s function, how to run it, as well as testing.


class SpacecraftPlus : public DynamicObject

Public Functions

SpacecraftPlus()

Constructor

This is the constructor, setting variables to default values

~SpacecraftPlus()

Destructor

This is the destructor, nothing to report here

void initializeDynamics()

This method initializes all of the dynamics and variables for the s/c

This method is used to initialize the simulation by registering all of the states, linking the dynamicEffectors, stateEffectors, and the hub, initialize gravity, and initialize the sim with the initial conditions specified in python for the simulation

void computeEnergyMomentum(double time)

This method computes the total energy and momentum of the s/c

This method is used to find the total energy and momentum of the spacecraft. It finds the total orbital energy, total orbital angular momentum, total rotational energy and total rotational angular momentum. These values are used for validation purposes.

void updateSCMassProps(double time)

This method computes the total mass properties of the s/c

This method is used to update the mass properties of the entire spacecraft using contributions from stateEffectors

void calcForceTorqueFromStateEffectors(double time, Eigen::Vector3d omega_BN_B)

This method computes the force and torque from the stateEffectors

This method is used to find the force and torque that each stateEffector is applying to the spacecraft. These values are held in the stateEffector class. Additionally, the stateDerivative value is behind the state values because they are calculated in the intergrator calls

void SelfInit()

Lets spacecraft plus create its own msgs

This method creates the messages for s/c output data and initializes the gravity field

void CrossInit()

Hook to tie s/c plus back into provided msgs

This method is used to cross link the messages and to initialize the dynamics

void writeOutputStateMessages(uint64_t clockTime)

Method to write all of the class output messages

This is the method where the messages of the state of vehicle are written

void UpdateState(uint64_t CurrentSimNanos)

Runtime hook back into Basilisk arch

This method is a part of sysModel and is used to integrate the state and update the state in the messaging system

void linkInStates(DynParamManager &statesIn)

Method to get access to the hub’s states.

This method allows the spacecraftPlus to have access to the current state of the hub for MRP switching, writing messages, and calculating energy and momentum

void equationsOfMotion(double integTimeSeconds)

This method computes the equations of motion for the whole system

This method is solving Xdot = F(X,t) for the system. The hub needs to calculate its derivatives, along with all of the stateEffectors. The hub also has gravity and dynamicEffectors acting on it and these relationships are controlled in this method. At the end of this method all of the states will have their corresponding state derivatives set in the dynParam Manager thus solving for Xdot

void integrateState(double time)

This method steps the state forward one step in time

This method is used to integrate the state forward in time, switch MRPs, calculate energy and momentum, and calculate the accumulated deltaV

void addStateEffector(StateEffector *newSateEffector)

Attaches a stateEffector to the system

This method attaches a stateEffector to the dynamicObject

void addDynamicEffector(DynamicEffector *newDynamicEffector)

Attaches a dynamicEffector

This method attaches a dynamicEffector to the dynamicObject

Public Members

uint64_t simTimePrevious

Previous simulation time

uint64_t numOutMsgBuffers

Number of output message buffers for I/O

std::string sysTimePropertyName

Name of the system time property

std::string scStateOutMsgName

Name of the state output message

std::string scMassStateOutMsgName

Name of the state output message

double totOrbEnergy

[J] Total orbital kinetic energy

double totRotEnergy

[J] Total rotational energy

double rotEnergyContr

[J] Contribution of stateEffector to total rotational energy

double orbPotentialEnergyContr

[J] Contribution of stateEffector to total rotational energy

double currTimeStep

[s] Time after integration, used for dvAccum calculation

double timePrevious

[s] Time before integration, used for dvAccum calculation

BackSubMatrices backSubContributions
Eigen::Vector3d sumForceExternal_N

[N] Sum of forces given in the inertial frame

Eigen::Vector3d sumForceExternal_B

[N] Sum of forces given in the body frame

Eigen::Vector3d sumTorquePntB_B

[N-m] Total torque about point B in B frame components

Eigen::MatrixXd *m_SC

[kg] spacecrafts total mass

Eigen::MatrixXd *mDot_SC

[kg/s] Time derivative of spacecrafts total mass

Eigen::MatrixXd *ISCPntB_B

[kg m^2] Inertia of s/c about point B in B frame components

Eigen::MatrixXd *c_B

[m] Vector from point B to CoM of s/c in B frame components

Eigen::MatrixXd *cPrime_B

[m/s] Body time derivative of c_B

Eigen::MatrixXd *cDot_B

[m/s] Inertial time derivative of c_B

Eigen::MatrixXd *ISCPntBPrime_B

[kg m^2/s] Body time derivative of ISCPntB_B

Eigen::MatrixXd *g_N

[m/s^2] Gravitational acceleration in N frame components

Eigen::MatrixXd *sysTime

[s] System time

Eigen::Vector3d dvAccum_B

[m/s] Accumulated delta-v of center of mass relative to inertial frame in body frame coordinates

Eigen::Vector3d dvAccum_BN_B

[m/s] accumulated delta-v of body frame relative to inertial frame in body frame coordinates

Eigen::Vector3d nonConservativeAccelpntB_B

[m/s/s] Current spacecraft body acceleration in the B frame

Eigen::Vector3d omegaDot_BN_B

[rad/s/s] angular acceleration of body wrt to N in body frame

Eigen::Vector3d totOrbAngMomPntN_N

[kg m^2/s] Total orbital angular momentum about N in N frame compenents

Eigen::Vector3d totRotAngMomPntC_N

[kg m^2/s] Total rotational angular momentum about C in N frame compenents

Eigen::Vector3d rotAngMomPntCContr_B

[kg m^2/s] Contribution of stateEffector to total rotational angular mom.

HubEffector hub

The spacecraft plus needs access to the spacecraft hub

GravityEffector gravField

Gravity effector for gravitational field experienced by spacecraft

std::vector<StateEffector*> states

Vector of state effectors attached to dynObject

std::vector<DynamicEffector*> dynEffectors

Vector of dynamic effectors attached to dynObject

BSKLogger bskLogger

BSK Logging

Private Members

StateData *hubR_N

State data accesss to inertial position for the hub

StateData *hubV_N

State data access to inertial velocity for the hub

StateData *hubOmega_BN_B

State data access to the attitude rate of the hub

StateData *hubSigma

State data access to sigmaBN for the hub

Eigen::MatrixXd *inertialPositionProperty

[m] r_N inertial position relative to system spice zeroBase/refBase

Eigen::MatrixXd *inertialVelocityProperty

[m] v_N inertial velocity relative to system spice zeroBase/refBase

int64_t scStateOutMsgId

Message ID for the outgoing spacecraft state

int64_t scMassStateOutMsgId

Message ID for the outgoing spacecraft mass state