Create Keyframe schema in mjcPhysics.
PiperOrigin-RevId: 777568003 Change-Id: I036fd54e2926c138f9ca8de87040b263b8427df3
This commit is contained in:
committed by
Copybara-Service
parent
1c98dfd86e
commit
106df98946
@@ -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."
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -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 <mujoco/experimental/usd/mjcPhysics/keyframe.h>
|
||||
|
||||
#include <pxr/usd/sdf/assetPath.h>
|
||||
#include <pxr/usd/sdf/types.h>
|
||||
#include <pxr/usd/usd/schemaRegistry.h>
|
||||
#include <pxr/usd/usd/typed.h>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
// Register the schema with the TfType system.
|
||||
TF_REGISTRY_FUNCTION(TfType) {
|
||||
TfType::Define<MjcPhysicsKeyframe, TfType::Bases<UsdTyped> >();
|
||||
|
||||
// Register the usd prim typename as an alias under UsdSchemaBase. This
|
||||
// enables one to call
|
||||
// TfType::Find<UsdSchemaBase>().FindDerivedByName("Keyframe")
|
||||
// to find TfType<MjcPhysicsKeyframe>, which is how IsA queries are
|
||||
// answered.
|
||||
TfType::AddAlias<UsdSchemaBase, MjcPhysicsKeyframe>("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<MjcPhysicsKeyframe>();
|
||||
return tfType;
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool MjcPhysicsKeyframe::_IsTypedSchema() {
|
||||
static bool isTyped = _GetStaticTfType().IsA<UsdTyped>();
|
||||
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)--
|
||||
@@ -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"
|
||||
|
||||
@@ -663,3 +663,35 @@ class "PhysicsActuatorAPI"
|
||||
}
|
||||
|
||||
|
||||
class Keyframe "Keyframe"
|
||||
(
|
||||
doc = """Represents time independent keyframe values."""
|
||||
|
||||
inherits = </Typed>
|
||||
)
|
||||
{
|
||||
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."
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user