C++ Module: MJQuaternionStatePolicy
These immutable policies connect MuJoCo quaternion states to the generic integrator.
Both store scalar-first quaternions with shape 4 x 1 and apply 3 x 1 angular
diffusion tangents through MuJoCo’s exponential-map update.
MJNativeQuaternionStatePolicy also uses a 3 x 1 body-rate drift.
MJHighOrderQuaternionStatePolicy uses a 4 x 1 quaternion derivative, adds the
weighted derivative to the base, and normalizes the candidate. MJJoint selects
the policy during registration according to the scene’s attitude-integration setting.
Changing that setting after topology is established is not permitted.
The registry owns each policy. Repeated registration compares policy topology by value, and integrator descriptors borrow the committed policy. See Dynamics state and integrator architecture for joint layout and stage evaluation.
-
class MJNativeQuaternionStatePolicy : public StateUpdatePolicy
- #include <MJQuaternionStatePolicy.h>
MuJoCo exponential-map update for a scalar-first quaternion. State shape is 4x1; drift and diffusion tangents are 3x1 body angular increments. Drift construction starts from the supplied base and calls MuJoCo’s quaternion integration rule. Ordered noise increments use the same rule in place. The registry owns the stateless policy and compares its concrete type on Reset.
Public Functions
-
bool topologyEquals(const StateUpdatePolicy &other) const override
Accept another native quaternion policy as the same immutable topology.
-
void validate(const StateSpec &spec) const override
Require 4x1 state, 3x1 drift/tangent, and special-policy dispatch.
-
void buildDriftCandidate(ConstMatrixView base, ConstMatrixView combinedDrift, double timeStep, MutableMatrixView output) const override
Exponentiate the weighted body-rate drift from the base quaternion.
-
void applyNoiseIncrement(MutableMatrixView state, ConstMatrixView diffusionTangent, double pseudoStep) const override
Apply one angular diffusion increment through the exponential map.
-
bool topologyEquals(const StateUpdatePolicy &other) const override
-
class MJHighOrderQuaternionStatePolicy : public StateUpdatePolicy
- #include <MJQuaternionStatePolicy.h>
RK update using a four-component quaternion derivative, followed by normalization. State and drift shapes are 4x1. Diffusion remains a 3x1 angular tangent and uses MuJoCo’s exponential-map update.
Public Functions
-
bool topologyEquals(const StateUpdatePolicy &other) const override
Accept another high-order quaternion policy as the same immutable topology.
-
void validate(const StateSpec &spec) const override
Require 4x1 state/drift, 3x1 tangent, and special-policy dispatch.
-
void buildDriftCandidate(ConstMatrixView base, ConstMatrixView combinedDrift, double timeStep, MutableMatrixView output) const override
Add the weighted quaternion derivative and normalize the result.
-
void applyNoiseIncrement(MutableMatrixView state, ConstMatrixView diffusionTangent, double pseudoStep) const override
Apply one angular diffusion increment through the exponential map.
-
bool topologyEquals(const StateUpdatePolicy &other) const override