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
@@ -323,6 +323,8 @@ class MjcPhysicsCollisionAPI : public UsdAPISchemaBase {
// --------------------------------------------------------------------- //
// MARGIN
// --------------------------------------------------------------------- //
/// DEPRECATED: Use newton:contactMargin and newton:contactGap instead.
///
/// Geometric inflation of the geom surface for the purpose of contact force
/// generation.
///
@@ -348,6 +350,8 @@ class MjcPhysicsCollisionAPI : public UsdAPISchemaBase {
// --------------------------------------------------------------------- //
// GAP
// --------------------------------------------------------------------- //
/// DEPRECATED: Use newton:contactGap instead.
///
/// Additional contact detection buffer beyond margin. Contacts are detected
/// at distance margin + gap but forces are only generated at distance margin.
///
@@ -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
@@ -42,6 +42,9 @@ class SdfAssetPath;
/// \class MjcPhysicsMaterialAPI
///
/// DEPRECATED: Use NewtonMaterialAPI instead. All attributes on this API have
/// been superseded by Newton equivalents.
///
/// API providing extension attributes to represent physical MuJoCo materials.
///
class MjcPhysicsMaterialAPI : public UsdAPISchemaBase {
@@ -148,6 +151,8 @@ class MjcPhysicsMaterialAPI : public UsdAPISchemaBase {
// --------------------------------------------------------------------- //
// TORSIONALFRICTION
// --------------------------------------------------------------------- //
/// DEPRECATED: Use newton:torsionalFriction instead.
///
/// Friction value acting around contact normal.
///
/// | ||
@@ -173,6 +178,8 @@ class MjcPhysicsMaterialAPI : public UsdAPISchemaBase {
// --------------------------------------------------------------------- //
// ROLLINGFRICTION
// --------------------------------------------------------------------- //
/// DEPRECATED: Use newton:rollingFriction instead.
///
/// Friction value acting around both axes on the contact tangent plane.
///
/// | ||
@@ -179,6 +179,8 @@ class MjcPhysicsMeshCollisionAPI : public UsdAPISchemaBase {
// --------------------------------------------------------------------- //
// MAXHULLVERT
// --------------------------------------------------------------------- //
/// DEPRECATED: Use newton:maxHullVertices instead.
///
/// Sets an upper limit on the number of vertices in the meshes convex hull.
/// The default value of -1 means unlimited.
///
@@ -152,6 +152,8 @@ class MjcPhysicsSceneAPI : public UsdAPISchemaBase {
// --------------------------------------------------------------------- //
// TIMESTEP
// --------------------------------------------------------------------- //
/// DEPRECATED: Use newton:timeStepsPerSecond instead.
///
/// Controls the timestep in seconds used by MuJoCo.
///
/// | ||
@@ -498,6 +500,8 @@ class MjcPhysicsSceneAPI : public UsdAPISchemaBase {
// --------------------------------------------------------------------- //
// ITERATIONS
// --------------------------------------------------------------------- //
/// DEPRECATED: Use newton:maxSolverIterations instead.
///
/// Maximum number of iterations of the constraint solver.
///
/// | ||
@@ -942,6 +946,8 @@ class MjcPhysicsSceneAPI : public UsdAPISchemaBase {
// --------------------------------------------------------------------- //
// GRAVITYFLAG
// --------------------------------------------------------------------- //
/// DEPRECATED: Use newton:gravityEnabled instead.
///
/// Enables the application of gravitational acceleration as defined in
/// mjOption.
///
@@ -656,7 +656,7 @@ struct MjcPhysicsTokensType {
const TfToken mjcSliderSite;
/// \brief "mjc:solimp"
///
/// MjcPhysicsCollisionAPI, MjcPhysicsEqualityAPI
/// MjcPhysicsCollisionAPI, MjcPhysicsEqualityAPI, MjcPhysicsEqualityJointAPI
const TfToken mjcSolimp;
/// \brief "mjc:solimpfriction"
///
@@ -672,7 +672,7 @@ struct MjcPhysicsTokensType {
const TfToken mjcSolmix;
/// \brief "mjc:solref"
///
/// MjcPhysicsCollisionAPI, MjcPhysicsEqualityAPI
/// MjcPhysicsCollisionAPI, MjcPhysicsEqualityAPI, MjcPhysicsEqualityJointAPI
const TfToken mjcSolref;
/// \brief "mjc:solreffriction"
///
@@ -700,7 +700,7 @@ struct MjcPhysicsTokensType {
const TfToken mjcStiffness;
/// \brief "mjc:target"
///
/// MjcPhysicsActuator, MjcPhysicsEqualityAPI
/// MjcPhysicsActuator, MjcPhysicsEqualityAPI, MjcPhysicsEqualityJointAPI
const TfToken mjcTarget;
/// \brief "mjc:torqueScale"
///