Module: vscmgStateEffector
Executive Summary
This dynamic effector class implements a variable speed control moment gyroscope or VSCMG device.
The module
PDF Description
contains further information on this module’s function,
how to run it, as well as testing.
Message Connection Descriptions
The following table lists all the module input and output messages. The module msg variable name is set by the user from python. The msg type contains a link to the message structure definition, while the description provides information on what this message is used for.
Msg Variable Name |
Msg Type |
Description |
---|---|---|
cmdsInMsg |
motor torque command input message |
|
speedOutMsg |
VSCMG speed output message |
|
vscmgOutMsgs |
vector of VSCMG output messages |
User Guide
This section is to outline the steps needed to setup a VSCMG State Effector in Python using Basilisk.
Import the vscmgStateEffector class:
from basilisk.simulation import vscmgStateEffector
create a default VSCMG function:
def defaultVSCMG(): VSCMG = messaging.VSCMGConfigMsgPayload() VSCMG.rGB_B = [[0.],[0.],[0.]] VSCMG.gsHat0_B = [[0.],[0.],[0.]] VSCMG.gtHat0_B = [[0.],[0.],[0.]] VSCMG.ggHat_B = [[0.],[0.],[0.]] VSCMG.u_s_max = -1 VSCMG.u_s_min = -1 VSCMG.u_s_f = 0. VSCMG.wheelLinearFrictionRatio = -1 VSCMG.u_g_current = 0. VSCMG.u_g_max = -1 VSCMG.u_g_min = -1 VSCMG.u_g_f = 0. VSCMG.gimbalLinearFrictionRatio = -1 VSCMG.Omega = 0. VSCMG.gamma = 0. VSCMG.gammaDot = 0. VSCMG.Omega_max = 6000. * macros.RPM VSCMG.gammaDot_max = -1 VSCMG.IW1 = 100./VSCMG.Omega_max VSCMG.IW2 = 0.5*VSCMG.IW1 VSCMG.IW3 = 0.5*VSCMG.IW1 VSCMG.IG1 = 0.1 VSCMG.IG2 = 0.2 VSCMG.IG3 = 0.3 VSCMG.U_s = 4.8e-06 * 1e4 VSCMG.U_d = 1.54e-06 * 1e4 VSCMG.l = 0.01 VSCMG.L = 0.1 VSCMG.rGcG_G = [[0.0001],[-0.02],[0.1]] VSCMG.massW = 6. VSCMG.massG = 6. VSCMG.VSCMGModel = 0 return VSCMG
Create a list to store the VSCMGs:
VSCMGs = []
Create a VSCMG and append it to the list:
VSCMGs.append(defaultVSCMG())
(Optional) Adjust the VSCMG parameters:
VSCMGs[0].gsHat0_B = [[1.0], [0.0], [0.0]] VSCMGs[0].gtHat0_B = [[0.0], [1.0], [0.0]] VSCMGs[0].ggHat_B = [[0.0], [0.0], [1.0]] VSCMGs[0].Omega = 2000 * macros.RPM VSCMGs[0].gamma = 0. VSCMGs[0].gammaDot = 0.06 VSCMGs[0].rGB_B = [[0.1], [0.002], [-0.02]]
(Optional) Create additional VSCMGs and append them to the list:
ang = 54.75 * np.pi/180 VSCMGs.append(defaultVSCMG()) VSCMGs[1].gsHat0_B = [[0.0], [1.0], [0.0]] VSCMGs[1].ggHat_B = [[math.cos(ang)], [0.0], [math.sin(ang)]] VSCMGs[1].gtHat0_B = np.cross(np.array([math.cos(ang), 0.0, math.sin(ang)]),np.array([0.0, 1.0, 0.0])) VSCMGs[1].Omega = 350 * macros.RPM VSCMGs[1].gamma = 0. VSCMGs[1].gammaDot = 0.011 VSCMGs[1].rGB_B = [[0.0], [-0.05], [0.0]] VSCMGs.append(defaultVSCMG()) VSCMGs[2].gsHat0_B = [[0.0], [-1.0], [0.0]] VSCMGs[2].ggHat_B = [[-math.cos(ang)], [0.0], [math.sin(ang)]] VSCMGs[2].gtHat0_B = np.cross(np.array([-math.cos(ang), 0.0, math.sin(ang)]),np.array([0.0, -1.0, 0.0])) VSCMGs[2].Omega = -900 * macros.RPM VSCMGs[2].gamma = 0. VSCMGs[2].gammaDot = -0.003 VSCMGs[2].rGB_B = [[-0.1], [0.05], [0.05]]
- Create an instantiation of the VSCMGs::
vscmgStateEffector = vscmgStateEffector.VSCMGStateEffector()
Add the VSCMGs to the vscmgStateEffector:
for item in VSCMGs: vscmgStateEffector.AddVSCMG(item)
The VSCMG angular states output message is
speedOutMsg
.The configuration of the VSCMG is created using an output vector of messages
vscmgOutMsgs
.Add the effector to your spacecraft:
scObject.addStateEffector(vscmgStateEffector) See :ref:`spacecraft` documentation on how to set up a spacecraft object.
Create the VSCMG torque command input message:
cmdArray = messaging.VSCMGArrayTorqueMsgPayload()
Set the torque command for each VSCMG in the array:
cmdArray.wheelTorque = [0.0, 0.0, 0.0] # [Nm] cmdArray.gimbalTorque = [0.0, 0.0, 0.0] # [Nm]
Write the command message:
cmdMsg = messaging.VSCMGArrayTorqueMsg().write(cmdArray)
Subscribe the vscmgStateEffector to the command message:
vscmgStateEffector.cmdsInMsg.subscribeTo(cmdMsg)
Add the module to the task list:
unitTestSim.AddModelToTask(unitTaskName, vscmgStateEffector)
-
class VSCMGStateEffector : public SysModel, public StateEffector
- #include <vscmgStateEffector.h>
VSCMG state effector class.
Public Functions
-
VSCMGStateEffector()
-
~VSCMGStateEffector()
-
void registerStates(DynParamManager &states)
-
void linkInStates(DynParamManager &states)
-
void updateEffectorMassProps(double integTime)
-
void Reset(uint64_t CurrentSimNanos)
Reset the module to origina configuration values.
-
void AddVSCMG(VSCMGConfigMsgPayload *NewVSCMG)
This method allows VSCMG devices to be added to this effector
- Parameters:
NewVSCMG – VSCMG device to be added
-
void UpdateState(uint64_t CurrentSimNanos)
This method is the main cyclical call for the scheduled part of the VSCMG dynamics model. It reads the current commands array and sets the VSCMG configuration data based on that incoming command set. Note that the main dynamical method (ComputeDynamics()) is not called here and is intended to be called from the dynamics plant in the system
- Parameters:
CurrentSimNanos – The current simulation time in nanoseconds
-
void WriteOutputMessages(uint64_t CurrentClock)
This method is here to write the output message structure into the specified message.
- Parameters:
CurrentClock – The current time used for time-stamping the message
-
void ReadInputs()
This method is used to read the incoming command message and set the associated command structure for operating the VSCMGs.
-
void ConfigureVSCMGRequests(double CurrentTime)
This method is used to read the new commands vector and set the VSCMG torque commands appropriately. It assumes that the ReadInputs method has already been run successfully.
- Parameters:
CurrentTime – The current simulation time converted to a double
-
void updateContributions(double integTime, BackSubMatrices &backSubContr, Eigen::Vector3d sigma_BN, Eigen::Vector3d omega_BN_B, Eigen::Vector3d g_N)
[-] Back-sub contributions
Public Members
-
std::vector<VSCMGConfigMsgPayload> VSCMGData
[-] VSCMG data structure
-
ReadFunctor<VSCMGArrayTorqueMsgPayload> cmdsInMsg
[-] motor torque command input message
-
Message<VSCMGSpeedMsgPayload> speedOutMsg
[-] VSCMG speed output message
-
std::vector<Message<VSCMGConfigMsgPayload>*> vscmgOutMsgs
[-] vector of VSCMG output messages
-
std::vector<VSCMGCmdMsgPayload> newVSCMGCmds
[-] Incoming torque commands
-
VSCMGSpeedMsgPayload outputStates
[-] Output data from the VSCMGs
-
std::string nameOfVSCMGOmegasState
[-] identifier for the Omegas state data container
-
std::string nameOfVSCMGThetasState
[-] identifier for the Thetas state data container
-
std::string nameOfVSCMGGammasState
[-] identifier for the Gammas state data container
-
std::string nameOfVSCMGGammaDotsState
[-] identifier for the GammaDots state data container
-
int numVSCMG
[-] number of VSCMGs
-
int numVSCMGJitter
[-] number of VSCMGs with jitter
-
BSKLogger bskLogger
[-] BSK Logging
Private Members
-
VSCMGArrayTorqueMsgPayload incomingCmdBuffer
[-] One-time allocation for savings
-
uint64_t prevCommandTime
[-] Time for previous valid thruster firing
-
VSCMGStateEffector()