Module: scalarJointStatesToRWSpeed
Executive Summary
The scalarJointStatesToRWSpeed module is an adapter that converts a set of scalar joint state messages into a single
reaction wheel speed message. The module reads \(N\) input messages of type ScalarJointStateMsgPayload, each
containing a scalar joint rate \(\dot{\theta}_i\). At each update, the module
packs the joint rates into the output RWSpeedMsgPayload such that
where \(\Omega_i\) is the \(i\)-th reaction wheel speed in the output message. This supports using MuJoCo hinge joint rates (or any scalar joint rates) as inputs to Basilisk flight software that expects a reaction wheel speed message.
Message Connection Description
The following table lists the module input and output messages.
Msg Variable Name |
Msg Type |
Description |
|---|---|---|
jointStateInMsgs |
Vector of input messages containing the scalar joint states and rates |
|
rwSpeedOutMsg |
Output message containing the packed reaction wheel speeds |
Module Functions
Below is a list of functions that this simulation module performs
Reads all
ScalarJointStateMsginputsCopies each input joint rate into the corresponding element of the
RWSpeedMsgoutputWrites the packed
RWSpeedMsgoutput message each update cycle
Module Assumptions and Limitations
The mapping is order-preserving: input message index \(i\) maps to output wheel speed index \(i\)
The module uses the joint state from each input message
The module assumes \(N\) does not exceed the maximum wheel speed vector length supported by RWSpeedMsgPayload
Test Description and Success Criteria
The unit test for this module is defined in test_scalarJointStatesToRWSpeed.
The test initializes the module with a configurable number of joints \(N\) and drives each joint input message with
a distinct constant rate. The test passes if the output wheelSpeeds vector matches the expected values for every
index to within numerical tolerance.
-
class ScalarJointStatesToRWSpeed : public SysModel
- #include <scalarJointStatesToRWSpeed.h>
Adapter module that maps multiple ScalarJointStateMsg inputs directly into a single RWSpeedMsg output.
Public Functions
-
ScalarJointStatesToRWSpeed()
Default constructor.
-
explicit ScalarJointStatesToRWSpeed(uint32_t numJoints)
Constructor specifying number of joints.
- Parameters:
numJoints – Number of joint inputs.
-
~ScalarJointStatesToRWSpeed() override
Destructor.
-
void Reset(uint64_t CurrentSimNanos) override
Reset the module.
- Parameters:
CurrentSimNanos – Current simulation time [ns].
-
void UpdateState(uint64_t CurrentSimNanos) override
Read joint states and publish RW speed message.
- Parameters:
CurrentSimNanos – Current simulation time [ns].
-
void setNumJoints(uint32_t numJoints)
Set the number of joints.
- Parameters:
numJoints – Number of joints.
Public Members
-
std::vector<ReadFunctor<ScalarJointStateMsgPayload>> jointStateInMsgs
Joint state readers.
-
Message<RWSpeedMsgPayload> rwSpeedOutMsg
RW speed output.
-
BSKLogger bskLogger
BSK Logging.
Private Functions
-
void ensureSizes()
Ensure internal buffers are correctly sized.
Private Members
-
uint32_t numJoints
Number of joints.
-
ScalarJointStatesToRWSpeed()