C++ Module: twoHingeDamper
twoHingeDamper
Executive Summary
The TwoHingeDamper module converts the position and rates of a
two-hinge spherical pendulum into the generalized torques produced by an
isotropic Cartesian damper at the bob. For rod length \(L\) and Cartesian
damping coefficient \(d\), set dampingCoeff to \(dL^2\).
For a phi rotation followed by a theta rotation, the module writes
Connecting the outputs to motors on the two joints applies equal and opposite torques to the parent and child bodies.
Module Assumptions and Limitations
The first input coordinate is the pendulum’s phi hinge and the second is
its theta hinge. The damping law assumes a rod direction formed by a
phi rotation followed by a theta rotation, with both hinge axes
intersecting at the pendulum pivot. Both coordinates must therefore be
rotational hinge joints; translational slide joints are not supported.
dampingCoeff has units of N m s and represents \(dL^2\), where
\(d\) is the isotropic Cartesian damping coefficient at the bob and
\(L\) is the rod length. The three input messages must be linked before
the module is reset.
Message Connection Descriptions
Msg Variable Name |
Msg Type |
Description |
|---|---|---|
thetaInMsg |
Second hinge position \(\theta\). |
|
phiDotInMsg |
First hinge rate \(\dot\phi\). |
|
thetaDotInMsg |
Second hinge rate \(\dot\theta\). |
|
phiTorqueOutMsg |
Generalized damping torque for the first hinge. |
|
thetaTorqueOutMsg |
Generalized damping torque for the second hinge. |
User Guide
Set dampingCoeff, connect the three scalar-joint state messages, and route
the two output messages to actuators on the corresponding joints. For MuJoCo
models, applyTo performs this wiring and creates the two internal torque
actuators:
damper = twoHingeDamper.TwoHingeDamper()
damper.ModelTag = "pendulumDamper"
damper.dampingCoeff = cartesianDamping*rodLength**2
phiActuator, thetaActuator = damper.applyTo(phiJoint, thetaJoint)
scene.AddModelToDynamicsTask(damper)
Call applyTo after constructing the MJScene and retrieving
the two hinge joints, but before initializing the simulation. Both joints must
belong to the same scene. The returned actuators remain owned by that scene.
-
class TwoHingeDamper : public SysModel
- #include <twoHingeDamper.h>
Generalized damping for a two-hinge spherical pendulum.
For the rod direction obtained by a phi rotation followed by a theta rotation, isotropic Cartesian damping at the bob gives
Q_phi = -c cos(theta)^2 phiDot Q_theta = -c thetaDot.
The output messages are intended for motors on the corresponding MuJoCo joints, which apply each torque as an internal parent-child pair.
Public Functions
-
void Reset(uint64_t CurrentSimNanos) override
Validate the input message links and the damping coefficient.
- Parameters:
CurrentSimNanos – Current simulation time in nanoseconds.
-
void UpdateState(uint64_t CurrentSimNanos) override
Write both hinge damping torques for the current joint state.
- Parameters:
CurrentSimNanos – Current simulation time in nanoseconds.
Public Members
-
double dampingCoeff = {0.0}
[N*m*s] Cartesian damping coefficient times rod length squared
-
ReadFunctor<ScalarJointStateMsgPayload> thetaInMsg
[rad] theta joint position
-
ReadFunctor<ScalarJointStateMsgPayload> phiDotInMsg
[rad/s] phi joint rate
-
ReadFunctor<ScalarJointStateMsgPayload> thetaDotInMsg
[rad/s] theta joint rate
-
Message<SingleActuatorMsgPayload> phiTorqueOutMsg
[N*m] phi-joint damping torque
-
Message<SingleActuatorMsgPayload> thetaTorqueOutMsg
[N*m] theta-joint damping torque
-
BSKLogger bskLogger
module logger
-
void Reset(uint64_t CurrentSimNanos) override