Merge pull request #3156 from andrewkaufman:newton-schemas

PiperOrigin-RevId: 925328794
Change-Id: If45b8659ea9b88785660331bca5ee837ac172f67
This commit is contained in:
Copybara-Service
2026-06-02 07:06:59 -07:00
13 changed files with 635 additions and 116 deletions
@@ -43,12 +43,20 @@ class SdfAssetPath;
/// \class MjcPhysicsEqualityJointAPI
///
/// API providing extension attributes to represent equality/joint constraints.
/// This API is applied to a joint prim which acts as the constrained joint
/// (joint1 in MuJoCo terminology). The target relationship points to another
/// joint prim which is the reference joint (joint2 in MuJoCo terminology). The
/// constrained joint's position or angle is constrained to be a quartic
/// polynomial of the reference joint's position or angle. Only scalar joint
/// types (slide and hinge) can be used.
///
/// This API is applied to a joint prim which acts as the follower (joint0). The
/// leader joint (joint1) is specified via the newton:mimicJoint relationship
/// inherited from NewtonMimicAPI.
///
/// The follower's position or angle is constrained to be a quartic polynomial
/// of the leader's position or angle: joint0 = coef0 + coef1*(joint1) +
/// coef2*(joint1)^2 + coef3*(joint1)^3 + coef4*(joint1)^4
///
/// The constant (coef0) and linear (coef1) coefficients are provided by
/// NewtonMimicAPI as newton:mimicCoef0 and newton:mimicCoef1. The higher-order
/// coefficients (coef2-coef4) are provided by this API.
///
/// Only scalar joint types (slide and hinge) can be used.
///
class MjcPhysicsEqualityJointAPI : public UsdAPISchemaBase {
public:
@@ -150,10 +158,60 @@ class MjcPhysicsEqualityJointAPI : public UsdAPISchemaBase {
MJCPHYSICS_API
const TfType& _GetTfType() const override;
public:
// --------------------------------------------------------------------- //
// SOLIMP
// --------------------------------------------------------------------- //
/// Constraint solver parameter for equality constraint simulation.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform double[] mjc:solimp = [0.9, 0.95, 0.001, 0.5, 2]`
/// | | C++ Type | VtArray<double> | | \ref Usd_Datatypes "Usd Type" |
/// SdfValueTypeNames->DoubleArray | | \ref SdfVariability "Variability" |
/// SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetSolImpAttr() const;
/// See GetSolImpAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
MJCPHYSICS_API
UsdAttribute CreateSolImpAttr(VtValue const& defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// SOLREF
// --------------------------------------------------------------------- //
/// Constraint solver parameter for equality constraint simulation.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform double[] mjc:solref = [0.02, 1]` |
/// | C++ Type | VtArray<double> |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->DoubleArray |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetSolRefAttr() const;
/// See GetSolRefAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
MJCPHYSICS_API
UsdAttribute CreateSolRefAttr(VtValue const& defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// COEF0
// --------------------------------------------------------------------- //
/// DEPRECATED: Use newton:mimicCoef0 instead.
///
/// Constant coefficient a0 of the quartic polynomial. The constraint is:
/// y = y0 + a0 + a1*(x-x0) + a2*(x-x0)^2 + a3*(x-x0)^3 + a4*(x-x0)^4.
///
@@ -179,6 +237,8 @@ class MjcPhysicsEqualityJointAPI : public UsdAPISchemaBase {
// --------------------------------------------------------------------- //
// COEF1
// --------------------------------------------------------------------- //
/// DEPRECATED: Use newton:mimicCoef1 instead.
///
/// Linear coefficient a1 of the quartic polynomial.
///
/// | ||
@@ -271,6 +331,22 @@ class MjcPhysicsEqualityJointAPI : public UsdAPISchemaBase {
UsdAttribute CreateCoef4Attr(VtValue const& defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCTARGET
// --------------------------------------------------------------------- //
/// DEPRECATED: Use newton:mimicJoint instead.
///
/// Secondary target of the equality constraint (the leader/reference joint).
///
MJCPHYSICS_API
UsdRelationship GetMjcTargetRel() const;
/// See GetMjcTargetRel(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create
MJCPHYSICS_API
UsdRelationship CreateMjcTargetRel() const;
public:
// ===================================================================== //
// Feel free to add custom code below this line, it will be preserved by