C++ Module: MJSystemCoM
Executive Summary
The MJSystemCoM module extracts the total system CoM position and velocity
from a MuJoCo scene with a single spacecraft. For variable-mass bodies, the
reported velocity is the time derivative of the reported center-of-mass
position,
The second term is read from each body’s
derivativeMassPropertiesInMsg. It is a mass-property bookkeeping term,
not an additional generalized force in the MuJoCo equations of motion.
Message Connection Descriptions
The following table lists all the module input and output messages. The module msg connection 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 |
|---|---|---|
comStatesOutMsg |
spacecraft CoM states C++ output msg |
|
comStatesOutMsgC |
spacecraft CoM states C output msg |
User Guide
This section is to outline the steps needed to setup the MJSystemCoM module in Python using Basilisk.
Import the MJSystemCoM class:
from Basilisk.simulation import MJSystemCoM
Enable extra EOM call when building the MuJoCo scene:
scene.extraEoMCall = True
Create an instance of MJSystemCoM:
module = MJSystemCoM.MJSystemCoM()
Set the scene the module is attached to:
module.scene = scene
The MJSystemCoM output message is
comStatesOutMsg.Add the module to the MuJoCo scene dynamics task:
scene.AddModelToDynamicsTask(module)
-
class MJSystemCoM : public SysModel
- #include <MJSystemCoM.h>
This is a C++ module to extract the system CoM position and velocity from Mujoco.
Public Functions
-
MJSystemCoM()
This is the constructor for the module class. It sets default variable values and initializes the various parts of the model
-
~MJSystemCoM() = default
-
void SelfInit()
Initialize C-wrapped output messages
-
void Reset(uint64_t CurrentSimNanos)
This method is used to reset the module and checks that required input messages are connect.
-
void UpdateState(uint64_t CurrentSimNanos)
This extracts the total spacecraft CoM position and velocity
Public Members
-
Message<SCStatesMsgPayload> comStatesOutMsg
spacecraft CoM states C++ output msg
-
SCStatesMsg_C comStatesOutMsgC = {}
spacecraft CoM states C output msg
-
BSKLogger bskLogger
BSK Logging.
-
MJSystemCoM()