Add group support to mjcPhysics equivalents for sites, geoms, actuators, and joints.

PiperOrigin-RevId: 781945497
Change-Id: I5c409f05e6bae33c181a51c273f260daea6004fc
This commit is contained in:
Sam Haves
2025-07-11 05:36:35 -07:00
committed by Copybara-Service
parent bbb265da4a
commit 3473e4e451
14 changed files with 234 additions and 24 deletions
@@ -40,7 +40,7 @@ class SdfAssetPath;
/// \class MjcPhysicsCollisionAPI
///
/// API describing a Mujoco collider.
/// API describing a MuJoCo collider.
///
class MjcPhysicsCollisionAPI : public UsdAPISchemaBase {
public:
@@ -142,6 +142,30 @@ class MjcPhysicsCollisionAPI : public UsdAPISchemaBase {
MJCPHYSICS_API
const TfType &_GetTfType() const override;
public:
// --------------------------------------------------------------------- //
// GROUP
// --------------------------------------------------------------------- //
/// Integer MuJoCo group to which the collider belongs.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform int mjc:group = 0` |
/// | C++ Type | int |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Int |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetGroupAttr() const;
/// See GetGroupAttr(), 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 CreateGroupAttr(VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// SHELLINERTIA
@@ -40,7 +40,7 @@ class SdfAssetPath;
/// \class MjcPhysicsJointAPI
///
/// API describing a Mujoco joint.
/// API describing a MuJoCo joint.
///
/// For any described attribute \em Fallback \em Value or \em Allowed \em Values
/// below that are text/tokens, the actual token is published and defined in
@@ -146,6 +146,30 @@ class MjcPhysicsJointAPI : public UsdAPISchemaBase {
MJCPHYSICS_API
const TfType &_GetTfType() const override;
public:
// --------------------------------------------------------------------- //
// GROUP
// --------------------------------------------------------------------- //
/// Integer MuJoCo group to which the joint belongs.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform int mjc:group = 0` |
/// | C++ Type | int |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Int |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetGroupAttr() const;
/// See GetGroupAttr(), 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 CreateGroupAttr(VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCSPRINGDAMPER
@@ -40,7 +40,7 @@ class SdfAssetPath;
/// \class MjcPhysicsSceneAPI
///
/// API providing global simulation options for Mujoco.
/// API providing global simulation options for MuJoCo.
///
/// For any described attribute \em Fallback \em Value or \em Allowed \em Values
/// below that are text/tokens, the actual token is published and defined in
@@ -18,6 +18,7 @@
/// \file mjcPhysics/siteAPI.h
#include <mujoco/experimental/usd/mjcPhysics/api.h>
#include <mujoco/experimental/usd/mjcPhysics/tokens.h>
#include <pxr/base/gf/matrix4d.h>
#include <pxr/base/gf/vec3d.h>
#include <pxr/base/gf/vec3f.h>
@@ -39,7 +40,7 @@ class SdfAssetPath;
/// \class MjcPhysicsSiteAPI
///
/// API describing a Mujoco site.
/// API describing a MuJoCo site.
///
class MjcPhysicsSiteAPI : public UsdAPISchemaBase {
public:
@@ -140,6 +141,30 @@ class MjcPhysicsSiteAPI : public UsdAPISchemaBase {
MJCPHYSICS_API
const TfType &_GetTfType() const override;
public:
// --------------------------------------------------------------------- //
// GROUP
// --------------------------------------------------------------------- //
/// Integer MuJoCo group to which the collider belongs.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform int mjc:group = 0` |
/// | C++ Type | int |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Int |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetGroupAttr() const;
/// See GetGroupAttr(), 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 CreateGroupAttr(VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// ===================================================================== //
// Feel free to add custom code below this line, it will be preserved by
@@ -338,7 +338,8 @@ struct MjcPhysicsTokensType {
const TfToken mjcGear;
/// \brief "mjc:group"
///
/// MjcPhysicsTransmission
/// MjcPhysicsSiteAPI, MjcPhysicsImageableAPI, MjcPhysicsCollisionAPI,
/// MjcPhysicsTransmission, MjcPhysicsJointAPI
const TfToken mjcGroup;
/// \brief "mjc:inertia"
///
@@ -589,6 +590,10 @@ struct MjcPhysicsTokensType {
///
/// Schema identifier and family for MjcPhysicsCollisionAPI
const TfToken MjcCollisionAPI;
/// \brief "MjcImageableAPI"
///
/// Schema identifier and family for MjcPhysicsImageableAPI
const TfToken MjcImageableAPI;
/// \brief "MjcJointAPI"
///
/// Schema identifier and family for MjcPhysicsJointAPI