Add support for tendons to mjcPhysics.
PiperOrigin-RevId: 822230926 Change-Id: I232a9fbfb473186ac742d210458ff0221a561126
This commit is contained in:
committed by
Copybara-Service
parent
ac2cd5dfd6
commit
160b9480f9
@@ -22,6 +22,7 @@
|
||||
#include <mujoco/experimental/usd/mjcPhysics/actuator.h>
|
||||
#include <mujoco/experimental/usd/mjcPhysics/keyframe.h>
|
||||
#include <mujoco/experimental/usd/mjcPhysics/siteAPI.h>
|
||||
#include <mujoco/experimental/usd/mjcPhysics/tendon.h>
|
||||
#include <mujoco/mujoco.h>
|
||||
#include <pxr/usd/sdf/path.h>
|
||||
#include <pxr/usd/usd/common.h>
|
||||
@@ -171,6 +172,12 @@ ExtractedPrims ExtractPrims(pxr::UsdStageRefPtr stage) {
|
||||
it.PruneChildren();
|
||||
}
|
||||
|
||||
if (prim.IsA<pxr::MjcPhysicsTendon>()) {
|
||||
root->tendons.push_back(prim_path);
|
||||
// Tendons should not have children of interest.
|
||||
it.PruneChildren();
|
||||
}
|
||||
|
||||
if (prim.IsA<pxr::MjcPhysicsKeyframe>()) {
|
||||
root->keyframes.push_back(prim_path);
|
||||
// Keyframes should not have children.
|
||||
|
||||
@@ -35,6 +35,7 @@ struct Node {
|
||||
std::vector<pxr::SdfPath> visual_gprims;
|
||||
std::vector<pxr::SdfPath> colliders;
|
||||
std::vector<pxr::SdfPath> sites;
|
||||
std::vector<pxr::SdfPath> tendons;
|
||||
std::vector<pxr::SdfPath> keyframes;
|
||||
std::vector<std::unique_ptr<Node>> children;
|
||||
};
|
||||
|
||||
@@ -550,3 +550,110 @@ class "MjcMaterialAPI" (
|
||||
)
|
||||
}
|
||||
|
||||
class MjcTendon "MjcTendon" (
|
||||
doc = "Type describing fixed and spatial tendons."
|
||||
)
|
||||
{
|
||||
uniform token mjc:actuatorfrclimited = "auto" (
|
||||
allowedTokens = ["false", "true", "auto"]
|
||||
displayName = "Actuator Force Limited"
|
||||
doc = "This attribute specifies whether actuator forces acting on the tendon should be clamped. See Force limits for details. This attribute interacts with the actuatorfrcrange attribute. If this attribute is “false”, actuator force clamping is disabled. If it is “true”, actuator force clamping is enabled. If this attribute is “auto”, and autolimits is set in compiler, actuator force clamping will be enabled if actuatorfrcrange is defined."
|
||||
)
|
||||
uniform double mjc:actuatorfrcrange:max = 0 (
|
||||
displayName = "Actuator Force Range Max"
|
||||
doc = "Maximum range for clamping total actuator forces acting on this tendon. See Force limits for details. The compiler expects the upper bound to be nonnegative. Setting this attribute without specifying actuatorfrclimited is an error if compiler-autolimits is “false”."
|
||||
)
|
||||
uniform double mjc:actuatorfrcrange:min = 0 (
|
||||
displayName = "Actuator Force Range Min"
|
||||
doc = "Minimum range for clamping total actuator forces acting on this tendon. See Force limits for details. The compiler expects the lower bound to be nonpositive. Setting this attribute without specifying actuatorfrclimited is an error if compiler-autolimits is “false”."
|
||||
)
|
||||
uniform double mjc:armature = 0 (
|
||||
displayName = "Armature"
|
||||
doc = "Inertia associated with changes in tendon length."
|
||||
)
|
||||
uniform double mjc:damping = 0 (
|
||||
displayName = "Damping"
|
||||
doc = "Damping coefficient. A positive value generates a damping force (linear in velocity) acting along the tendon. Unlike joint damping which is integrated implicitly by the Euler method, tendon damping is not integrated implicitly, thus joint damping should be used if possible."
|
||||
)
|
||||
uniform double mjc:frictionloss = 0 (
|
||||
displayName = "Friction Loss"
|
||||
doc = "Friction loss caused by dry friction. To enable friction loss, set this attribute to a positive value."
|
||||
)
|
||||
uniform int mjc:group = 0 (
|
||||
displayName = "Group"
|
||||
doc = "Integer MuJoCo group to which the tendon belongs."
|
||||
)
|
||||
uniform token mjc:limited = "auto" (
|
||||
allowedTokens = ["auto", "true", "false"]
|
||||
displayName = "Limited"
|
||||
doc = "If true, the tendon length is limited to the range specified by mjc:range:min/max."
|
||||
)
|
||||
uniform double mjc:margin = 0 (
|
||||
displayName = "Margin"
|
||||
doc = "The limit constraint becomes active when the absolute value of the difference between the tendon length and either limit of the specified range falls below this margin. Similar to contacts, the margin parameter is subtracted from the difference between the range limit and the tendon length. The resulting constraint distance is always negative when the constraint is active. This quantity is used to compute constraint impedance as a function of distance."
|
||||
)
|
||||
rel mjc:path (
|
||||
doc = "For spatial tendons, this describes a list of sites and geoms the tendon wraps. For fixed tendons, this is instead a list of joints."
|
||||
)
|
||||
uniform double[] mjc:path:coef = [] (
|
||||
doc = "For fixed tendons passing through joints this represents a multiplicative factor on the position or angle of the targeted joint."
|
||||
)
|
||||
uniform double[] mjc:path:divisors = [] (
|
||||
doc = "For spatial tendons, this represents an indexed array of divisors. A tendon path segments' length contribution to the overall tendon length is divided by its divisor."
|
||||
)
|
||||
uniform int[] mjc:path:segments = [] (
|
||||
doc = "For spatial tendons, this holds the index of the segment each tendon path wrap point belongs to."
|
||||
)
|
||||
uniform double mjc:range:max = 0 (
|
||||
displayName = "Range Max"
|
||||
doc = "Maximum allowed tendon length. Setting this attribute without specifying limited is an error, unless autolimits is set in compiler."
|
||||
)
|
||||
uniform double mjc:range:min = 0 (
|
||||
displayName = "Range Min"
|
||||
doc = "Minimum allowed tendon length. Setting this attribute without specifying limited is an error, unless autolimits is set in compiler."
|
||||
)
|
||||
uniform color4f mjc:rgba = (0.5, 0.5, 0.5, 1) (
|
||||
displayName = "RGBA"
|
||||
doc = "Color and transparency of the tendon in MuJoCo."
|
||||
)
|
||||
rel mjc:sideSites (
|
||||
doc = "For spatial tendons, a geom wrapped by the tendon may specify which side of the geom the tendon wraps around via a site prim. This is a list of sites that are used as side sites in mjc:path."
|
||||
)
|
||||
uniform int[] mjc:sideSites:indices = [] (
|
||||
doc = "For spatial tendons, if mjc:sideSites has targets then index 'i' in this list represents the position in the relationship targets of mjc:sideSites that the geom at index 'i' in mjc:path uses as a side site. It is considered an authoring error to assign a side site to something other than a geom. Geoms that do not use a side site should use index value '-1'."
|
||||
)
|
||||
uniform double[] mjc:solimpfriction = [0.9, 0.95, 0.001, 0.5, 2] (
|
||||
displayName = "Solver Impedance Friction"
|
||||
doc = "Constraint solver parameters for simulating dry friction in the tendon."
|
||||
)
|
||||
uniform double[] mjc:solimplimit = [0.9, 0.95, 0.001, 0.5, 2] (
|
||||
displayName = "Solver Impedance Limit"
|
||||
doc = "Constraint solver parameters for simulating tendon limits."
|
||||
)
|
||||
uniform double[] mjc:solreffriction = [0.02, 1] (
|
||||
displayName = "Solver Reference Friction"
|
||||
doc = "Constraint solver parameters for simulating dry friction in the tendon."
|
||||
)
|
||||
uniform double[] mjc:solreflimit = [0.02, 1] (
|
||||
displayName = "Solver Reference Limit"
|
||||
doc = "Constraint solver parameters for simulating tendon limits."
|
||||
)
|
||||
uniform double[] mjc:springlength = [-1, -1] (
|
||||
displayName = "Spring Length"
|
||||
doc = "Spring resting position, can take either one or two values. If one value is given, it corresponds to the length of the tendon at rest. If it is -1, the tendon resting length is determined from the model reference configuration in mjModel.qpos0. Note that the default value of -1, which invokes the automatic length computation, was designed with spatial tendons in mind, which can only have nonegative length. In order to set the springlength of a fixed tendon to -1, use a nearby value like -0.99999. If two non-decreasing values are given, they define a dead-band range. If the tendon length is between the two values, the force is 0. If it is outside this range, the force behaves like a regular spring, with the rest-point corresponding to the nearest springlength value. A deadband can be used to define tendons whose limits are enforced by springs rather than constraints."
|
||||
)
|
||||
uniform double mjc:stiffness = 0 (
|
||||
displayName = "Stiffness"
|
||||
doc = "Stiffness coefficient. A positive value generates a spring force (linear in position) acting along the tendon."
|
||||
)
|
||||
uniform token mjc:type = "spatial" (
|
||||
allowedTokens = ["spatial", "fixed"]
|
||||
displayName = "Type"
|
||||
doc = "Type of tendon, valid values are 'spatial' and 'fixed'."
|
||||
)
|
||||
uniform double mjc:width = 0.003 (
|
||||
displayName = "Width"
|
||||
doc = "Radius of the cross-section area of the spatial tendon, used for rendering in MuJoCo. Parts of the tendon that wrap around geom obstacles are rendered with reduced width."
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,16 @@
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"MjcPhysicsTendon": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "MjcTendon"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdTyped"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1056,3 +1056,201 @@ class "MjcMaterialAPI"
|
||||
doc = """Friction value acting around both axes on the contact tangent plane."""
|
||||
)
|
||||
}
|
||||
|
||||
class MjcTendon "MjcTendon"
|
||||
(
|
||||
customData = {
|
||||
string className = "Tendon"
|
||||
}
|
||||
doc = """Type describing fixed and spatial tendons."""
|
||||
|
||||
inherits = </Typed>
|
||||
)
|
||||
{
|
||||
uniform token mjc:type = "spatial" (
|
||||
allowedTokens = ["spatial", "fixed"]
|
||||
customData = {
|
||||
string apiName = "Type"
|
||||
}
|
||||
displayName = "Type"
|
||||
doc = """Type of tendon, valid values are 'spatial' and 'fixed'."""
|
||||
)
|
||||
|
||||
rel mjc:path (
|
||||
doc = "For spatial tendons, this describes a list of sites and geoms the tendon wraps. For fixed tendons, this is instead a list of joints."
|
||||
)
|
||||
|
||||
rel mjc:sideSites (
|
||||
doc = "For spatial tendons, a geom wrapped by the tendon may specify which side of the geom the tendon wraps around via a site prim. This is a list of sites that are used as side sites in mjc:path."
|
||||
)
|
||||
|
||||
uniform int[] mjc:sideSites:indices = [] (
|
||||
doc = "For spatial tendons, if mjc:sideSites has targets then index 'i' in this list represents the position in the relationship targets of mjc:sideSites that the geom at index 'i' in mjc:path uses as a side site. It is considered an authoring error to assign a side site to something other than a geom. Geoms that do not use a side site should use index value '-1'."
|
||||
)
|
||||
|
||||
uniform int[] mjc:path:segments = [] (
|
||||
doc = "For spatial tendons, this holds the index of the segment each tendon path wrap point belongs to."
|
||||
)
|
||||
|
||||
uniform double[] mjc:path:divisors = [] (
|
||||
doc = "For spatial tendons, this represents an indexed array of divisors. A tendon path segments' length contribution to the overall tendon length is divided by its divisor."
|
||||
)
|
||||
|
||||
uniform double[] mjc:path:coef = [] (
|
||||
doc = "For fixed tendons passing through joints this represents a multiplicative factor on the position or angle of the targeted joint."
|
||||
)
|
||||
|
||||
uniform int mjc:group = 0 (
|
||||
customData = {
|
||||
string apiName = "Group"
|
||||
}
|
||||
displayName = "Group"
|
||||
doc = """Integer MuJoCo group to which the tendon belongs."""
|
||||
)
|
||||
|
||||
uniform token mjc:limited = "auto" (
|
||||
allowedTokens = ["auto", "true", "false"]
|
||||
customData = {
|
||||
string apiName = "Limited"
|
||||
}
|
||||
displayName = "Limited"
|
||||
doc = """If true, the tendon length is limited to the range specified by mjc:range:min/max."""
|
||||
)
|
||||
|
||||
uniform token mjc:actuatorfrclimited = "auto" (
|
||||
allowedTokens = ["false", "true", "auto"]
|
||||
customData = {
|
||||
string apiName = "ActuatorFrcLimited"
|
||||
}
|
||||
displayName = "Actuator Force Limited"
|
||||
doc = """This attribute specifies whether actuator forces acting on the tendon should be clamped. See Force limits for details. This attribute interacts with the actuatorfrcrange attribute. If this attribute is “false”, actuator force clamping is disabled. If it is “true”, actuator force clamping is enabled. If this attribute is “auto”, and autolimits is set in compiler, actuator force clamping will be enabled if actuatorfrcrange is defined."""
|
||||
)
|
||||
|
||||
uniform double mjc:range:min = 0 (
|
||||
customData = {
|
||||
string apiName = "RangeMin"
|
||||
}
|
||||
displayName = "Range Min"
|
||||
doc = """Minimum allowed tendon length. Setting this attribute without specifying limited is an error, unless autolimits is set in compiler."""
|
||||
)
|
||||
|
||||
uniform double mjc:range:max = 0 (
|
||||
customData = {
|
||||
string apiName = "RangeMax"
|
||||
}
|
||||
displayName = "Range Max"
|
||||
doc = """Maximum allowed tendon length. Setting this attribute without specifying limited is an error, unless autolimits is set in compiler."""
|
||||
)
|
||||
|
||||
uniform double mjc:actuatorfrcrange:min = 0 (
|
||||
customData = {
|
||||
string apiName = "ActuatorFrcRangeMin"
|
||||
}
|
||||
displayName = "Actuator Force Range Min"
|
||||
doc = """Minimum range for clamping total actuator forces acting on this tendon. See Force limits for details. The compiler expects the lower bound to be nonpositive. Setting this attribute without specifying actuatorfrclimited is an error if compiler-autolimits is “false”."""
|
||||
)
|
||||
|
||||
uniform double mjc:actuatorfrcrange:max = 0 (
|
||||
customData = {
|
||||
string apiName = "ActuatorFrcRangeMax"
|
||||
}
|
||||
displayName = "Actuator Force Range Max"
|
||||
doc = """Maximum range for clamping total actuator forces acting on this tendon. See Force limits for details. The compiler expects the upper bound to be nonnegative. Setting this attribute without specifying actuatorfrclimited is an error if compiler-autolimits is “false”."""
|
||||
)
|
||||
|
||||
uniform double[] mjc:solreflimit = [0.02, 1.0] (
|
||||
customData = {
|
||||
string apiName = "SolRefLimit"
|
||||
}
|
||||
displayName = "Solver Reference Limit"
|
||||
doc = """Constraint solver parameters for simulating tendon limits."""
|
||||
)
|
||||
|
||||
uniform double[] mjc:solimplimit = [0.9, 0.95, 0.001, 0.5, 2.0] (
|
||||
customData = {
|
||||
string apiName = "SolImpLimit"
|
||||
}
|
||||
displayName = "Solver Impedance Limit"
|
||||
doc = """Constraint solver parameters for simulating tendon limits."""
|
||||
)
|
||||
|
||||
uniform double[] mjc:solreffriction = [0.02, 1.0] (
|
||||
customData = {
|
||||
string apiName = "SolRefFriction"
|
||||
}
|
||||
displayName = "Solver Reference Friction"
|
||||
doc = """Constraint solver parameters for simulating dry friction in the tendon."""
|
||||
)
|
||||
|
||||
uniform double[] mjc:solimpfriction = [0.9, 0.95, 0.001, 0.5, 2.0] (
|
||||
customData = {
|
||||
string apiName = "SolImpFriction"
|
||||
}
|
||||
displayName = "Solver Impedance Friction"
|
||||
doc = """Constraint solver parameters for simulating dry friction in the tendon."""
|
||||
)
|
||||
|
||||
uniform double mjc:margin = 0.0 (
|
||||
customData = {
|
||||
string apiName = "Margin"
|
||||
}
|
||||
displayName = "Margin"
|
||||
doc = """The limit constraint becomes active when the absolute value of the difference between the tendon length and either limit of the specified range falls below this margin. Similar to contacts, the margin parameter is subtracted from the difference between the range limit and the tendon length. The resulting constraint distance is always negative when the constraint is active. This quantity is used to compute constraint impedance as a function of distance."""
|
||||
)
|
||||
|
||||
uniform double mjc:frictionloss = 0.0 (
|
||||
customData = {
|
||||
string apiName = "FrictionLoss"
|
||||
}
|
||||
displayName = "Friction Loss"
|
||||
doc = """Friction loss caused by dry friction. To enable friction loss, set this attribute to a positive value."""
|
||||
)
|
||||
|
||||
uniform double mjc:width = 0.003 (
|
||||
customData = {
|
||||
string apiName = "Width"
|
||||
}
|
||||
displayName = "Width"
|
||||
doc = """Radius of the cross-section area of the spatial tendon, used for rendering in MuJoCo. Parts of the tendon that wrap around geom obstacles are rendered with reduced width."""
|
||||
)
|
||||
|
||||
uniform color4f mjc:rgba = (0.5, 0.5, 0.5, 1.0) (
|
||||
customData = {
|
||||
string apiName = "Rgba"
|
||||
}
|
||||
displayName = "RGBA"
|
||||
doc = """Color and transparency of the tendon in MuJoCo."""
|
||||
)
|
||||
|
||||
uniform double[] mjc:springlength = [-1, -1] (
|
||||
customData = {
|
||||
string apiName = "SpringLength"
|
||||
}
|
||||
displayName = "Spring Length"
|
||||
doc = """Spring resting position, can take either one or two values. If one value is given, it corresponds to the length of the tendon at rest. If it is -1, the tendon resting length is determined from the model reference configuration in mjModel.qpos0. Note that the default value of -1, which invokes the automatic length computation, was designed with spatial tendons in mind, which can only have nonegative length. In order to set the springlength of a fixed tendon to -1, use a nearby value like -0.99999. If two non-decreasing values are given, they define a dead-band range. If the tendon length is between the two values, the force is 0. If it is outside this range, the force behaves like a regular spring, with the rest-point corresponding to the nearest springlength value. A deadband can be used to define tendons whose limits are enforced by springs rather than constraints."""
|
||||
)
|
||||
|
||||
uniform double mjc:stiffness = 0.0 (
|
||||
customData = {
|
||||
string apiName = "Stiffness"
|
||||
}
|
||||
displayName = "Stiffness"
|
||||
doc = """Stiffness coefficient. A positive value generates a spring force (linear in position) acting along the tendon."""
|
||||
)
|
||||
|
||||
uniform double mjc:damping = 0.0 (
|
||||
customData = {
|
||||
string apiName = "Damping"
|
||||
}
|
||||
displayName = "Damping"
|
||||
doc = """Damping coefficient. A positive value generates a damping force (linear in velocity) acting along the tendon. Unlike joint damping which is integrated implicitly by the Euler method, tendon damping is not integrated implicitly, thus joint damping should be used if possible."""
|
||||
)
|
||||
|
||||
uniform double mjc:armature = 0.0 (
|
||||
customData = {
|
||||
string apiName = "Armature"
|
||||
}
|
||||
displayName = "Armature"
|
||||
doc = """Inertia associated with changes in tendon length."""
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,422 @@
|
||||
// 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/tendon.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<MjcPhysicsTendon, TfType::Bases<UsdTyped> >();
|
||||
|
||||
// Register the usd prim typename as an alias under UsdSchemaBase. This
|
||||
// enables one to call
|
||||
// TfType::Find<UsdSchemaBase>().FindDerivedByName("MjcTendon")
|
||||
// to find TfType<MjcPhysicsTendon>, which is how IsA queries are
|
||||
// answered.
|
||||
TfType::AddAlias<UsdSchemaBase, MjcPhysicsTendon>("MjcTendon");
|
||||
}
|
||||
|
||||
/* virtual */
|
||||
MjcPhysicsTendon::~MjcPhysicsTendon() {}
|
||||
|
||||
/* static */
|
||||
MjcPhysicsTendon MjcPhysicsTendon::Get(const UsdStagePtr& stage,
|
||||
const SdfPath& path) {
|
||||
if (!stage) {
|
||||
TF_CODING_ERROR("Invalid stage");
|
||||
return MjcPhysicsTendon();
|
||||
}
|
||||
return MjcPhysicsTendon(stage->GetPrimAtPath(path));
|
||||
}
|
||||
|
||||
/* static */
|
||||
MjcPhysicsTendon MjcPhysicsTendon::Define(const UsdStagePtr& stage,
|
||||
const SdfPath& path) {
|
||||
static TfToken usdPrimTypeName("MjcTendon");
|
||||
if (!stage) {
|
||||
TF_CODING_ERROR("Invalid stage");
|
||||
return MjcPhysicsTendon();
|
||||
}
|
||||
return MjcPhysicsTendon(stage->DefinePrim(path, usdPrimTypeName));
|
||||
}
|
||||
|
||||
/* virtual */
|
||||
UsdSchemaKind MjcPhysicsTendon::_GetSchemaKind() const {
|
||||
return MjcPhysicsTendon::schemaKind;
|
||||
}
|
||||
|
||||
/* static */
|
||||
const TfType& MjcPhysicsTendon::_GetStaticTfType() {
|
||||
static TfType tfType = TfType::Find<MjcPhysicsTendon>();
|
||||
return tfType;
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool MjcPhysicsTendon::_IsTypedSchema() {
|
||||
static bool isTyped = _GetStaticTfType().IsA<UsdTyped>();
|
||||
return isTyped;
|
||||
}
|
||||
|
||||
/* virtual */
|
||||
const TfType& MjcPhysicsTendon::_GetTfType() const {
|
||||
return _GetStaticTfType();
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetTypeAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcType);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateTypeAttr(VtValue const& defaultValue,
|
||||
bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcType, SdfValueTypeNames->Token,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetMjcSideSitesIndicesAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcSideSitesIndices);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateMjcSideSitesIndicesAttr(
|
||||
VtValue const& defaultValue, bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcSideSitesIndices, SdfValueTypeNames->IntArray,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetMjcPathSegmentsAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcPathSegments);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateMjcPathSegmentsAttr(
|
||||
VtValue const& defaultValue, bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcPathSegments, SdfValueTypeNames->IntArray,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetMjcPathDivisorsAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcPathDivisors);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateMjcPathDivisorsAttr(
|
||||
VtValue const& defaultValue, bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcPathDivisors, SdfValueTypeNames->DoubleArray,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetMjcPathCoefAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcPathCoef);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateMjcPathCoefAttr(
|
||||
VtValue const& defaultValue, bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcPathCoef, SdfValueTypeNames->DoubleArray,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetGroupAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcGroup);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateGroupAttr(VtValue const& defaultValue,
|
||||
bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcGroup, SdfValueTypeNames->Int,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetLimitedAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcLimited);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateLimitedAttr(VtValue const& defaultValue,
|
||||
bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcLimited, SdfValueTypeNames->Token,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetActuatorFrcLimitedAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcActuatorfrclimited);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateActuatorFrcLimitedAttr(
|
||||
VtValue const& defaultValue, bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcActuatorfrclimited, SdfValueTypeNames->Token,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetRangeMinAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcRangeMin);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateRangeMinAttr(VtValue const& defaultValue,
|
||||
bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcRangeMin, SdfValueTypeNames->Double,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetRangeMaxAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcRangeMax);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateRangeMaxAttr(VtValue const& defaultValue,
|
||||
bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcRangeMax, SdfValueTypeNames->Double,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetActuatorFrcRangeMinAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcActuatorfrcrangeMin);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateActuatorFrcRangeMinAttr(
|
||||
VtValue const& defaultValue, bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcActuatorfrcrangeMin, SdfValueTypeNames->Double,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetActuatorFrcRangeMaxAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcActuatorfrcrangeMax);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateActuatorFrcRangeMaxAttr(
|
||||
VtValue const& defaultValue, bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcActuatorfrcrangeMax, SdfValueTypeNames->Double,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetSolRefLimitAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcSolreflimit);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateSolRefLimitAttr(
|
||||
VtValue const& defaultValue, bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcSolreflimit, SdfValueTypeNames->DoubleArray,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetSolImpLimitAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcSolimplimit);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateSolImpLimitAttr(
|
||||
VtValue const& defaultValue, bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcSolimplimit, SdfValueTypeNames->DoubleArray,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetSolRefFrictionAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcSolreffriction);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateSolRefFrictionAttr(
|
||||
VtValue const& defaultValue, bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcSolreffriction, SdfValueTypeNames->DoubleArray,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetSolImpFrictionAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcSolimpfriction);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateSolImpFrictionAttr(
|
||||
VtValue const& defaultValue, bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcSolimpfriction, SdfValueTypeNames->DoubleArray,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetMarginAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcMargin);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateMarginAttr(VtValue const& defaultValue,
|
||||
bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcMargin, SdfValueTypeNames->Double,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetFrictionLossAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcFrictionloss);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateFrictionLossAttr(
|
||||
VtValue const& defaultValue, bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcFrictionloss, SdfValueTypeNames->Double,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetWidthAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcWidth);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateWidthAttr(VtValue const& defaultValue,
|
||||
bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcWidth, SdfValueTypeNames->Double,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetRgbaAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcRgba);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateRgbaAttr(VtValue const& defaultValue,
|
||||
bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcRgba, SdfValueTypeNames->Color4f,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetSpringLengthAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcSpringlength);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateSpringLengthAttr(
|
||||
VtValue const& defaultValue, bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcSpringlength, SdfValueTypeNames->DoubleArray,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetStiffnessAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcStiffness);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateStiffnessAttr(VtValue const& defaultValue,
|
||||
bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcStiffness, SdfValueTypeNames->Double,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetDampingAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcDamping);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateDampingAttr(VtValue const& defaultValue,
|
||||
bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcDamping, SdfValueTypeNames->Double,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::GetArmatureAttr() const {
|
||||
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcArmature);
|
||||
}
|
||||
|
||||
UsdAttribute MjcPhysicsTendon::CreateArmatureAttr(VtValue const& defaultValue,
|
||||
bool writeSparsely) const {
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
MjcPhysicsTokens->mjcArmature, SdfValueTypeNames->Double,
|
||||
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
|
||||
}
|
||||
|
||||
UsdRelationship MjcPhysicsTendon::GetMjcPathRel() const {
|
||||
return GetPrim().GetRelationship(MjcPhysicsTokens->mjcPath);
|
||||
}
|
||||
|
||||
UsdRelationship MjcPhysicsTendon::CreateMjcPathRel() const {
|
||||
return GetPrim().CreateRelationship(MjcPhysicsTokens->mjcPath,
|
||||
/* custom = */ false);
|
||||
}
|
||||
|
||||
UsdRelationship MjcPhysicsTendon::GetMjcSideSitesRel() const {
|
||||
return GetPrim().GetRelationship(MjcPhysicsTokens->mjcSideSites);
|
||||
}
|
||||
|
||||
UsdRelationship MjcPhysicsTendon::CreateMjcSideSitesRel() const {
|
||||
return GetPrim().CreateRelationship(MjcPhysicsTokens->mjcSideSites,
|
||||
/* custom = */ false);
|
||||
}
|
||||
|
||||
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& MjcPhysicsTendon::GetSchemaAttributeNames(
|
||||
bool includeInherited) {
|
||||
static TfTokenVector localNames = {
|
||||
MjcPhysicsTokens->mjcType,
|
||||
MjcPhysicsTokens->mjcSideSitesIndices,
|
||||
MjcPhysicsTokens->mjcPathSegments,
|
||||
MjcPhysicsTokens->mjcPathDivisors,
|
||||
MjcPhysicsTokens->mjcPathCoef,
|
||||
MjcPhysicsTokens->mjcGroup,
|
||||
MjcPhysicsTokens->mjcLimited,
|
||||
MjcPhysicsTokens->mjcActuatorfrclimited,
|
||||
MjcPhysicsTokens->mjcRangeMin,
|
||||
MjcPhysicsTokens->mjcRangeMax,
|
||||
MjcPhysicsTokens->mjcActuatorfrcrangeMin,
|
||||
MjcPhysicsTokens->mjcActuatorfrcrangeMax,
|
||||
MjcPhysicsTokens->mjcSolreflimit,
|
||||
MjcPhysicsTokens->mjcSolimplimit,
|
||||
MjcPhysicsTokens->mjcSolreffriction,
|
||||
MjcPhysicsTokens->mjcSolimpfriction,
|
||||
MjcPhysicsTokens->mjcMargin,
|
||||
MjcPhysicsTokens->mjcFrictionloss,
|
||||
MjcPhysicsTokens->mjcWidth,
|
||||
MjcPhysicsTokens->mjcRgba,
|
||||
MjcPhysicsTokens->mjcSpringlength,
|
||||
MjcPhysicsTokens->mjcStiffness,
|
||||
MjcPhysicsTokens->mjcDamping,
|
||||
MjcPhysicsTokens->mjcArmature,
|
||||
};
|
||||
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)--
|
||||
@@ -112,6 +112,7 @@ MjcPhysicsTokensType::MjcPhysicsTokensType()
|
||||
mjcJointInParent("mjc:jointInParent", TfToken::Immortal),
|
||||
mjcLengthRangeMax("mjc:lengthRange:max", TfToken::Immortal),
|
||||
mjcLengthRangeMin("mjc:lengthRange:min", TfToken::Immortal),
|
||||
mjcLimited("mjc:limited", TfToken::Immortal),
|
||||
mjcMargin("mjc:margin", TfToken::Immortal),
|
||||
mjcMaxhullvert("mjc:maxhullvert", TfToken::Immortal),
|
||||
mjcMpos("mjc:mpos", TfToken::Immortal),
|
||||
@@ -144,13 +145,22 @@ MjcPhysicsTokensType::MjcPhysicsTokensType()
|
||||
mjcOptionTolerance("mjc:option:tolerance", TfToken::Immortal),
|
||||
mjcOptionViscosity("mjc:option:viscosity", TfToken::Immortal),
|
||||
mjcOptionWind("mjc:option:wind", TfToken::Immortal),
|
||||
mjcPath("mjc:path", TfToken::Immortal),
|
||||
mjcPathCoef("mjc:path:coef", TfToken::Immortal),
|
||||
mjcPathDivisors("mjc:path:divisors", TfToken::Immortal),
|
||||
mjcPathSegments("mjc:path:segments", TfToken::Immortal),
|
||||
mjcPriority("mjc:priority", TfToken::Immortal),
|
||||
mjcQpos("mjc:qpos", TfToken::Immortal),
|
||||
mjcQvel("mjc:qvel", TfToken::Immortal),
|
||||
mjcRangeMax("mjc:range:max", TfToken::Immortal),
|
||||
mjcRangeMin("mjc:range:min", TfToken::Immortal),
|
||||
mjcRef("mjc:ref", TfToken::Immortal),
|
||||
mjcRefSite("mjc:refSite", TfToken::Immortal),
|
||||
mjcRgba("mjc:rgba", TfToken::Immortal),
|
||||
mjcRollingfriction("mjc:rollingfriction", TfToken::Immortal),
|
||||
mjcShellinertia("mjc:shellinertia", TfToken::Immortal),
|
||||
mjcSideSites("mjc:sideSites", TfToken::Immortal),
|
||||
mjcSideSitesIndices("mjc:sideSites:indices", TfToken::Immortal),
|
||||
mjcSliderSite("mjc:sliderSite", TfToken::Immortal),
|
||||
mjcSolimp("mjc:solimp", TfToken::Immortal),
|
||||
mjcSolimpfriction("mjc:solimpfriction", TfToken::Immortal),
|
||||
@@ -160,10 +170,13 @@ MjcPhysicsTokensType::MjcPhysicsTokensType()
|
||||
mjcSolreffriction("mjc:solreffriction", TfToken::Immortal),
|
||||
mjcSolreflimit("mjc:solreflimit", TfToken::Immortal),
|
||||
mjcSpringdamper("mjc:springdamper", TfToken::Immortal),
|
||||
mjcSpringlength("mjc:springlength", TfToken::Immortal),
|
||||
mjcSpringref("mjc:springref", TfToken::Immortal),
|
||||
mjcStiffness("mjc:stiffness", TfToken::Immortal),
|
||||
mjcTarget("mjc:target", TfToken::Immortal),
|
||||
mjcTorsionalfriction("mjc:torsionalfriction", TfToken::Immortal),
|
||||
mjcType("mjc:type", TfToken::Immortal),
|
||||
mjcWidth("mjc:width", TfToken::Immortal),
|
||||
muscle("muscle", TfToken::Immortal),
|
||||
newton("newton", TfToken::Immortal),
|
||||
none("none", TfToken::Immortal),
|
||||
@@ -173,6 +186,7 @@ MjcPhysicsTokensType::MjcPhysicsTokensType()
|
||||
rk4("rk4", TfToken::Immortal),
|
||||
shell("shell", TfToken::Immortal),
|
||||
sparse("sparse", TfToken::Immortal),
|
||||
spatial("spatial", TfToken::Immortal),
|
||||
true_("true", TfToken::Immortal),
|
||||
user("user", TfToken::Immortal),
|
||||
MjcActuator("MjcActuator", TfToken::Immortal),
|
||||
@@ -184,6 +198,7 @@ MjcPhysicsTokensType::MjcPhysicsTokensType()
|
||||
MjcMeshCollisionAPI("MjcMeshCollisionAPI", TfToken::Immortal),
|
||||
MjcSceneAPI("MjcSceneAPI", TfToken::Immortal),
|
||||
MjcSiteAPI("MjcSiteAPI", TfToken::Immortal),
|
||||
MjcTendon("MjcTendon", TfToken::Immortal),
|
||||
allTokens({affine,
|
||||
auto_,
|
||||
cg,
|
||||
@@ -275,6 +290,7 @@ MjcPhysicsTokensType::MjcPhysicsTokensType()
|
||||
mjcJointInParent,
|
||||
mjcLengthRangeMax,
|
||||
mjcLengthRangeMin,
|
||||
mjcLimited,
|
||||
mjcMargin,
|
||||
mjcMaxhullvert,
|
||||
mjcMpos,
|
||||
@@ -304,13 +320,22 @@ MjcPhysicsTokensType::MjcPhysicsTokensType()
|
||||
mjcOptionTolerance,
|
||||
mjcOptionViscosity,
|
||||
mjcOptionWind,
|
||||
mjcPath,
|
||||
mjcPathCoef,
|
||||
mjcPathDivisors,
|
||||
mjcPathSegments,
|
||||
mjcPriority,
|
||||
mjcQpos,
|
||||
mjcQvel,
|
||||
mjcRangeMax,
|
||||
mjcRangeMin,
|
||||
mjcRef,
|
||||
mjcRefSite,
|
||||
mjcRgba,
|
||||
mjcRollingfriction,
|
||||
mjcShellinertia,
|
||||
mjcSideSites,
|
||||
mjcSideSitesIndices,
|
||||
mjcSliderSite,
|
||||
mjcSolimp,
|
||||
mjcSolimpfriction,
|
||||
@@ -320,10 +345,13 @@ MjcPhysicsTokensType::MjcPhysicsTokensType()
|
||||
mjcSolreffriction,
|
||||
mjcSolreflimit,
|
||||
mjcSpringdamper,
|
||||
mjcSpringlength,
|
||||
mjcSpringref,
|
||||
mjcStiffness,
|
||||
mjcTarget,
|
||||
mjcTorsionalfriction,
|
||||
mjcType,
|
||||
mjcWidth,
|
||||
muscle,
|
||||
newton,
|
||||
none,
|
||||
@@ -333,6 +361,7 @@ MjcPhysicsTokensType::MjcPhysicsTokensType()
|
||||
rk4,
|
||||
shell,
|
||||
sparse,
|
||||
spatial,
|
||||
true_,
|
||||
user,
|
||||
MjcActuator,
|
||||
@@ -343,7 +372,8 @@ MjcPhysicsTokensType::MjcPhysicsTokensType()
|
||||
MjcMaterialAPI,
|
||||
MjcMeshCollisionAPI,
|
||||
MjcSceneAPI,
|
||||
MjcSiteAPI}) {}
|
||||
MjcSiteAPI,
|
||||
MjcTendon}) {}
|
||||
|
||||
TfStaticData<MjcPhysicsTokensType> MjcPhysicsTokens;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <map>
|
||||
@@ -29,6 +30,7 @@
|
||||
#include <mujoco/experimental/usd/mjcPhysics/meshCollisionAPI.h>
|
||||
#include <mujoco/experimental/usd/mjcPhysics/sceneAPI.h>
|
||||
#include <mujoco/experimental/usd/mjcPhysics/siteAPI.h>
|
||||
#include <mujoco/experimental/usd/mjcPhysics/tendon.h>
|
||||
#include <mujoco/experimental/usd/mjcPhysics/tokens.h>
|
||||
#include <mujoco/experimental/usd/usd.h>
|
||||
#include <mujoco/experimental/usd/utils.h>
|
||||
@@ -919,6 +921,300 @@ void ParseMjcPhysicsMeshCollisionAPI(
|
||||
}
|
||||
}
|
||||
|
||||
void ParseMjcPhysicsTendon(mjSpec* spec,
|
||||
const pxr::MjcPhysicsTendon& tendon) {
|
||||
pxr::UsdPrim prim = tendon.GetPrim();
|
||||
pxr::UsdStageRefPtr stage = prim.GetStage();
|
||||
mjsTendon* mj_tendon = mjs_addTendon(spec, nullptr);
|
||||
mjs_setName(mj_tendon->element, prim.GetPath().GetAsString().c_str());
|
||||
|
||||
pxr::TfToken type;
|
||||
tendon.GetTypeAttr().Get(&type);
|
||||
|
||||
pxr::SdfPathVector wrap_targets;
|
||||
tendon.GetMjcPathRel().GetTargets(&wrap_targets);
|
||||
|
||||
pxr::SdfPathVector side_site_paths;
|
||||
tendon.GetMjcSideSitesRel().GetTargets(&side_site_paths);
|
||||
|
||||
pxr::VtIntArray side_site_indices;
|
||||
tendon.GetMjcSideSitesIndicesAttr().Get(&side_site_indices);
|
||||
|
||||
pxr::VtIntArray segments;
|
||||
tendon.GetMjcPathSegmentsAttr().Get(&segments);
|
||||
|
||||
pxr::VtDoubleArray divisors;
|
||||
tendon.GetMjcPathDivisorsAttr().Get(&divisors);
|
||||
|
||||
pxr::VtDoubleArray coefs;
|
||||
tendon.GetMjcPathCoefAttr().Get(&coefs);
|
||||
|
||||
if (type == MjcPhysicsTokens->spatial) {
|
||||
// Check that for N targets we have 0 or N elements in segments.
|
||||
if (!segments.empty() && segments.size() != wrap_targets.size()) {
|
||||
mju_warning(
|
||||
"Spatial tendon %s has %lu segments but %lu wrap targets, skipping.",
|
||||
prim.GetPath().GetAsString().c_str(), segments.size(),
|
||||
wrap_targets.size());
|
||||
return;
|
||||
}
|
||||
// Check that if we have >1 segments that the user has specified how much each segment
|
||||
// contributes to the total segment length.
|
||||
if (!segments.empty() && divisors.empty()) {
|
||||
mju_warning(
|
||||
"Spatial tendon %s has >1 segments (%d) but does not specify divisors, skipping.",
|
||||
prim.GetPath().GetAsString().c_str(), *std::max_element(segments.begin(), segments.end()) + 1);
|
||||
return;
|
||||
}
|
||||
// Check that if we side site indices that we have N of them.
|
||||
if (!side_site_indices.empty() && side_site_indices.size() != wrap_targets.size()) {
|
||||
mju_warning(
|
||||
"Spatial tendon %s has %lu sideSite indices but %lu wrap targets, skipping.",
|
||||
prim.GetPath().GetAsString().c_str(), side_site_indices.size(), wrap_targets.size());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!side_site_indices.empty() && side_site_paths.empty()) {
|
||||
mju_warning(
|
||||
"Spatial tendon %s has %lu sideSite indices but no side sites, skipping.",
|
||||
prim.GetPath().GetAsString().c_str(), side_site_indices.size());
|
||||
return;
|
||||
}
|
||||
} else { // Fixed tendon.
|
||||
// Check that for N targets we have 0 or N elements in coef:
|
||||
if (!coefs.empty() && coefs.size() != wrap_targets.size()) {
|
||||
mju_warning(
|
||||
"Spatial tendon %s has %lu coefs but %lu wrap targets, skipping.",
|
||||
prim.GetPath().GetAsString().c_str(), coefs.size(), wrap_targets.size());
|
||||
}
|
||||
}
|
||||
|
||||
int last_segment = 0;
|
||||
for (int i = 0; i < wrap_targets.size(); ++i) {
|
||||
auto wrap_target = wrap_targets[i];
|
||||
auto wrap_prim = stage->GetPrimAtPath(wrap_target);
|
||||
// Important to check site before Imageable here because some Imageable prims are sites.
|
||||
|
||||
if (!segments.empty()) {
|
||||
int segment = segments[i];
|
||||
if (segment >= divisors.size()) {
|
||||
mju_warning("Tendon %s has at least %d segments but only %lu divisors, skipping.",
|
||||
prim.GetPath().GetAsString().c_str(), segment + 1, divisors.size());
|
||||
return;
|
||||
}
|
||||
|
||||
if (segment > last_segment) {
|
||||
mjsWrap* pulley_wrap = mjs_wrapPulley(mj_tendon, divisors[segment]);
|
||||
mjs_setString(pulley_wrap->info, ("Pulley between segments: " +
|
||||
std::to_string(last_segment) + " and " +
|
||||
std::to_string(segment)).c_str());
|
||||
}
|
||||
last_segment = segment;
|
||||
}
|
||||
|
||||
mjsWrap* wrap = nullptr;
|
||||
if (wrap_prim.HasAPI<pxr::MjcPhysicsSiteAPI>()) {
|
||||
wrap = mjs_wrapSite(mj_tendon, wrap_target.GetAsString().c_str());
|
||||
} else if (wrap_prim.IsA<pxr::UsdPhysicsJoint>()) {
|
||||
double coef = 1.0;
|
||||
if (!coefs.empty()) {
|
||||
coef = coefs[i];
|
||||
}
|
||||
wrap = mjs_wrapJoint(mj_tendon, wrap_target.GetAsString().c_str(), coef);
|
||||
} else if (wrap_prim.IsA<pxr::UsdGeomImageable>()) {
|
||||
std::string side_site_name = "";
|
||||
if (!side_site_indices.empty()) {
|
||||
int side_site_index = side_site_indices[i];
|
||||
if (side_site_index >= side_site_paths.size()) {
|
||||
mju_warning("Tendon %s has side site index %d but only %lu side sites, skipping.",
|
||||
prim.GetPath().GetAsString().c_str(), side_site_index, side_site_paths.size());
|
||||
return;
|
||||
}
|
||||
side_site_name = side_site_paths[side_site_index].GetAsString();
|
||||
}
|
||||
wrap = mjs_wrapGeom(mj_tendon, wrap_target.GetAsString().c_str(), side_site_name.c_str());
|
||||
} else {
|
||||
mju_warning("Tendon %s has an invalid wrap target type, skipping.",
|
||||
prim.GetPath().GetAsString().c_str());
|
||||
return;
|
||||
}
|
||||
mjs_setString(mj_tendon->info, ("Prim: " + wrap_target.GetAsString()).c_str());
|
||||
}
|
||||
|
||||
auto group_attr = tendon.GetGroupAttr();
|
||||
if (group_attr.HasAuthoredValue()) {
|
||||
group_attr.Get(&mj_tendon->group);
|
||||
}
|
||||
|
||||
auto limited_attr = tendon.GetLimitedAttr();
|
||||
if (limited_attr.HasAuthoredValue()) {
|
||||
pxr::TfToken limited;
|
||||
limited_attr.Get(&limited);
|
||||
if (limited == MjcPhysicsTokens->true_) {
|
||||
mj_tendon->limited = mjLIMITED_TRUE;
|
||||
} else if (limited == MjcPhysicsTokens->false_) {
|
||||
mj_tendon->limited = mjLIMITED_FALSE;
|
||||
} else {
|
||||
mj_tendon->limited = mjLIMITED_AUTO;
|
||||
}
|
||||
}
|
||||
|
||||
auto actuatorfrclimited_attr = tendon.GetActuatorFrcLimitedAttr();
|
||||
if (actuatorfrclimited_attr.HasAuthoredValue()) {
|
||||
pxr::TfToken actuatorfrclimited;
|
||||
actuatorfrclimited_attr.Get(&actuatorfrclimited);
|
||||
if (actuatorfrclimited == MjcPhysicsTokens->true_) {
|
||||
mj_tendon->actfrclimited = mjLIMITED_TRUE;
|
||||
} else if (actuatorfrclimited == MjcPhysicsTokens->false_) {
|
||||
mj_tendon->actfrclimited = mjLIMITED_FALSE;
|
||||
} else {
|
||||
mj_tendon->actfrclimited = mjLIMITED_AUTO;
|
||||
}
|
||||
}
|
||||
|
||||
auto range_min_attr = tendon.GetRangeMinAttr();
|
||||
if (range_min_attr.HasAuthoredValue()) {
|
||||
range_min_attr.Get(&mj_tendon->range[0]);
|
||||
}
|
||||
|
||||
auto range_max_attr = tendon.GetRangeMaxAttr();
|
||||
if (range_max_attr.HasAuthoredValue()) {
|
||||
range_max_attr.Get(&mj_tendon->range[1]);
|
||||
}
|
||||
|
||||
auto actuatorfrcrange_min_attr = tendon.GetActuatorFrcRangeMinAttr();
|
||||
if (actuatorfrcrange_min_attr.HasAuthoredValue()) {
|
||||
actuatorfrcrange_min_attr.Get(&mj_tendon->actfrcrange[0]);
|
||||
}
|
||||
|
||||
auto actuatorfrcrange_max_attr = tendon.GetActuatorFrcRangeMaxAttr();
|
||||
if (actuatorfrcrange_max_attr.HasAuthoredValue()) {
|
||||
actuatorfrcrange_max_attr.Get(&mj_tendon->actfrcrange[1]);
|
||||
}
|
||||
|
||||
auto solreflimit_attr = tendon.GetSolRefLimitAttr();
|
||||
if (solreflimit_attr.HasAuthoredValue()) {
|
||||
pxr::VtDoubleArray solreflimit;
|
||||
solreflimit_attr.Get(&solreflimit);
|
||||
if (solreflimit.size() == mjNREF) {
|
||||
for (int i = 0; i < mjNREF; ++i) {
|
||||
mj_tendon->solref_limit[i] = solreflimit[i];
|
||||
}
|
||||
} else {
|
||||
mju_warning(
|
||||
"solreflimit attribute for tendon %s has incorrect size %zu, "
|
||||
"expected %d.",
|
||||
prim.GetPath().GetAsString().c_str(), solreflimit.size(), mjNREF);
|
||||
}
|
||||
}
|
||||
|
||||
auto solimplimit_attr = tendon.GetSolImpLimitAttr();
|
||||
if (solimplimit_attr.HasAuthoredValue()) {
|
||||
pxr::VtDoubleArray solimplimit;
|
||||
solimplimit_attr.Get(&solimplimit);
|
||||
if (solimplimit.size() == mjNIMP) {
|
||||
for (int i = 0; i < mjNIMP; ++i) {
|
||||
mj_tendon->solimp_limit[i] = solimplimit[i];
|
||||
}
|
||||
} else {
|
||||
mju_warning(
|
||||
"solimplimit attribute for tendon %s has incorrect size %zu, "
|
||||
"expected %d.",
|
||||
prim.GetPath().GetAsString().c_str(), solimplimit.size(), mjNIMP);
|
||||
}
|
||||
}
|
||||
|
||||
auto solreffriction_attr = tendon.GetSolRefFrictionAttr();
|
||||
if (solreffriction_attr.HasAuthoredValue()) {
|
||||
pxr::VtDoubleArray solreffriction;
|
||||
solreffriction_attr.Get(&solreffriction);
|
||||
if (solreffriction.size() == mjNREF) {
|
||||
for (int i = 0; i < mjNREF; ++i) {
|
||||
mj_tendon->solref_friction[i] = solreffriction[i];
|
||||
}
|
||||
} else {
|
||||
mju_warning(
|
||||
"solreffriction attribute for tendon %s has incorrect size %zu, "
|
||||
"expected %d.",
|
||||
prim.GetPath().GetAsString().c_str(), solreffriction.size(), mjNREF);
|
||||
}
|
||||
}
|
||||
|
||||
auto solimpfriction_attr = tendon.GetSolImpFrictionAttr();
|
||||
if (solimpfriction_attr.HasAuthoredValue()) {
|
||||
pxr::VtDoubleArray solimpfriction;
|
||||
solimpfriction_attr.Get(&solimpfriction);
|
||||
if (solimpfriction.size() == mjNIMP) {
|
||||
for (int i = 0; i < mjNIMP; ++i) {
|
||||
mj_tendon->solimp_friction[i] = solimpfriction[i];
|
||||
}
|
||||
} else {
|
||||
mju_warning(
|
||||
"solimpfriction attribute for tendon %s has incorrect size %zu, "
|
||||
"expected %d.",
|
||||
prim.GetPath().GetAsString().c_str(), solimpfriction.size(), mjNIMP);
|
||||
}
|
||||
}
|
||||
|
||||
auto margin_attr = tendon.GetMarginAttr();
|
||||
if (margin_attr.HasAuthoredValue()) {
|
||||
margin_attr.Get(&mj_tendon->margin);
|
||||
}
|
||||
|
||||
auto frictionloss_attr = tendon.GetFrictionLossAttr();
|
||||
if (frictionloss_attr.HasAuthoredValue()) {
|
||||
frictionloss_attr.Get(&mj_tendon->frictionloss);
|
||||
}
|
||||
|
||||
auto width_attr = tendon.GetWidthAttr();
|
||||
if (width_attr.HasAuthoredValue()) {
|
||||
width_attr.Get(&mj_tendon->width);
|
||||
}
|
||||
|
||||
auto rgba_attr = tendon.GetRgbaAttr();
|
||||
if (rgba_attr.HasAuthoredValue()) {
|
||||
pxr::GfVec4f rgba;
|
||||
rgba_attr.Get(&rgba);
|
||||
mj_tendon->rgba[0] = rgba[0];
|
||||
mj_tendon->rgba[1] = rgba[1];
|
||||
mj_tendon->rgba[2] = rgba[2];
|
||||
mj_tendon->rgba[3] = rgba[3];
|
||||
}
|
||||
|
||||
auto springlength_attr = tendon.GetSpringLengthAttr();
|
||||
if (springlength_attr.HasAuthoredValue()) {
|
||||
pxr::VtDoubleArray springlength;
|
||||
springlength_attr.Get(&springlength);
|
||||
if (springlength.size() == 1) {
|
||||
mj_tendon->springlength[0] = springlength[0];
|
||||
mj_tendon->springlength[1] = springlength[0];
|
||||
} else if (springlength.size() == 2) {
|
||||
mj_tendon->springlength[0] = springlength[0];
|
||||
mj_tendon->springlength[1] = springlength[1];
|
||||
} else {
|
||||
mju_warning(
|
||||
"springlength attribute for tendon %s has incorrect size %zu, "
|
||||
"expected 1 or 2.",
|
||||
prim.GetPath().GetAsString().c_str(), springlength.size());
|
||||
}
|
||||
}
|
||||
|
||||
auto stiffness_attr = tendon.GetStiffnessAttr();
|
||||
if (stiffness_attr.HasAuthoredValue()) {
|
||||
stiffness_attr.Get(&mj_tendon->stiffness);
|
||||
}
|
||||
|
||||
auto damping_attr = tendon.GetDampingAttr();
|
||||
if (damping_attr.HasAuthoredValue()) {
|
||||
damping_attr.Get(&mj_tendon->damping);
|
||||
}
|
||||
|
||||
auto armature_attr = tendon.GetArmatureAttr();
|
||||
if (armature_attr.HasAuthoredValue()) {
|
||||
armature_attr.Get(&mj_tendon->armature);
|
||||
}
|
||||
}
|
||||
|
||||
void ParseMjcPhysicsActuator(mjSpec* spec,
|
||||
const pxr::MjcPhysicsActuator& tran) {
|
||||
pxr::UsdPrim prim = tran.GetPrim();
|
||||
@@ -1797,6 +2093,13 @@ mjSpec* mj_parseUSDStage(const pxr::UsdStageRefPtr stage) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!root->tendons.empty()) {
|
||||
for (const auto& tendon : root->tendons) {
|
||||
mujoco::usd::ParseMjcPhysicsTendon(
|
||||
spec, pxr::MjcPhysicsTendon::Get(stage, tendon));
|
||||
}
|
||||
}
|
||||
|
||||
// Set of caches to use for all queries when parsing.
|
||||
mujoco::usd::UsdCaches caches;
|
||||
// Then populate the kinematic tree.
|
||||
|
||||
Reference in New Issue
Block a user