From 106df98946a942bccf2cc8e38038bc8933858b0c Mon Sep 17 00:00:00 2001 From: Sam Haves Date: Mon, 30 Jun 2025 07:47:47 -0700 Subject: [PATCH] Create Keyframe schema in mjcPhysics. PiperOrigin-RevId: 777568003 Change-Id: I036fd54e2926c138f9ca8de87040b263b8427df3 --- .../experimental/usd/mjcPhysics/keyframe.h | 292 ++++++++++++++++++ .../experimental/usd/mjcPhysics/tokens.h | 38 ++- .../usd/mjcPhysics/generatedSchema.usda | 24 ++ src/experimental/usd/mjcPhysics/keyframe.cpp | 185 +++++++++++ src/experimental/usd/mjcPhysics/plugInfo.json | 13 +- src/experimental/usd/mjcPhysics/schema.usda | 32 ++ src/experimental/usd/mjcPhysics/tokens.cpp | 14 + 7 files changed, 590 insertions(+), 8 deletions(-) create mode 100644 include/mujoco/experimental/usd/mjcPhysics/keyframe.h create mode 100644 src/experimental/usd/mjcPhysics/keyframe.cpp diff --git a/include/mujoco/experimental/usd/mjcPhysics/keyframe.h b/include/mujoco/experimental/usd/mjcPhysics/keyframe.h new file mode 100644 index 00000000..bf66efb2 --- /dev/null +++ b/include/mujoco/experimental/usd/mjcPhysics/keyframe.h @@ -0,0 +1,292 @@ +// Copyright 2025 DeepMind Technologies Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef MJCPHYSICS_GENERATED_KEYFRAME_H +#define MJCPHYSICS_GENERATED_KEYFRAME_H + +/// \file mjcPhysics/keyframe.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +PXR_NAMESPACE_OPEN_SCOPE + +class SdfAssetPath; + +// -------------------------------------------------------------------------- // +// KEYFRAME // +// -------------------------------------------------------------------------- // + +/// \class MjcPhysicsKeyframe +/// +/// Represents time independent keyframe values. +/// +class MjcPhysicsKeyframe : public UsdTyped { + public: + /// Compile time constant representing what kind of schema this class is. + /// + /// \sa UsdSchemaKind + static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped; + + /// Construct a MjcPhysicsKeyframe on UsdPrim \p prim . + /// Equivalent to MjcPhysicsKeyframe::Get(prim.GetStage(), prim.GetPath()) + /// for a \em valid \p prim, but will not immediately throw an error for + /// an invalid \p prim + explicit MjcPhysicsKeyframe(const UsdPrim &prim = UsdPrim()) + : UsdTyped(prim) {} + + /// Construct a MjcPhysicsKeyframe on the prim held by \p schemaObj . + /// Should be preferred over MjcPhysicsKeyframe(schemaObj.GetPrim()), + /// as it preserves SchemaBase state. + explicit MjcPhysicsKeyframe(const UsdSchemaBase &schemaObj) + : UsdTyped(schemaObj) {} + + /// Destructor. + MJCPHYSICS_API + virtual ~MjcPhysicsKeyframe(); + + /// Return a vector of names of all pre-declared attributes for this schema + /// class and all its ancestor classes. Does not include attributes that + /// may be authored by custom/extended methods of the schemas involved. + MJCPHYSICS_API + static const TfTokenVector &GetSchemaAttributeNames( + bool includeInherited = true); + + /// Return a MjcPhysicsKeyframe holding the prim adhering to this + /// schema at \p path on \p stage. If no prim exists at \p path on + /// \p stage, or if the prim at that path does not adhere to this schema, + /// return an invalid schema object. This is shorthand for the following: + /// + /// \code + /// MjcPhysicsKeyframe(stage->GetPrimAtPath(path)); + /// \endcode + /// + MJCPHYSICS_API + static MjcPhysicsKeyframe Get(const UsdStagePtr &stage, const SdfPath &path); + + /// Attempt to ensure a \a UsdPrim adhering to this schema at \p path + /// is defined (according to UsdPrim::IsDefined()) on this stage. + /// + /// If a prim adhering to this schema at \p path is already defined on this + /// stage, return that prim. Otherwise author an \a SdfPrimSpec with + /// \a specifier == \a SdfSpecifierDef and this schema's prim type name for + /// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s + /// with \p specifier == \a SdfSpecifierDef and empty typeName at the + /// current EditTarget for any nonexistent, or existing but not \a Defined + /// ancestors. + /// + /// The given \a path must be an absolute prim path that does not contain + /// any variant selections. + /// + /// If it is impossible to author any of the necessary PrimSpecs, (for + /// example, in case \a path cannot map to the current UsdEditTarget's + /// namespace) issue an error and return an invalid \a UsdPrim. + /// + /// Note that this method may return a defined prim whose typeName does not + /// specify this schema class, in case a stronger typeName opinion overrides + /// the opinion at the current EditTarget. + /// + MJCPHYSICS_API + static MjcPhysicsKeyframe Define(const UsdStagePtr &stage, + const SdfPath &path); + + protected: + /// Returns the kind of schema this class belongs to. + /// + /// \sa UsdSchemaKind + MJCPHYSICS_API + UsdSchemaKind _GetSchemaKind() const override; + + private: + // needs to invoke _GetStaticTfType. + friend class UsdSchemaRegistry; + MJCPHYSICS_API + static const TfType &_GetStaticTfType(); + + static bool _IsTypedSchema(); + + // override SchemaBase virtuals. + MJCPHYSICS_API + const TfType &_GetTfType() const override; + + public: + // --------------------------------------------------------------------- // + // MJCQPOS + // --------------------------------------------------------------------- // + /// Vector of joint positions, copied into mjData.qpos when the simulation + /// state is set to this keyframe. + /// + /// | || + /// | -- | -- | + /// | Declaration | `double[] mjc:qpos` | + /// | C++ Type | VtArray | + /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->DoubleArray | + MJCPHYSICS_API + UsdAttribute GetMjcQposAttr() const; + + /// See GetMjcQposAttr(), 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 CreateMjcQposAttr(VtValue const &defaultValue = VtValue(), + bool writeSparsely = false) const; + + public: + // --------------------------------------------------------------------- // + // MJCQVEL + // --------------------------------------------------------------------- // + /// Vector of joint velocities, copied into mjData.qvel when the simulation + /// state is set to this keyframe. + /// + /// | || + /// | -- | -- | + /// | Declaration | `double[] mjc:qvel` | + /// | C++ Type | VtArray | + /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->DoubleArray | + MJCPHYSICS_API + UsdAttribute GetMjcQvelAttr() const; + + /// See GetMjcQvelAttr(), 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 CreateMjcQvelAttr(VtValue const &defaultValue = VtValue(), + bool writeSparsely = false) const; + + public: + // --------------------------------------------------------------------- // + // MJCACT + // --------------------------------------------------------------------- // + /// Vector of actuator activations, copied into mjData.act when the simulation + /// state is set to this keyframe. + /// + /// | || + /// | -- | -- | + /// | Declaration | `double[] mjc:act` | + /// | C++ Type | VtArray | + /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->DoubleArray | + MJCPHYSICS_API + UsdAttribute GetMjcActAttr() const; + + /// See GetMjcActAttr(), 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 CreateMjcActAttr(VtValue const &defaultValue = VtValue(), + bool writeSparsely = false) const; + + public: + // --------------------------------------------------------------------- // + // MJCCTRL + // --------------------------------------------------------------------- // + /// Vector of controls, copied into mjData.ctrl when the simulation state is + /// set to this keyframe. + /// + /// | || + /// | -- | -- | + /// | Declaration | `double[] mjc:ctrl` | + /// | C++ Type | VtArray | + /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->DoubleArray | + MJCPHYSICS_API + UsdAttribute GetMjcCtrlAttr() const; + + /// See GetMjcCtrlAttr(), 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 CreateMjcCtrlAttr(VtValue const &defaultValue = VtValue(), + bool writeSparsely = false) const; + + public: + // --------------------------------------------------------------------- // + // MJCMPOS + // --------------------------------------------------------------------- // + /// Vector of mocap body positions, copied into mjData.mocap_pos when the + /// simulation state is set to this keyframe. + /// + /// | || + /// | -- | -- | + /// | Declaration | `double[] mjc:mpos` | + /// | C++ Type | VtArray | + /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->DoubleArray | + MJCPHYSICS_API + UsdAttribute GetMjcMposAttr() const; + + /// See GetMjcMposAttr(), 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 CreateMjcMposAttr(VtValue const &defaultValue = VtValue(), + bool writeSparsely = false) const; + + public: + // --------------------------------------------------------------------- // + // MJCMQUAT + // --------------------------------------------------------------------- // + /// Vector of mocap body quaternions, copied into mjData.mocap_quat when the + /// simulation state is set to this keyframe. + /// + /// | || + /// | -- | -- | + /// | Declaration | `double[] mjc:mquat` | + /// | C++ Type | VtArray | + /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->DoubleArray | + MJCPHYSICS_API + UsdAttribute GetMjcMquatAttr() const; + + /// See GetMjcMquatAttr(), 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 CreateMjcMquatAttr(VtValue const &defaultValue = VtValue(), + bool writeSparsely = false) const; + + public: + // ===================================================================== // + // Feel free to add custom code below this line, it will be preserved by + // the code generator. + // + // Just remember to: + // - Close the class declaration with }; + // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE + // - Close the include guard with #endif + // ===================================================================== // + // --(BEGIN CUSTOM CODE)-- +}; + +PXR_NAMESPACE_CLOSE_SCOPE + +#endif diff --git a/include/mujoco/experimental/usd/mjcPhysics/tokens.h b/include/mujoco/experimental/usd/mjcPhysics/tokens.h index 50170a59..df19f843 100644 --- a/include/mujoco/experimental/usd/mjcPhysics/tokens.h +++ b/include/mujoco/experimental/usd/mjcPhysics/tokens.h @@ -130,6 +130,10 @@ struct MjcPhysicsTokensType { /// /// Fallback value for MjcPhysicsMeshCollisionAPI::GetInertiaAttr() const TfToken legacy; + /// \brief "mjc:act" + /// + /// MjcPhysicsKeyframe + const TfToken mjcAct; /// \brief "mjc:actDim" /// /// MjcPhysicsActuatorAPI @@ -162,6 +166,10 @@ struct MjcPhysicsTokensType { /// /// MjcPhysicsActuatorAPI const TfToken mjcCrankLength; + /// \brief "mjc:ctrl" + /// + /// MjcPhysicsKeyframe + const TfToken mjcCtrl; /// \brief "mjc:ctrlLimited" /// /// MjcPhysicsActuatorAPI @@ -314,6 +322,14 @@ struct MjcPhysicsTokensType { /// /// MjcPhysicsActuatorAPI const TfToken mjcLengthRangeMin; + /// \brief "mjc:mpos" + /// + /// MjcPhysicsKeyframe + const TfToken mjcMpos; + /// \brief "mjc:mquat" + /// + /// MjcPhysicsKeyframe + const TfToken mjcMquat; /// \brief "mjc:option:actuatorgroupdisable" /// /// MjcPhysicsSceneAPI @@ -418,6 +434,14 @@ struct MjcPhysicsTokensType { /// /// MjcPhysicsSceneAPI const TfToken mjcOptionWind; + /// \brief "mjc:qpos" + /// + /// MjcPhysicsKeyframe + const TfToken mjcQpos; + /// \brief "mjc:qvel" + /// + /// MjcPhysicsKeyframe + const TfToken mjcQvel; /// \brief "mjc:refSite" /// /// MjcPhysicsActuatorAPI @@ -484,23 +508,27 @@ struct MjcPhysicsTokensType { const TfToken user; /// \brief "CollisionAPI" /// - /// Schema identifer and family for MjcPhysicsCollisionAPI + /// Schema identifier and family for MjcPhysicsCollisionAPI const TfToken CollisionAPI; + /// \brief "Keyframe" + /// + /// Schema identifier and family for MjcPhysicsKeyframe + const TfToken Keyframe; /// \brief "MeshCollisionAPI" /// - /// Schema identifer and family for MjcPhysicsMeshCollisionAPI + /// Schema identifier and family for MjcPhysicsMeshCollisionAPI const TfToken MeshCollisionAPI; /// \brief "PhysicsActuatorAPI" /// - /// Schema identifer and family for MjcPhysicsActuatorAPI + /// Schema identifier and family for MjcPhysicsActuatorAPI const TfToken PhysicsActuatorAPI; /// \brief "SceneAPI" /// - /// Schema identifer and family for MjcPhysicsSceneAPI + /// Schema identifier and family for MjcPhysicsSceneAPI const TfToken SceneAPI; /// \brief "SiteAPI" /// - /// Schema identifer and family for MjcPhysicsSiteAPI + /// Schema identifier and family for MjcPhysicsSiteAPI const TfToken SiteAPI; /// A vector of all of the tokens listed above. const std::vector allTokens; diff --git a/src/experimental/usd/mjcPhysics/generatedSchema.usda b/src/experimental/usd/mjcPhysics/generatedSchema.usda index 91b0f7fd..d88cebee 100644 --- a/src/experimental/usd/mjcPhysics/generatedSchema.usda +++ b/src/experimental/usd/mjcPhysics/generatedSchema.usda @@ -331,3 +331,27 @@ class "PhysicsActuatorAPI" ( ) } +class Keyframe "Keyframe" ( + doc = "Represents time independent keyframe values." +) +{ + double[] mjc:act ( + doc = "Vector of actuator activations, copied into mjData.act when the simulation state is set to this keyframe." + ) + double[] mjc:ctrl ( + doc = "Vector of controls, copied into mjData.ctrl when the simulation state is set to this keyframe." + ) + double[] mjc:mpos ( + doc = "Vector of mocap body positions, copied into mjData.mocap_pos when the simulation state is set to this keyframe." + ) + double[] mjc:mquat ( + doc = "Vector of mocap body quaternions, copied into mjData.mocap_quat when the simulation state is set to this keyframe." + ) + double[] mjc:qpos ( + doc = "Vector of joint positions, copied into mjData.qpos when the simulation state is set to this keyframe." + ) + double[] mjc:qvel ( + doc = "Vector of joint velocities, copied into mjData.qvel when the simulation state is set to this keyframe." + ) +} + diff --git a/src/experimental/usd/mjcPhysics/keyframe.cpp b/src/experimental/usd/mjcPhysics/keyframe.cpp new file mode 100644 index 00000000..05a4eb46 --- /dev/null +++ b/src/experimental/usd/mjcPhysics/keyframe.cpp @@ -0,0 +1,185 @@ +// Copyright 2025 DeepMind Technologies Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include +#include +#include +#include + +PXR_NAMESPACE_OPEN_SCOPE + +// Register the schema with the TfType system. +TF_REGISTRY_FUNCTION(TfType) { + TfType::Define >(); + + // Register the usd prim typename as an alias under UsdSchemaBase. This + // enables one to call + // TfType::Find().FindDerivedByName("Keyframe") + // to find TfType, which is how IsA queries are + // answered. + TfType::AddAlias("Keyframe"); +} + +/* virtual */ +MjcPhysicsKeyframe::~MjcPhysicsKeyframe() {} + +/* static */ +MjcPhysicsKeyframe MjcPhysicsKeyframe::Get(const UsdStagePtr &stage, + const SdfPath &path) { + if (!stage) { + TF_CODING_ERROR("Invalid stage"); + return MjcPhysicsKeyframe(); + } + return MjcPhysicsKeyframe(stage->GetPrimAtPath(path)); +} + +/* static */ +MjcPhysicsKeyframe MjcPhysicsKeyframe::Define(const UsdStagePtr &stage, + const SdfPath &path) { + static TfToken usdPrimTypeName("Keyframe"); + if (!stage) { + TF_CODING_ERROR("Invalid stage"); + return MjcPhysicsKeyframe(); + } + return MjcPhysicsKeyframe(stage->DefinePrim(path, usdPrimTypeName)); +} + +/* virtual */ +UsdSchemaKind MjcPhysicsKeyframe::_GetSchemaKind() const { + return MjcPhysicsKeyframe::schemaKind; +} + +/* static */ +const TfType &MjcPhysicsKeyframe::_GetStaticTfType() { + static TfType tfType = TfType::Find(); + return tfType; +} + +/* static */ +bool MjcPhysicsKeyframe::_IsTypedSchema() { + static bool isTyped = _GetStaticTfType().IsA(); + return isTyped; +} + +/* virtual */ +const TfType &MjcPhysicsKeyframe::_GetTfType() const { + return _GetStaticTfType(); +} + +UsdAttribute MjcPhysicsKeyframe::GetMjcQposAttr() const { + return GetPrim().GetAttribute(MjcPhysicsTokens->mjcQpos); +} + +UsdAttribute MjcPhysicsKeyframe::CreateMjcQposAttr(VtValue const &defaultValue, + bool writeSparsely) const { + return UsdSchemaBase::_CreateAttr( + MjcPhysicsTokens->mjcQpos, SdfValueTypeNames->DoubleArray, + /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); +} + +UsdAttribute MjcPhysicsKeyframe::GetMjcQvelAttr() const { + return GetPrim().GetAttribute(MjcPhysicsTokens->mjcQvel); +} + +UsdAttribute MjcPhysicsKeyframe::CreateMjcQvelAttr(VtValue const &defaultValue, + bool writeSparsely) const { + return UsdSchemaBase::_CreateAttr( + MjcPhysicsTokens->mjcQvel, SdfValueTypeNames->DoubleArray, + /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); +} + +UsdAttribute MjcPhysicsKeyframe::GetMjcActAttr() const { + return GetPrim().GetAttribute(MjcPhysicsTokens->mjcAct); +} + +UsdAttribute MjcPhysicsKeyframe::CreateMjcActAttr(VtValue const &defaultValue, + bool writeSparsely) const { + return UsdSchemaBase::_CreateAttr( + MjcPhysicsTokens->mjcAct, SdfValueTypeNames->DoubleArray, + /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); +} + +UsdAttribute MjcPhysicsKeyframe::GetMjcCtrlAttr() const { + return GetPrim().GetAttribute(MjcPhysicsTokens->mjcCtrl); +} + +UsdAttribute MjcPhysicsKeyframe::CreateMjcCtrlAttr(VtValue const &defaultValue, + bool writeSparsely) const { + return UsdSchemaBase::_CreateAttr( + MjcPhysicsTokens->mjcCtrl, SdfValueTypeNames->DoubleArray, + /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); +} + +UsdAttribute MjcPhysicsKeyframe::GetMjcMposAttr() const { + return GetPrim().GetAttribute(MjcPhysicsTokens->mjcMpos); +} + +UsdAttribute MjcPhysicsKeyframe::CreateMjcMposAttr(VtValue const &defaultValue, + bool writeSparsely) const { + return UsdSchemaBase::_CreateAttr( + MjcPhysicsTokens->mjcMpos, SdfValueTypeNames->DoubleArray, + /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); +} + +UsdAttribute MjcPhysicsKeyframe::GetMjcMquatAttr() const { + return GetPrim().GetAttribute(MjcPhysicsTokens->mjcMquat); +} + +UsdAttribute MjcPhysicsKeyframe::CreateMjcMquatAttr(VtValue const &defaultValue, + bool writeSparsely) const { + return UsdSchemaBase::_CreateAttr( + MjcPhysicsTokens->mjcMquat, SdfValueTypeNames->DoubleArray, + /* custom = */ false, SdfVariabilityVarying, defaultValue, writeSparsely); +} + +namespace { +static inline TfTokenVector _ConcatenateAttributeNames( + const TfTokenVector &left, const TfTokenVector &right) { + TfTokenVector result; + result.reserve(left.size() + right.size()); + result.insert(result.end(), left.begin(), left.end()); + result.insert(result.end(), right.begin(), right.end()); + return result; +} +} // namespace + +/*static*/ +const TfTokenVector &MjcPhysicsKeyframe::GetSchemaAttributeNames( + bool includeInherited) { + static TfTokenVector localNames = { + MjcPhysicsTokens->mjcQpos, MjcPhysicsTokens->mjcQvel, + MjcPhysicsTokens->mjcAct, MjcPhysicsTokens->mjcCtrl, + MjcPhysicsTokens->mjcMpos, MjcPhysicsTokens->mjcMquat, + }; + static TfTokenVector allNames = _ConcatenateAttributeNames( + UsdTyped::GetSchemaAttributeNames(true), localNames); + + if (includeInherited) + return allNames; + else + return localNames; +} + +PXR_NAMESPACE_CLOSE_SCOPE + +// ===================================================================== // +// Feel free to add custom code below this line. It will be preserved by +// the code generator. +// +// Just remember to wrap code in the appropriate delimiters: +// 'PXR_NAMESPACE_OPEN_SCOPE', 'PXR_NAMESPACE_CLOSE_SCOPE'. +// ===================================================================== // +// --(BEGIN CUSTOM CODE)-- diff --git a/src/experimental/usd/mjcPhysics/plugInfo.json b/src/experimental/usd/mjcPhysics/plugInfo.json index 12f8beae..b66c1eb0 100644 --- a/src/experimental/usd/mjcPhysics/plugInfo.json +++ b/src/experimental/usd/mjcPhysics/plugInfo.json @@ -1,6 +1,3 @@ -#Portions of this file auto - generated by usdGenSchema. -#Edits will survive regeneration except for comments and -#changes to types with autoGenerated = true. { "Plugins": [ { @@ -26,6 +23,16 @@ ], "schemaKind": "singleApplyAPI" }, + "MjcPhysicsKeyframe": { + "alias": { + "UsdSchemaBase": "Keyframe" + }, + "autoGenerated": true, + "bases": [ + "UsdTyped" + ], + "schemaKind": "concreteTyped" + }, "MjcPhysicsMeshCollisionAPI": { "alias": { "UsdSchemaBase": "MeshCollisionAPI" diff --git a/src/experimental/usd/mjcPhysics/schema.usda b/src/experimental/usd/mjcPhysics/schema.usda index a59c6bb9..9b9196a4 100644 --- a/src/experimental/usd/mjcPhysics/schema.usda +++ b/src/experimental/usd/mjcPhysics/schema.usda @@ -663,3 +663,35 @@ class "PhysicsActuatorAPI" } +class Keyframe "Keyframe" +( + doc = """Represents time independent keyframe values.""" + + inherits = +) +{ + double[] mjc:qpos ( + doc = "Vector of joint positions, copied into mjData.qpos when the simulation state is set to this keyframe." + ) + + double[] mjc:qvel ( + doc = "Vector of joint velocities, copied into mjData.qvel when the simulation state is set to this keyframe." + ) + + double[] mjc:act ( + doc = "Vector of actuator activations, copied into mjData.act when the simulation state is set to this keyframe." + ) + + double[] mjc:ctrl ( + doc = "Vector of controls, copied into mjData.ctrl when the simulation state is set to this keyframe." + ) + + double[] mjc:mpos ( + doc = "Vector of mocap body positions, copied into mjData.mocap_pos when the simulation state is set to this keyframe." + ) + + double[] mjc:mquat ( + doc = "Vector of mocap body quaternions, copied into mjData.mocap_quat when the simulation state is set to this keyframe." + ) +} + diff --git a/src/experimental/usd/mjcPhysics/tokens.cpp b/src/experimental/usd/mjcPhysics/tokens.cpp index 0fa5cef2..e18394ed 100644 --- a/src/experimental/usd/mjcPhysics/tokens.cpp +++ b/src/experimental/usd/mjcPhysics/tokens.cpp @@ -33,6 +33,7 @@ MjcPhysicsTokensType::MjcPhysicsTokensType() implicitfast("implicitfast", TfToken::Immortal), integrator("integrator", TfToken::Immortal), legacy("legacy", TfToken::Immortal), + mjcAct("mjc:act", TfToken::Immortal), mjcActDim("mjc:actDim", TfToken::Immortal), mjcActEarly("mjc:actEarly", TfToken::Immortal), mjcActLimited("mjc:actLimited", TfToken::Immortal), @@ -41,6 +42,7 @@ MjcPhysicsTokensType::MjcPhysicsTokensType() mjcBiasPrm("mjc:biasPrm", TfToken::Immortal), mjcBiasType("mjc:biasType", TfToken::Immortal), mjcCrankLength("mjc:crankLength", TfToken::Immortal), + mjcCtrl("mjc:ctrl", TfToken::Immortal), mjcCtrlLimited("mjc:ctrlLimited", TfToken::Immortal), mjcCtrlRangeMax("mjc:ctrlRange:max", TfToken::Immortal), mjcCtrlRangeMin("mjc:ctrlRange:min", TfToken::Immortal), @@ -79,6 +81,8 @@ MjcPhysicsTokensType::MjcPhysicsTokensType() mjcJointInParent("mjc:jointInParent", TfToken::Immortal), mjcLengthRangeMax("mjc:lengthRange:max", TfToken::Immortal), mjcLengthRangeMin("mjc:lengthRange:min", TfToken::Immortal), + mjcMpos("mjc:mpos", TfToken::Immortal), + mjcMquat("mjc:mquat", TfToken::Immortal), mjcOptionActuatorgroupdisable("mjc:option:actuatorgroupdisable", TfToken::Immortal), mjcOptionApirate("mjc:option:apirate", TfToken::Immortal), @@ -108,6 +112,8 @@ MjcPhysicsTokensType::MjcPhysicsTokensType() mjcOptionTolerance("mjc:option:tolerance", TfToken::Immortal), mjcOptionViscosity("mjc:option:viscosity", TfToken::Immortal), mjcOptionWind("mjc:option:wind", TfToken::Immortal), + mjcQpos("mjc:qpos", TfToken::Immortal), + mjcQvel("mjc:qvel", TfToken::Immortal), mjcRefSite("mjc:refSite", TfToken::Immortal), mjcShellinertia("mjc:shellinertia", TfToken::Immortal), mjcSliderSite("mjc:sliderSite", TfToken::Immortal), @@ -122,6 +128,7 @@ MjcPhysicsTokensType::MjcPhysicsTokensType() true_("true", TfToken::Immortal), user("user", TfToken::Immortal), CollisionAPI("CollisionAPI", TfToken::Immortal), + Keyframe("Keyframe", TfToken::Immortal), MeshCollisionAPI("MeshCollisionAPI", TfToken::Immortal), PhysicsActuatorAPI("PhysicsActuatorAPI", TfToken::Immortal), SceneAPI("SceneAPI", TfToken::Immortal), @@ -142,6 +149,7 @@ MjcPhysicsTokensType::MjcPhysicsTokensType() implicitfast, integrator, legacy, + mjcAct, mjcActDim, mjcActEarly, mjcActLimited, @@ -150,6 +158,7 @@ MjcPhysicsTokensType::MjcPhysicsTokensType() mjcBiasPrm, mjcBiasType, mjcCrankLength, + mjcCtrl, mjcCtrlLimited, mjcCtrlRangeMax, mjcCtrlRangeMin, @@ -188,6 +197,8 @@ MjcPhysicsTokensType::MjcPhysicsTokensType() mjcJointInParent, mjcLengthRangeMax, mjcLengthRangeMin, + mjcMpos, + mjcMquat, mjcOptionActuatorgroupdisable, mjcOptionApirate, mjcOptionCcd_iterations, @@ -214,6 +225,8 @@ MjcPhysicsTokensType::MjcPhysicsTokensType() mjcOptionTolerance, mjcOptionViscosity, mjcOptionWind, + mjcQpos, + mjcQvel, mjcRefSite, mjcShellinertia, mjcSliderSite, @@ -228,6 +241,7 @@ MjcPhysicsTokensType::MjcPhysicsTokensType() true_, user, CollisionAPI, + Keyframe, MeshCollisionAPI, PhysicsActuatorAPI, SceneAPI,