Module: MJEquality
-
class MJEquality : public MJObject<mjsEquality>
- #include <MJEquality.h>
Represents a MuJoCo equality constraint.
This class provides functionality to manage an equality constraint in MuJoCo, allowing the constraint to be activated or deactivated as needed.
Subclassed by MJSingleJointEquality
Public Functions
-
inline MJEquality(mjsEquality *mjsequality, MJSpec &spec)
Constructs an MJEquality object with a given equality constraint.
- Parameters:
mjsequality – Pointer to the MuJoCo equality constraint.
spec – Reference to the
MJSpec
object where this equality is defined.
-
void setActive(bool active)
Sets the active state of the equality constraint.
- Parameters:
active – Boolean indicating whether the constraint should be active.
-
void setSolref(double val1, double val2)
Set the solref parameters for this equality constraint.
The solref attribute controls the reference acceleration that the solver tries to enforce. It can be specified in two formats:
Positive values: (timeconst, dampratio)
timeconst
: Time constant τ (seconds), must be ≥ 2x timestep.dampratio
: Damping ratio ζ, where 1.0 = critical damping.
Negative values: (-stiffness, -damping)
stiffness
: Direct stiffness constant (N/m).damping
: Direct damping constant (Ns/m).
See more in the MuJoCo documentation about “Solver parameters”.
Example usage:
eq.setSolref(0.05, 1.0); // time-constant / damping ratio form eq.setSolref(-1000, -5.0); // stiffness / damping form
- Parameters:
val1 – Either time constant (τ) or -stiffness depending on sign.
val2 – Either damping ratio (ζ) or -damping depending on sign.
-
void setSolimp(double d0, double dwidth, double width, double midpoint, double power)
Set the solimp parameters for this equality constraint.
The solimp attribute defines how the impedance d(r) varies with constraint violation r, allowing smooth, position-dependent stiffness/damping.
See more in the MuJoCo documentation about “Solver parameters”.
Example usage:
eq.setSolimp(0.9, 0.95, 0.001, 0.5, 2.0);
- Parameters:
d0 – Impedance at zero violation (0 < d0 < 1).
dwidth – Impedance at max violation width (0 < dwidth < 1).
width – Transition distance (positive scalar).
midpoint – Inflection point in [0, 1], relative to width.
power – Power ≥ 1, controls curve steepness.
-
inline MJEquality(mjsEquality *mjsequality, MJSpec &spec)
-
class MJSingleJointEquality : public MJEquality
- #include <MJEquality.h>
Represents an equality constraint applied to a 1-degree-of-freedom joint.
This equality can be used to enforce a specific state on said joint.
For revolute joints, this is the angle (in radians) of the joint with respect to its zero-pose.
For linear joints, this is the displacement (in meters) of the joint with respect to its zero-pose.
Public Functions
-
void setJointOffsetConstraint(double val)
Sets the value that the state of the joint should have.
- Parameters:
val – The value to apply to the joint constraint.
-
inline MJEquality(mjsEquality *mjsequality, MJSpec &spec)
Constructs an MJEquality object with a given equality constraint.
- Parameters:
mjsequality – Pointer to the MuJoCo equality constraint.
spec – Reference to the
MJSpec
object where this equality is defined.
-
void setJointOffsetConstraint(double val)