Module: MJJointReactionForces

Executive Summary

The MJJointReactionForces module extracts the reaction forces and torques acting on the joints from the MuJoCo scene. It also indexes the kinematic tree, parent body, type, and starting degree-of-freedom for each joint.

Note

If a free joint is used as part of a kinematic tree, it must be used as the first joint of that tree.

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.

Module I/O Messages

Msg Variable Name

Msg Type

Description

reactionForcesOutMsg

MJJointReactionsMsgPayload

joint reaction forces and torques output msg

User Guide

This section is to outline the steps needed to setup the MJJointReactionForces module in Python using Basilisk.

  1. Import the MJJointReactionForces class:

    from Basilisk.simulation import MJJointReactionForces
    
  2. Enable extra EOM call when building the MuJoCo scene:

    scene.extraEoMCall = True
    
  3. Create an instance of MJJointReactionForces:

    module = MJJointReactionForces.MJJointReactionForces()
    
  4. Set the scene the module is attached to:

    module.scene = scene
    
  5. Add the module to the task list:

    unitTestSim.AddModelToTask(unitTaskName, module)
    

class MJJointReactionForces : public SysModel
#include <MJJointReactionForces.h>

This C++ module extracts the reaction forces and torques acting on the joints from a MuJoCo scene.

Public Functions

MJJointReactionForces() = default

This is the constructor for the module class.

~MJJointReactionForces() = default

This is the destructor for the module class.

void Reset(uint64_t CurrentSimNanos)

This method is used to reset the module and checks that scene is setup.

void UpdateState(uint64_t CurrentSimNanos)

This is the main method that gets called every time the module is updated. It is used to read the reaction forces and torques acting on the joints from the MuJoCo scene and write them to an output message.

Public Members

MJScene *scene = {nullptr}

pointer to the MuJoCo scene

Message<MJJointReactionsMsgPayload> reactionForcesOutMsg

joint reaction forces and torques output msg

BSKLogger bskLogger

BSK Logging.

Private Members

std::size_t nDOF = 0

number of total DOF

std::vector<int> jointTreeIdx

list of the kinematic tree index for each joint

std::vector<int> jointParentBodyIdx

list of the parent body index for each joint

std::vector<int> jointTypes

list of joint types in the system

std::vector<int> jointDOFStart

list of the starting DOF index for each joint