Remove MjcActuatorAPI in favor of typed MjcTransmission.

PiperOrigin-RevId: 781498554
Change-Id: Ib6ce5038645f6ca08638a9d316b0347dc121bc62
This commit is contained in:
Sam Haves
2025-07-10 05:58:08 -07:00
committed by Copybara-Service
parent 2d69610abd
commit fbea72d767
12 changed files with 437 additions and 321 deletions
@@ -55,15 +55,15 @@ struct MjcPhysicsTokensType {
MJCPHYSICS_API MjcPhysicsTokensType(); MJCPHYSICS_API MjcPhysicsTokensType();
/// \brief "affine" /// \brief "affine"
/// ///
/// Possible value for MjcPhysicsActuatorAPI::GetMjcBiasTypeAttr(), Possible /// Possible value for MjcPhysicsTransmission::GetMjcBiasTypeAttr(), Possible
/// value for MjcPhysicsActuatorAPI::GetMjcGainTypeAttr() /// value for MjcPhysicsTransmission::GetMjcGainTypeAttr()
const TfToken affine; const TfToken affine;
/// \brief "auto" /// \brief "auto"
/// ///
/// Fallback value for MjcPhysicsSceneAPI::GetJacobianAttr(), Fallback value /// Fallback value for MjcPhysicsSceneAPI::GetJacobianAttr(), Fallback value
/// for MjcPhysicsActuatorAPI::GetMjcActLimitedAttr(), Fallback value for /// for MjcPhysicsTransmission::GetMjcActLimitedAttr(), Fallback value for
/// MjcPhysicsActuatorAPI::GetMjcCtrlLimitedAttr(), Fallback value for /// MjcPhysicsTransmission::GetMjcCtrlLimitedAttr(), Fallback value for
/// MjcPhysicsActuatorAPI::GetMjcForceLimitedAttr(), Fallback value for /// MjcPhysicsTransmission::GetMjcForceLimitedAttr(), Fallback value for
/// MjcPhysicsJointAPI::GetMjcActuatorfrclimitedAttr(), This token represents /// MjcPhysicsJointAPI::GetMjcActuatorfrclimitedAttr(), This token represents
/// the auto constraint Jacobian and matrices computed from it. /// the auto constraint Jacobian and matrices computed from it.
const TfToken auto_; const TfToken auto_;
@@ -97,22 +97,22 @@ struct MjcPhysicsTokensType {
const TfToken exact; const TfToken exact;
/// \brief "false" /// \brief "false"
/// ///
/// Possible value for MjcPhysicsActuatorAPI::GetMjcActLimitedAttr(), Possible /// Possible value for MjcPhysicsTransmission::GetMjcActLimitedAttr(),
/// value for MjcPhysicsActuatorAPI::GetMjcCtrlLimitedAttr(), Possible value /// Possible value for MjcPhysicsTransmission::GetMjcCtrlLimitedAttr(),
/// for MjcPhysicsActuatorAPI::GetMjcForceLimitedAttr(), Possible value for /// Possible value for MjcPhysicsTransmission::GetMjcForceLimitedAttr(),
/// MjcPhysicsJointAPI::GetMjcActuatorfrclimitedAttr() /// Possible value for MjcPhysicsJointAPI::GetMjcActuatorfrclimitedAttr()
const TfToken false_; const TfToken false_;
/// \brief "filter" /// \brief "filter"
/// ///
/// Possible value for MjcPhysicsActuatorAPI::GetMjcDynTypeAttr() /// Possible value for MjcPhysicsTransmission::GetMjcDynTypeAttr()
const TfToken filter; const TfToken filter;
/// \brief "filterexact" /// \brief "filterexact"
/// ///
/// Possible value for MjcPhysicsActuatorAPI::GetMjcDynTypeAttr() /// Possible value for MjcPhysicsTransmission::GetMjcDynTypeAttr()
const TfToken filterexact; const TfToken filterexact;
/// \brief "fixed" /// \brief "fixed"
/// ///
/// Fallback value for MjcPhysicsActuatorAPI::GetMjcGainTypeAttr() /// Fallback value for MjcPhysicsTransmission::GetMjcGainTypeAttr()
const TfToken fixed; const TfToken fixed;
/// \brief "implicit" /// \brief "implicit"
/// ///
@@ -126,7 +126,7 @@ struct MjcPhysicsTokensType {
const TfToken implicitfast; const TfToken implicitfast;
/// \brief "integrator" /// \brief "integrator"
/// ///
/// Possible value for MjcPhysicsActuatorAPI::GetMjcDynTypeAttr() /// Possible value for MjcPhysicsTransmission::GetMjcDynTypeAttr()
const TfToken integrator; const TfToken integrator;
/// \brief "legacy" /// \brief "legacy"
/// ///
@@ -138,23 +138,23 @@ struct MjcPhysicsTokensType {
const TfToken mjcAct; const TfToken mjcAct;
/// \brief "mjc:actDim" /// \brief "mjc:actDim"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcActDim; const TfToken mjcActDim;
/// \brief "mjc:actEarly" /// \brief "mjc:actEarly"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcActEarly; const TfToken mjcActEarly;
/// \brief "mjc:actLimited" /// \brief "mjc:actLimited"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcActLimited; const TfToken mjcActLimited;
/// \brief "mjc:actRange:max" /// \brief "mjc:actRange:max"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcActRangeMax; const TfToken mjcActRangeMax;
/// \brief "mjc:actRange:min" /// \brief "mjc:actRange:min"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcActRangeMin; const TfToken mjcActRangeMin;
/// \brief "mjc:actuatorfrclimited" /// \brief "mjc:actuatorfrclimited"
/// ///
@@ -178,15 +178,15 @@ struct MjcPhysicsTokensType {
const TfToken mjcArmature; const TfToken mjcArmature;
/// \brief "mjc:biasPrm" /// \brief "mjc:biasPrm"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcBiasPrm; const TfToken mjcBiasPrm;
/// \brief "mjc:biasType" /// \brief "mjc:biasType"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcBiasType; const TfToken mjcBiasType;
/// \brief "mjc:crankLength" /// \brief "mjc:crankLength"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcCrankLength; const TfToken mjcCrankLength;
/// \brief "mjc:ctrl" /// \brief "mjc:ctrl"
/// ///
@@ -194,15 +194,15 @@ struct MjcPhysicsTokensType {
const TfToken mjcCtrl; const TfToken mjcCtrl;
/// \brief "mjc:ctrlLimited" /// \brief "mjc:ctrlLimited"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcCtrlLimited; const TfToken mjcCtrlLimited;
/// \brief "mjc:ctrlRange:max" /// \brief "mjc:ctrlRange:max"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcCtrlRangeMax; const TfToken mjcCtrlRangeMax;
/// \brief "mjc:ctrlRange:min" /// \brief "mjc:ctrlRange:min"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcCtrlRangeMin; const TfToken mjcCtrlRangeMin;
/// \brief "mjc:damping" /// \brief "mjc:damping"
/// ///
@@ -210,11 +210,11 @@ struct MjcPhysicsTokensType {
const TfToken mjcDamping; const TfToken mjcDamping;
/// \brief "mjc:dynPrm" /// \brief "mjc:dynPrm"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcDynPrm; const TfToken mjcDynPrm;
/// \brief "mjc:dynType" /// \brief "mjc:dynType"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcDynType; const TfToken mjcDynType;
/// \brief "mjc:flag:actuation" /// \brief "mjc:flag:actuation"
/// ///
@@ -310,15 +310,15 @@ struct MjcPhysicsTokensType {
const TfToken mjcFlagWarmstart; const TfToken mjcFlagWarmstart;
/// \brief "mjc:forceLimited" /// \brief "mjc:forceLimited"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcForceLimited; const TfToken mjcForceLimited;
/// \brief "mjc:forceRange:max" /// \brief "mjc:forceRange:max"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcForceRangeMax; const TfToken mjcForceRangeMax;
/// \brief "mjc:forceRange:min" /// \brief "mjc:forceRange:min"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcForceRangeMin; const TfToken mjcForceRangeMin;
/// \brief "mjc:frictionloss" /// \brief "mjc:frictionloss"
/// ///
@@ -326,31 +326,35 @@ struct MjcPhysicsTokensType {
const TfToken mjcFrictionloss; const TfToken mjcFrictionloss;
/// \brief "mjc:gainPrm" /// \brief "mjc:gainPrm"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcGainPrm; const TfToken mjcGainPrm;
/// \brief "mjc:gainType" /// \brief "mjc:gainType"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcGainType; const TfToken mjcGainType;
/// \brief "mjc:gear" /// \brief "mjc:gear"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcGear; const TfToken mjcGear;
/// \brief "mjc:group"
///
/// MjcPhysicsTransmission
const TfToken mjcGroup;
/// \brief "mjc:inertia" /// \brief "mjc:inertia"
/// ///
/// MjcPhysicsMeshCollisionAPI /// MjcPhysicsMeshCollisionAPI
const TfToken mjcInertia; const TfToken mjcInertia;
/// \brief "mjc:jointInParent" /// \brief "mjc:jointInParent"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcJointInParent; const TfToken mjcJointInParent;
/// \brief "mjc:lengthRange:max" /// \brief "mjc:lengthRange:max"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcLengthRangeMax; const TfToken mjcLengthRangeMax;
/// \brief "mjc:lengthRange:min" /// \brief "mjc:lengthRange:min"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcLengthRangeMin; const TfToken mjcLengthRangeMin;
/// \brief "mjc:margin" /// \brief "mjc:margin"
/// ///
@@ -486,7 +490,7 @@ struct MjcPhysicsTokensType {
const TfToken mjcRef; const TfToken mjcRef;
/// \brief "mjc:refSite" /// \brief "mjc:refSite"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcRefSite; const TfToken mjcRefSite;
/// \brief "mjc:shellinertia" /// \brief "mjc:shellinertia"
/// ///
@@ -494,7 +498,7 @@ struct MjcPhysicsTokensType {
const TfToken mjcShellinertia; const TfToken mjcShellinertia;
/// \brief "mjc:sliderSite" /// \brief "mjc:sliderSite"
/// ///
/// MjcPhysicsActuatorAPI /// MjcPhysicsTransmission
const TfToken mjcSliderSite; const TfToken mjcSliderSite;
/// \brief "mjc:solimpfriction" /// \brief "mjc:solimpfriction"
/// ///
@@ -524,11 +528,15 @@ struct MjcPhysicsTokensType {
/// ///
/// MjcPhysicsJointAPI /// MjcPhysicsJointAPI
const TfToken mjcStiffness; const TfToken mjcStiffness;
/// \brief "mjc:target"
///
/// MjcPhysicsTransmission
const TfToken mjcTarget;
/// \brief "muscle" /// \brief "muscle"
/// ///
/// Possible value for MjcPhysicsActuatorAPI::GetMjcBiasTypeAttr(), Possible /// Possible value for MjcPhysicsTransmission::GetMjcBiasTypeAttr(), Possible
/// value for MjcPhysicsActuatorAPI::GetMjcDynTypeAttr(), Possible value for /// value for MjcPhysicsTransmission::GetMjcDynTypeAttr(), Possible value for
/// MjcPhysicsActuatorAPI::GetMjcGainTypeAttr() /// MjcPhysicsTransmission::GetMjcGainTypeAttr()
const TfToken muscle; const TfToken muscle;
/// \brief "newton" /// \brief "newton"
/// ///
@@ -537,8 +545,8 @@ struct MjcPhysicsTokensType {
const TfToken newton; const TfToken newton;
/// \brief "none" /// \brief "none"
/// ///
/// Fallback value for MjcPhysicsActuatorAPI::GetMjcBiasTypeAttr(), Fallback /// Fallback value for MjcPhysicsTransmission::GetMjcBiasTypeAttr(), Fallback
/// value for MjcPhysicsActuatorAPI::GetMjcDynTypeAttr() /// value for MjcPhysicsTransmission::GetMjcDynTypeAttr()
const TfToken none; const TfToken none;
/// \brief "pgs" /// \brief "pgs"
/// ///
@@ -566,21 +574,17 @@ struct MjcPhysicsTokensType {
const TfToken sparse; const TfToken sparse;
/// \brief "true" /// \brief "true"
/// ///
/// Possible value for MjcPhysicsActuatorAPI::GetMjcActLimitedAttr(), Possible /// Possible value for MjcPhysicsTransmission::GetMjcActLimitedAttr(),
/// value for MjcPhysicsActuatorAPI::GetMjcCtrlLimitedAttr(), Possible value /// Possible value for MjcPhysicsTransmission::GetMjcCtrlLimitedAttr(),
/// for MjcPhysicsActuatorAPI::GetMjcForceLimitedAttr(), Possible value for /// Possible value for MjcPhysicsTransmission::GetMjcForceLimitedAttr(),
/// MjcPhysicsJointAPI::GetMjcActuatorfrclimitedAttr() /// Possible value for MjcPhysicsJointAPI::GetMjcActuatorfrclimitedAttr()
const TfToken true_; const TfToken true_;
/// \brief "user" /// \brief "user"
/// ///
/// Possible value for MjcPhysicsActuatorAPI::GetMjcBiasTypeAttr(), Possible /// Possible value for MjcPhysicsTransmission::GetMjcBiasTypeAttr(), Possible
/// value for MjcPhysicsActuatorAPI::GetMjcDynTypeAttr(), Possible value for /// value for MjcPhysicsTransmission::GetMjcDynTypeAttr(), Possible value for
/// MjcPhysicsActuatorAPI::GetMjcGainTypeAttr() /// MjcPhysicsTransmission::GetMjcGainTypeAttr()
const TfToken user; const TfToken user;
/// \brief "MjcActuatorAPI"
///
/// Schema identifier and family for MjcPhysicsActuatorAPI
const TfToken MjcActuatorAPI;
/// \brief "MjcCollisionAPI" /// \brief "MjcCollisionAPI"
/// ///
/// Schema identifier and family for MjcPhysicsCollisionAPI /// Schema identifier and family for MjcPhysicsCollisionAPI
@@ -605,6 +609,10 @@ struct MjcPhysicsTokensType {
/// ///
/// Schema identifier and family for MjcPhysicsSiteAPI /// Schema identifier and family for MjcPhysicsSiteAPI
const TfToken MjcSiteAPI; const TfToken MjcSiteAPI;
/// \brief "MjcTransmission"
///
/// Schema identifier and family for MjcPhysicsTransmission
const TfToken MjcTransmission;
/// A vector of all of the tokens listed above. /// A vector of all of the tokens listed above.
const std::vector<TfToken> allTokens; const std::vector<TfToken> allTokens;
}; };
@@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifndef MJCPHYSICS_GENERATED_ACTUATORAPI_H #ifndef MJCPHYSICS_GENERATED_TRANSMISSION_H
#define MJCPHYSICS_GENERATED_ACTUATORAPI_H #define MJCPHYSICS_GENERATED_TRANSMISSION_H
/// \file mjcPhysics/actuatorAPI.h /// \file mjcPhysics/transmission.h
#include <mujoco/experimental/usd/mjcPhysics/api.h> #include <mujoco/experimental/usd/mjcPhysics/api.h>
#include <mujoco/experimental/usd/mjcPhysics/tokens.h> #include <mujoco/experimental/usd/mjcPhysics/tokens.h>
@@ -26,50 +26,51 @@
#include <pxr/base/tf/type.h> #include <pxr/base/tf/type.h>
#include <pxr/base/vt/value.h> #include <pxr/base/vt/value.h>
#include <pxr/pxr.h> #include <pxr/pxr.h>
#include <pxr/usd/usd/apiSchemaBase.h>
#include <pxr/usd/usd/prim.h> #include <pxr/usd/usd/prim.h>
#include <pxr/usd/usd/stage.h> #include <pxr/usd/usd/stage.h>
#include <pxr/usd/usd/typed.h>
PXR_NAMESPACE_OPEN_SCOPE PXR_NAMESPACE_OPEN_SCOPE
class SdfAssetPath; class SdfAssetPath;
// -------------------------------------------------------------------------- // // -------------------------------------------------------------------------- //
// MJCACTUATORAPI // // MJCTRANSMISSION //
// -------------------------------------------------------------------------- // // -------------------------------------------------------------------------- //
/// \class MjcPhysicsActuatorAPI /// \class MjcPhysicsTransmission
/// ///
/// API describing a Mujoco actuator. /// Known as actuator in MuJoCo, this prim represents force transmission to
/// joints, bodies, or sites.
/// ///
/// For any described attribute \em Fallback \em Value or \em Allowed \em Values /// For any described attribute \em Fallback \em Value or \em Allowed \em Values
/// below that are text/tokens, the actual token is published and defined in /// below that are text/tokens, the actual token is published and defined in
/// \ref MjcPhysicsTokens. So to set an attribute to the value "rightHanded", /// \ref MjcPhysicsTokens. So to set an attribute to the value "rightHanded",
/// use MjcPhysicsTokens->rightHanded as the value. /// use MjcPhysicsTokens->rightHanded as the value.
/// ///
class MjcPhysicsActuatorAPI : public UsdAPISchemaBase { class MjcPhysicsTransmission : public UsdTyped {
public: public:
/// Compile time constant representing what kind of schema this class is. /// Compile time constant representing what kind of schema this class is.
/// ///
/// \sa UsdSchemaKind /// \sa UsdSchemaKind
static const UsdSchemaKind schemaKind = UsdSchemaKind::SingleApplyAPI; static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
/// Construct a MjcPhysicsActuatorAPI on UsdPrim \p prim . /// Construct a MjcPhysicsTransmission on UsdPrim \p prim .
/// Equivalent to MjcPhysicsActuatorAPI::Get(prim.GetStage(), prim.GetPath()) /// Equivalent to MjcPhysicsTransmission::Get(prim.GetStage(), prim.GetPath())
/// for a \em valid \p prim, but will not immediately throw an error for /// for a \em valid \p prim, but will not immediately throw an error for
/// an invalid \p prim /// an invalid \p prim
explicit MjcPhysicsActuatorAPI(const UsdPrim &prim = UsdPrim()) explicit MjcPhysicsTransmission(const UsdPrim &prim = UsdPrim())
: UsdAPISchemaBase(prim) {} : UsdTyped(prim) {}
/// Construct a MjcPhysicsActuatorAPI on the prim held by \p schemaObj . /// Construct a MjcPhysicsTransmission on the prim held by \p schemaObj .
/// Should be preferred over MjcPhysicsActuatorAPI(schemaObj.GetPrim()), /// Should be preferred over MjcPhysicsTransmission(schemaObj.GetPrim()),
/// as it preserves SchemaBase state. /// as it preserves SchemaBase state.
explicit MjcPhysicsActuatorAPI(const UsdSchemaBase &schemaObj) explicit MjcPhysicsTransmission(const UsdSchemaBase &schemaObj)
: UsdAPISchemaBase(schemaObj) {} : UsdTyped(schemaObj) {}
/// Destructor. /// Destructor.
MJCPHYSICS_API MJCPHYSICS_API
virtual ~MjcPhysicsActuatorAPI(); virtual ~MjcPhysicsTransmission();
/// Return a vector of names of all pre-declared attributes for this schema /// Return a vector of names of all pre-declared attributes for this schema
/// class and all its ancestor classes. Does not include attributes that /// class and all its ancestor classes. Does not include attributes that
@@ -78,55 +79,44 @@ class MjcPhysicsActuatorAPI : public UsdAPISchemaBase {
static const TfTokenVector &GetSchemaAttributeNames( static const TfTokenVector &GetSchemaAttributeNames(
bool includeInherited = true); bool includeInherited = true);
/// Return a MjcPhysicsActuatorAPI holding the prim adhering to this /// Return a MjcPhysicsTransmission holding the prim adhering to this
/// schema at \p path on \p stage. If no prim exists at \p path on /// 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, /// \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: /// return an invalid schema object. This is shorthand for the following:
/// ///
/// \code /// \code
/// MjcPhysicsActuatorAPI(stage->GetPrimAtPath(path)); /// MjcPhysicsTransmission(stage->GetPrimAtPath(path));
/// \endcode /// \endcode
/// ///
MJCPHYSICS_API MJCPHYSICS_API
static MjcPhysicsActuatorAPI Get(const UsdStagePtr &stage, static MjcPhysicsTransmission Get(const UsdStagePtr &stage,
const SdfPath &path); const SdfPath &path);
/// Returns true if this <b>single-apply</b> API schema can be applied to /// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
/// the given \p prim. If this schema can not be a applied to the prim, /// is defined (according to UsdPrim::IsDefined()) on this stage.
/// this returns false and, if provided, populates \p whyNot with the
/// reason it can not be applied.
/// ///
/// Note that if CanApply returns false, that does not necessarily imply /// If a prim adhering to this schema at \p path is already defined on this
/// that calling Apply will fail. Callers are expected to call CanApply /// stage, return that prim. Otherwise author an \a SdfPrimSpec with
/// before calling Apply if they want to ensure that it is valid to /// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
/// apply a schema. /// 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.
/// ///
/// \sa UsdPrim::GetAppliedSchemas() /// The given \a path must be an absolute prim path that does not contain
/// \sa UsdPrim::HasAPI() /// any variant selections.
/// \sa UsdPrim::CanApplyAPI() ///
/// \sa UsdPrim::ApplyAPI() /// If it is impossible to author any of the necessary PrimSpecs, (for
/// \sa UsdPrim::RemoveAPI() /// 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 MJCPHYSICS_API
static bool CanApply(const UsdPrim &prim, std::string *whyNot = nullptr); static MjcPhysicsTransmission Define(const UsdStagePtr &stage,
const SdfPath &path);
/// Applies this <b>single-apply</b> API schema to the given \p prim.
/// This information is stored by adding "MjcActuatorAPI" to the
/// token-valued, listOp metadata \em apiSchemas on the prim.
///
/// \return A valid MjcPhysicsActuatorAPI object is returned upon success.
/// An invalid (or empty) MjcPhysicsActuatorAPI object is returned upon
/// failure. See \ref UsdPrim::ApplyAPI() for conditions
/// resulting in failure.
///
/// \sa UsdPrim::GetAppliedSchemas()
/// \sa UsdPrim::HasAPI()
/// \sa UsdPrim::CanApplyAPI()
/// \sa UsdPrim::ApplyAPI()
/// \sa UsdPrim::RemoveAPI()
///
MJCPHYSICS_API
static MjcPhysicsActuatorAPI Apply(const UsdPrim &prim);
protected: protected:
/// Returns the kind of schema this class belongs to. /// Returns the kind of schema this class belongs to.
@@ -147,6 +137,30 @@ class MjcPhysicsActuatorAPI : public UsdAPISchemaBase {
MJCPHYSICS_API MJCPHYSICS_API
const TfType &_GetTfType() const override; const TfType &_GetTfType() const override;
public:
// --------------------------------------------------------------------- //
// GROUP
// --------------------------------------------------------------------- //
/// Integer MuJoCo group to which the transmission belongs.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform int mjc:group = 0` |
/// | C++ Type | int |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Int |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetGroupAttr() const;
/// See GetGroupAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
MJCPHYSICS_API
UsdAttribute CreateGroupAttr(VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public: public:
// --------------------------------------------------------------------- // // --------------------------------------------------------------------- //
// MJCCTRLLIMITED // MJCCTRLLIMITED
@@ -750,6 +764,20 @@ class MjcPhysicsActuatorAPI : public UsdAPISchemaBase {
UsdAttribute CreateMjcActEarlyAttr(VtValue const &defaultValue = VtValue(), UsdAttribute CreateMjcActEarlyAttr(VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const; bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCTARGET
// --------------------------------------------------------------------- //
/// Actuator transmission target.
///
MJCPHYSICS_API
UsdRelationship GetMjcTargetRel() const;
/// See GetMjcTargetRel(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create
MJCPHYSICS_API
UsdRelationship CreateMjcTargetRel() const;
public: public:
// --------------------------------------------------------------------- // // --------------------------------------------------------------------- //
// MJCREFSITE // MJCREFSITE
+1 -1
View File
@@ -172,7 +172,6 @@ target_include_directories(${MJCF_PLUGIN_TARGET_NAME} PRIVATE
add_library(${MJC_PHYSICS_PLUGIN_TARGET_NAME} SHARED) add_library(${MJC_PHYSICS_PLUGIN_TARGET_NAME} SHARED)
target_sources(${MJC_PHYSICS_PLUGIN_TARGET_NAME} PRIVATE target_sources(${MJC_PHYSICS_PLUGIN_TARGET_NAME} PRIVATE
mjcPhysics/actuatorAPI.cpp
mjcPhysics/collisionAPI.cpp mjcPhysics/collisionAPI.cpp
mjcPhysics/jointAPI.cpp mjcPhysics/jointAPI.cpp
mjcPhysics/keyframe.cpp mjcPhysics/keyframe.cpp
@@ -180,6 +179,7 @@ target_sources(${MJC_PHYSICS_PLUGIN_TARGET_NAME} PRIVATE
mjcPhysics/sceneAPI.cpp mjcPhysics/sceneAPI.cpp
mjcPhysics/siteAPI.cpp mjcPhysics/siteAPI.cpp
mjcPhysics/tokens.cpp mjcPhysics/tokens.cpp
mjcPhysics/transmission.cpp
) )
set_target_properties(${MJC_PHYSICS_PLUGIN_TARGET_NAME} PROPERTIES set_target_properties(${MJC_PHYSICS_PLUGIN_TARGET_NAME} PROPERTIES
OUTPUT_NAME ${MJC_PHYSICS_PLUGIN_TARGET_NAME} OUTPUT_NAME ${MJC_PHYSICS_PLUGIN_TARGET_NAME}
@@ -251,8 +251,8 @@ class "MjcMeshCollisionAPI" (
) )
} }
class "MjcActuatorAPI" ( class MjcTransmission "MjcTransmission" (
doc = "API describing a Mujoco actuator." doc = "Known as actuator in MuJoCo, this prim represents force transmission to joints, bodies, or sites."
) )
{ {
uniform int mjc:actDim = -1 ( uniform int mjc:actDim = -1 (
@@ -333,6 +333,9 @@ class "MjcActuatorAPI" (
rel mjc:sliderSite ( rel mjc:sliderSite (
doc = "Used only for the slider-crank transmission type. The target site is the pin joining the slider and the connecting rod. The slider moves along the z-axis of the slidersite frame. Therefore the site should be oriented as needed when it is defined in the kinematic tree; its orientation cannot be changed in the actuator definition." doc = "Used only for the slider-crank transmission type. The target site is the pin joining the slider and the connecting rod. The slider moves along the z-axis of the slidersite frame. Therefore the site should be oriented as needed when it is defined in the kinematic tree; its orientation cannot be changed in the actuator definition."
) )
rel mjc:target (
doc = "Actuator transmission target."
)
} }
class MjcKeyframe "MjcKeyframe" ( class MjcKeyframe "MjcKeyframe" (
+10 -10
View File
@@ -3,16 +3,6 @@
{ {
"Info": { "Info": {
"Types": { "Types": {
"MjcPhysicsActuatorAPI": {
"alias": {
"UsdSchemaBase": "MjcActuatorAPI"
},
"autoGenerated": true,
"bases": [
"UsdAPISchemaBase"
],
"schemaKind": "singleApplyAPI"
},
"MjcPhysicsCollisionAPI": { "MjcPhysicsCollisionAPI": {
"alias": { "alias": {
"UsdSchemaBase": "MjcCollisionAPI" "UsdSchemaBase": "MjcCollisionAPI"
@@ -72,6 +62,16 @@
"UsdAPISchemaBase" "UsdAPISchemaBase"
], ],
"schemaKind": "singleApplyAPI" "schemaKind": "singleApplyAPI"
},
"MjcPhysicsTransmission": {
"alias": {
"UsdSchemaBase": "MjcTransmission"
},
"autoGenerated": true,
"bases": [
"UsdTyped"
],
"schemaKind": "concreteTyped"
} }
} }
}, },
+8 -4
View File
@@ -569,16 +569,20 @@ class "MjcMeshCollisionAPI"
) )
} }
class "MjcActuatorAPI" class MjcTransmission "MjcTransmission"
( (
customData = { customData = {
string className = "ActuatorAPI" string className = "Transmission"
} }
doc = """API describing a Mujoco actuator.""" doc = """Known as actuator in MuJoCo, this prim represents force transmission to joints, bodies, or sites."""
inherits = </APISchemaBase> inherits = </Typed>
) )
{ {
rel mjc:target (
doc = "Actuator transmission target."
)
# Control/Force/Activation Limits # Control/Force/Activation Limits
uniform token mjc:ctrlLimited = "auto" ( uniform token mjc:ctrlLimited = "auto" (
doc = "If true, the control input to this actuator is automatically clamped to ctrlrange at runtime. If false, control input clamping is disabled. If 'auto' and autolimits is set in compiler, control clamping will automatically be set to true if ctrlrange is defined without explicitly setting this attribute to 'true'. Note that control input clamping can also be globally disabled with the clampctrl attribute of option/flag." doc = "If true, the control input to this actuator is automatically clamped to ctrlrange at runtime. If false, control input clamping is disabled. If 'auto' and autolimits is set in compiler, control clamping will automatically be set to true if ctrlrange is defined without explicitly setting this attribute to 'true'. Note that control input clamping can also be globally disabled with the clampctrl attribute of option/flag."
+5 -3
View File
@@ -134,6 +134,7 @@ MjcPhysicsTokensType::MjcPhysicsTokensType()
mjcSpringdamper("mjc:springdamper", TfToken::Immortal), mjcSpringdamper("mjc:springdamper", TfToken::Immortal),
mjcSpringref("mjc:springref", TfToken::Immortal), mjcSpringref("mjc:springref", TfToken::Immortal),
mjcStiffness("mjc:stiffness", TfToken::Immortal), mjcStiffness("mjc:stiffness", TfToken::Immortal),
mjcTarget("mjc:target", TfToken::Immortal),
muscle("muscle", TfToken::Immortal), muscle("muscle", TfToken::Immortal),
newton("newton", TfToken::Immortal), newton("newton", TfToken::Immortal),
none("none", TfToken::Immortal), none("none", TfToken::Immortal),
@@ -144,13 +145,13 @@ MjcPhysicsTokensType::MjcPhysicsTokensType()
sparse("sparse", TfToken::Immortal), sparse("sparse", TfToken::Immortal),
true_("true", TfToken::Immortal), true_("true", TfToken::Immortal),
user("user", TfToken::Immortal), user("user", TfToken::Immortal),
MjcActuatorAPI("MjcActuatorAPI", TfToken::Immortal),
MjcCollisionAPI("MjcCollisionAPI", TfToken::Immortal), MjcCollisionAPI("MjcCollisionAPI", TfToken::Immortal),
MjcJointAPI("MjcJointAPI", TfToken::Immortal), MjcJointAPI("MjcJointAPI", TfToken::Immortal),
MjcKeyframe("MjcKeyframe", TfToken::Immortal), MjcKeyframe("MjcKeyframe", TfToken::Immortal),
MjcMeshCollisionAPI("MjcMeshCollisionAPI", TfToken::Immortal), MjcMeshCollisionAPI("MjcMeshCollisionAPI", TfToken::Immortal),
MjcSceneAPI("MjcSceneAPI", TfToken::Immortal), MjcSceneAPI("MjcSceneAPI", TfToken::Immortal),
MjcSiteAPI("MjcSiteAPI", TfToken::Immortal), MjcSiteAPI("MjcSiteAPI", TfToken::Immortal),
MjcTransmission("MjcTransmission", TfToken::Immortal),
allTokens({affine, allTokens({affine,
auto_, auto_,
cg, cg,
@@ -265,6 +266,7 @@ MjcPhysicsTokensType::MjcPhysicsTokensType()
mjcSpringdamper, mjcSpringdamper,
mjcSpringref, mjcSpringref,
mjcStiffness, mjcStiffness,
mjcTarget,
muscle, muscle,
newton, newton,
none, none,
@@ -275,13 +277,13 @@ MjcPhysicsTokensType::MjcPhysicsTokensType()
sparse, sparse,
true_, true_,
user, user,
MjcActuatorAPI,
MjcCollisionAPI, MjcCollisionAPI,
MjcJointAPI, MjcJointAPI,
MjcKeyframe, MjcKeyframe,
MjcMeshCollisionAPI, MjcMeshCollisionAPI,
MjcSceneAPI, MjcSceneAPI,
MjcSiteAPI}) {} MjcSiteAPI,
MjcTransmission}) {}
TfStaticData<MjcPhysicsTokensType> MjcPhysicsTokens; TfStaticData<MjcPhysicsTokensType> MjcPhysicsTokens;
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include <mujoco/experimental/usd/mjcPhysics/actuatorAPI.h> #include <mujoco/experimental/usd/mjcPhysics/transmission.h>
#include <pxr/usd/sdf/assetPath.h> #include <pxr/usd/sdf/assetPath.h>
#include <pxr/usd/sdf/types.h> #include <pxr/usd/sdf/types.h>
@@ -23,313 +23,338 @@ PXR_NAMESPACE_OPEN_SCOPE
// Register the schema with the TfType system. // Register the schema with the TfType system.
TF_REGISTRY_FUNCTION(TfType) { TF_REGISTRY_FUNCTION(TfType) {
TfType::Define<MjcPhysicsActuatorAPI, TfType::Bases<UsdAPISchemaBase> >(); TfType::Define<MjcPhysicsTransmission, TfType::Bases<UsdTyped> >();
// Register the usd prim typename as an alias under UsdSchemaBase. This
// enables one to call
// TfType::Find<UsdSchemaBase>().FindDerivedByName("MjcTransmission")
// to find TfType<MjcPhysicsTransmission>, which is how IsA queries are
// answered.
TfType::AddAlias<UsdSchemaBase, MjcPhysicsTransmission>("MjcTransmission");
} }
/* virtual */ /* virtual */
MjcPhysicsActuatorAPI::~MjcPhysicsActuatorAPI() {} MjcPhysicsTransmission::~MjcPhysicsTransmission() {}
/* static */ /* static */
MjcPhysicsActuatorAPI MjcPhysicsActuatorAPI::Get(const UsdStagePtr &stage, MjcPhysicsTransmission MjcPhysicsTransmission::Get(const UsdStagePtr &stage,
const SdfPath &path) { const SdfPath &path) {
if (!stage) { if (!stage) {
TF_CODING_ERROR("Invalid stage"); TF_CODING_ERROR("Invalid stage");
return MjcPhysicsActuatorAPI(); return MjcPhysicsTransmission();
} }
return MjcPhysicsActuatorAPI(stage->GetPrimAtPath(path)); return MjcPhysicsTransmission(stage->GetPrimAtPath(path));
}
/* static */
MjcPhysicsTransmission MjcPhysicsTransmission::Define(const UsdStagePtr &stage,
const SdfPath &path) {
static TfToken usdPrimTypeName("MjcTransmission");
if (!stage) {
TF_CODING_ERROR("Invalid stage");
return MjcPhysicsTransmission();
}
return MjcPhysicsTransmission(stage->DefinePrim(path, usdPrimTypeName));
} }
/* virtual */ /* virtual */
UsdSchemaKind MjcPhysicsActuatorAPI::_GetSchemaKind() const { UsdSchemaKind MjcPhysicsTransmission::_GetSchemaKind() const {
return MjcPhysicsActuatorAPI::schemaKind; return MjcPhysicsTransmission::schemaKind;
} }
/* static */ /* static */
bool MjcPhysicsActuatorAPI::CanApply(const UsdPrim &prim, std::string *whyNot) { const TfType &MjcPhysicsTransmission::_GetStaticTfType() {
return prim.CanApplyAPI<MjcPhysicsActuatorAPI>(whyNot); static TfType tfType = TfType::Find<MjcPhysicsTransmission>();
}
/* static */
MjcPhysicsActuatorAPI MjcPhysicsActuatorAPI::Apply(const UsdPrim &prim) {
if (prim.ApplyAPI<MjcPhysicsActuatorAPI>()) {
return MjcPhysicsActuatorAPI(prim);
}
return MjcPhysicsActuatorAPI();
}
/* static */
const TfType &MjcPhysicsActuatorAPI::_GetStaticTfType() {
static TfType tfType = TfType::Find<MjcPhysicsActuatorAPI>();
return tfType; return tfType;
} }
/* static */ /* static */
bool MjcPhysicsActuatorAPI::_IsTypedSchema() { bool MjcPhysicsTransmission::_IsTypedSchema() {
static bool isTyped = _GetStaticTfType().IsA<UsdTyped>(); static bool isTyped = _GetStaticTfType().IsA<UsdTyped>();
return isTyped; return isTyped;
} }
/* virtual */ /* virtual */
const TfType &MjcPhysicsActuatorAPI::_GetTfType() const { const TfType &MjcPhysicsTransmission::_GetTfType() const {
return _GetStaticTfType(); return _GetStaticTfType();
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcCtrlLimitedAttr() const { UsdAttribute MjcPhysicsTransmission::GetGroupAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcGroup);
}
UsdAttribute MjcPhysicsTransmission::CreateGroupAttr(
VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcGroup, SdfValueTypeNames->Int,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
}
UsdAttribute MjcPhysicsTransmission::GetMjcCtrlLimitedAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcCtrlLimited); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcCtrlLimited);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcCtrlLimitedAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcCtrlLimitedAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcCtrlLimited, SdfValueTypeNames->Token, MjcPhysicsTokens->mjcCtrlLimited, SdfValueTypeNames->Token,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcForceLimitedAttr() const { UsdAttribute MjcPhysicsTransmission::GetMjcForceLimitedAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcForceLimited); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcForceLimited);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcForceLimitedAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcForceLimitedAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcForceLimited, SdfValueTypeNames->Token, MjcPhysicsTokens->mjcForceLimited, SdfValueTypeNames->Token,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcActLimitedAttr() const { UsdAttribute MjcPhysicsTransmission::GetMjcActLimitedAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcActLimited); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcActLimited);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcActLimitedAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcActLimitedAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcActLimited, SdfValueTypeNames->Token, MjcPhysicsTokens->mjcActLimited, SdfValueTypeNames->Token,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcCtrlRangeMinAttr() const { UsdAttribute MjcPhysicsTransmission::GetMjcCtrlRangeMinAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcCtrlRangeMin); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcCtrlRangeMin);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcCtrlRangeMinAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcCtrlRangeMinAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcCtrlRangeMin, SdfValueTypeNames->Double, MjcPhysicsTokens->mjcCtrlRangeMin, SdfValueTypeNames->Double,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcCtrlRangeMaxAttr() const { UsdAttribute MjcPhysicsTransmission::GetMjcCtrlRangeMaxAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcCtrlRangeMax); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcCtrlRangeMax);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcCtrlRangeMaxAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcCtrlRangeMaxAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcCtrlRangeMax, SdfValueTypeNames->Double, MjcPhysicsTokens->mjcCtrlRangeMax, SdfValueTypeNames->Double,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcForceRangeMinAttr() const { UsdAttribute MjcPhysicsTransmission::GetMjcForceRangeMinAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcForceRangeMin); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcForceRangeMin);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcForceRangeMinAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcForceRangeMinAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcForceRangeMin, SdfValueTypeNames->Double, MjcPhysicsTokens->mjcForceRangeMin, SdfValueTypeNames->Double,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcForceRangeMaxAttr() const { UsdAttribute MjcPhysicsTransmission::GetMjcForceRangeMaxAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcForceRangeMax); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcForceRangeMax);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcForceRangeMaxAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcForceRangeMaxAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcForceRangeMax, SdfValueTypeNames->Double, MjcPhysicsTokens->mjcForceRangeMax, SdfValueTypeNames->Double,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcActRangeMinAttr() const { UsdAttribute MjcPhysicsTransmission::GetMjcActRangeMinAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcActRangeMin); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcActRangeMin);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcActRangeMinAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcActRangeMinAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcActRangeMin, SdfValueTypeNames->Double, MjcPhysicsTokens->mjcActRangeMin, SdfValueTypeNames->Double,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcActRangeMaxAttr() const { UsdAttribute MjcPhysicsTransmission::GetMjcActRangeMaxAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcActRangeMax); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcActRangeMax);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcActRangeMaxAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcActRangeMaxAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcActRangeMax, SdfValueTypeNames->Double, MjcPhysicsTokens->mjcActRangeMax, SdfValueTypeNames->Double,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcLengthRangeMinAttr() const { UsdAttribute MjcPhysicsTransmission::GetMjcLengthRangeMinAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcLengthRangeMin); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcLengthRangeMin);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcLengthRangeMinAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcLengthRangeMinAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcLengthRangeMin, SdfValueTypeNames->Double, MjcPhysicsTokens->mjcLengthRangeMin, SdfValueTypeNames->Double,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcLengthRangeMaxAttr() const { UsdAttribute MjcPhysicsTransmission::GetMjcLengthRangeMaxAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcLengthRangeMax); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcLengthRangeMax);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcLengthRangeMaxAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcLengthRangeMaxAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcLengthRangeMax, SdfValueTypeNames->Double, MjcPhysicsTokens->mjcLengthRangeMax, SdfValueTypeNames->Double,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcGearAttr() const { UsdAttribute MjcPhysicsTransmission::GetMjcGearAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcGear); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcGear);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcGearAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcGearAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcGear, SdfValueTypeNames->DoubleArray, MjcPhysicsTokens->mjcGear, SdfValueTypeNames->DoubleArray,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcCrankLengthAttr() const { UsdAttribute MjcPhysicsTransmission::GetMjcCrankLengthAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcCrankLength); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcCrankLength);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcCrankLengthAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcCrankLengthAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcCrankLength, SdfValueTypeNames->Double, MjcPhysicsTokens->mjcCrankLength, SdfValueTypeNames->Double,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcJointInParentAttr() const { UsdAttribute MjcPhysicsTransmission::GetMjcJointInParentAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcJointInParent); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcJointInParent);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcJointInParentAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcJointInParentAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcJointInParent, SdfValueTypeNames->Bool, MjcPhysicsTokens->mjcJointInParent, SdfValueTypeNames->Bool,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcActDimAttr() const { UsdAttribute MjcPhysicsTransmission::GetMjcActDimAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcActDim); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcActDim);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcActDimAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcActDimAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcActDim, SdfValueTypeNames->Int, MjcPhysicsTokens->mjcActDim, SdfValueTypeNames->Int,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcDynTypeAttr() const { UsdAttribute MjcPhysicsTransmission::GetMjcDynTypeAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcDynType); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcDynType);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcDynTypeAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcDynTypeAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcDynType, SdfValueTypeNames->Token, MjcPhysicsTokens->mjcDynType, SdfValueTypeNames->Token,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcGainTypeAttr() const { UsdAttribute MjcPhysicsTransmission::GetMjcGainTypeAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcGainType); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcGainType);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcGainTypeAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcGainTypeAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcGainType, SdfValueTypeNames->Token, MjcPhysicsTokens->mjcGainType, SdfValueTypeNames->Token,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcBiasTypeAttr() const { UsdAttribute MjcPhysicsTransmission::GetMjcBiasTypeAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcBiasType); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcBiasType);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcBiasTypeAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcBiasTypeAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcBiasType, SdfValueTypeNames->Token, MjcPhysicsTokens->mjcBiasType, SdfValueTypeNames->Token,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcDynPrmAttr() const { UsdAttribute MjcPhysicsTransmission::GetMjcDynPrmAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcDynPrm); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcDynPrm);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcDynPrmAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcDynPrmAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcDynPrm, SdfValueTypeNames->DoubleArray, MjcPhysicsTokens->mjcDynPrm, SdfValueTypeNames->DoubleArray,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcGainPrmAttr() const { UsdAttribute MjcPhysicsTransmission::GetMjcGainPrmAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcGainPrm); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcGainPrm);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcGainPrmAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcGainPrmAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcGainPrm, SdfValueTypeNames->DoubleArray, MjcPhysicsTokens->mjcGainPrm, SdfValueTypeNames->DoubleArray,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcBiasPrmAttr() const { UsdAttribute MjcPhysicsTransmission::GetMjcBiasPrmAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcBiasPrm); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcBiasPrm);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcBiasPrmAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcBiasPrmAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcBiasPrm, SdfValueTypeNames->DoubleArray, MjcPhysicsTokens->mjcBiasPrm, SdfValueTypeNames->DoubleArray,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdAttribute MjcPhysicsActuatorAPI::GetMjcActEarlyAttr() const { UsdAttribute MjcPhysicsTransmission::GetMjcActEarlyAttr() const {
return GetPrim().GetAttribute(MjcPhysicsTokens->mjcActEarly); return GetPrim().GetAttribute(MjcPhysicsTokens->mjcActEarly);
} }
UsdAttribute MjcPhysicsActuatorAPI::CreateMjcActEarlyAttr( UsdAttribute MjcPhysicsTransmission::CreateMjcActEarlyAttr(
VtValue const &defaultValue, bool writeSparsely) const { VtValue const &defaultValue, bool writeSparsely) const {
return UsdSchemaBase::_CreateAttr( return UsdSchemaBase::_CreateAttr(
MjcPhysicsTokens->mjcActEarly, SdfValueTypeNames->Bool, MjcPhysicsTokens->mjcActEarly, SdfValueTypeNames->Bool,
/* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely); /* custom = */ false, SdfVariabilityUniform, defaultValue, writeSparsely);
} }
UsdRelationship MjcPhysicsActuatorAPI::GetMjcRefSiteRel() const { UsdRelationship MjcPhysicsTransmission::GetMjcTargetRel() const {
return GetPrim().GetRelationship(MjcPhysicsTokens->mjcTarget);
}
UsdRelationship MjcPhysicsTransmission::CreateMjcTargetRel() const {
return GetPrim().CreateRelationship(MjcPhysicsTokens->mjcTarget,
/* custom = */ false);
}
UsdRelationship MjcPhysicsTransmission::GetMjcRefSiteRel() const {
return GetPrim().GetRelationship(MjcPhysicsTokens->mjcRefSite); return GetPrim().GetRelationship(MjcPhysicsTokens->mjcRefSite);
} }
UsdRelationship MjcPhysicsActuatorAPI::CreateMjcRefSiteRel() const { UsdRelationship MjcPhysicsTransmission::CreateMjcRefSiteRel() const {
return GetPrim().CreateRelationship(MjcPhysicsTokens->mjcRefSite, return GetPrim().CreateRelationship(MjcPhysicsTokens->mjcRefSite,
/* custom = */ false); /* custom = */ false);
} }
UsdRelationship MjcPhysicsActuatorAPI::GetMjcSliderSiteRel() const { UsdRelationship MjcPhysicsTransmission::GetMjcSliderSiteRel() const {
return GetPrim().GetRelationship(MjcPhysicsTokens->mjcSliderSite); return GetPrim().GetRelationship(MjcPhysicsTokens->mjcSliderSite);
} }
UsdRelationship MjcPhysicsActuatorAPI::CreateMjcSliderSiteRel() const { UsdRelationship MjcPhysicsTransmission::CreateMjcSliderSiteRel() const {
return GetPrim().CreateRelationship(MjcPhysicsTokens->mjcSliderSite, return GetPrim().CreateRelationship(MjcPhysicsTokens->mjcSliderSite,
/* custom = */ false); /* custom = */ false);
} }
@@ -346,23 +371,24 @@ static inline TfTokenVector _ConcatenateAttributeNames(
} // namespace } // namespace
/*static*/ /*static*/
const TfTokenVector &MjcPhysicsActuatorAPI::GetSchemaAttributeNames( const TfTokenVector &MjcPhysicsTransmission::GetSchemaAttributeNames(
bool includeInherited) { bool includeInherited) {
static TfTokenVector localNames = { static TfTokenVector localNames = {
MjcPhysicsTokens->mjcCtrlLimited, MjcPhysicsTokens->mjcForceLimited, MjcPhysicsTokens->mjcGroup, MjcPhysicsTokens->mjcCtrlLimited,
MjcPhysicsTokens->mjcActLimited, MjcPhysicsTokens->mjcCtrlRangeMin, MjcPhysicsTokens->mjcForceLimited, MjcPhysicsTokens->mjcActLimited,
MjcPhysicsTokens->mjcCtrlRangeMax, MjcPhysicsTokens->mjcForceRangeMin, MjcPhysicsTokens->mjcCtrlRangeMin, MjcPhysicsTokens->mjcCtrlRangeMax,
MjcPhysicsTokens->mjcForceRangeMax, MjcPhysicsTokens->mjcActRangeMin, MjcPhysicsTokens->mjcForceRangeMin, MjcPhysicsTokens->mjcForceRangeMax,
MjcPhysicsTokens->mjcActRangeMax, MjcPhysicsTokens->mjcLengthRangeMin, MjcPhysicsTokens->mjcActRangeMin, MjcPhysicsTokens->mjcActRangeMax,
MjcPhysicsTokens->mjcLengthRangeMax, MjcPhysicsTokens->mjcGear, MjcPhysicsTokens->mjcLengthRangeMin, MjcPhysicsTokens->mjcLengthRangeMax,
MjcPhysicsTokens->mjcCrankLength, MjcPhysicsTokens->mjcJointInParent, MjcPhysicsTokens->mjcGear, MjcPhysicsTokens->mjcCrankLength,
MjcPhysicsTokens->mjcActDim, MjcPhysicsTokens->mjcDynType, MjcPhysicsTokens->mjcJointInParent, MjcPhysicsTokens->mjcActDim,
MjcPhysicsTokens->mjcGainType, MjcPhysicsTokens->mjcBiasType, MjcPhysicsTokens->mjcDynType, MjcPhysicsTokens->mjcGainType,
MjcPhysicsTokens->mjcDynPrm, MjcPhysicsTokens->mjcGainPrm, MjcPhysicsTokens->mjcBiasType, MjcPhysicsTokens->mjcDynPrm,
MjcPhysicsTokens->mjcBiasPrm, MjcPhysicsTokens->mjcActEarly, MjcPhysicsTokens->mjcGainPrm, MjcPhysicsTokens->mjcBiasPrm,
MjcPhysicsTokens->mjcActEarly,
}; };
static TfTokenVector allNames = _ConcatenateAttributeNames( static TfTokenVector allNames = _ConcatenateAttributeNames(
UsdAPISchemaBase::GetSchemaAttributeNames(true), localNames); UsdTyped::GetSchemaAttributeNames(true), localNames);
if (includeInherited) if (includeInherited)
return allNames; return allNames;
@@ -86,6 +86,7 @@ TF_DEFINE_PRIVATE_TOKENS(kTokens,
((materialsScope, "Materials")) ((materialsScope, "Materials"))
((previewSurface, "PreviewSurface")) ((previewSurface, "PreviewSurface"))
((keyframesScope, "Keyframes")) ((keyframesScope, "Keyframes"))
((transmissionsScope, "Transmissions"))
((keyframe, "Keyframe")) ((keyframe, "Keyframe"))
((surface, "PreviewSurface")) ((surface, "PreviewSurface"))
((world, "World")) ((world, "World"))
@@ -210,7 +211,7 @@ class ModelWriter {
WriteMaterials(); WriteMaterials();
WriteBodies(); WriteBodies();
if (write_physics_) { if (write_physics_) {
WriteActuators(); WriteTransmissions();
} }
WriteKeyframes(); WriteKeyframes();
} }
@@ -1050,27 +1051,39 @@ class ModelWriter {
} }
} }
void WriteActuator(mjsActuator *actuator) { void WriteTransmission(mjsActuator *actuator,
pxr::SdfPath transmission_path; const pxr::SdfPath &parent_path) {
pxr::TfToken valid_name = GetValidPrimName(*mjs_getName(actuator->element));
pxr::SdfPath transmission_path = parent_path.AppendChild(valid_name);
if (!data_->HasSpec(transmission_path)) {
CreatePrimSpec(data_, parent_path, valid_name,
pxr::MjcPhysicsTokens->MjcTransmission);
}
pxr::SdfPath target_path;
if (actuator->trntype == mjtTrn::mjTRN_BODY) { if (actuator->trntype == mjtTrn::mjTRN_BODY) {
int body_id = mj_name2id(model_, mjOBJ_BODY, actuator->target->c_str()); int body_id = mj_name2id(model_, mjOBJ_BODY, actuator->target->c_str());
transmission_path = body_paths_[body_id]; target_path = body_paths_[body_id];
} else if (actuator->trntype == mjtTrn::mjTRN_SITE || } else if (actuator->trntype == mjtTrn::mjTRN_SITE ||
actuator->trntype == mjtTrn::mjTRN_SLIDERCRANK) { actuator->trntype == mjtTrn::mjTRN_SLIDERCRANK) {
int site_id = mj_name2id(model_, mjOBJ_SITE, actuator->target->c_str()); int site_id = mj_name2id(model_, mjOBJ_SITE, actuator->target->c_str());
transmission_path = site_paths_[site_id]; target_path = site_paths_[site_id];
} else if (actuator->trntype == mjtTrn::mjTRN_JOINT) { } else if (actuator->trntype == mjtTrn::mjTRN_JOINT) {
int joint_id = mj_name2id(model_, mjOBJ_JOINT, actuator->target->c_str()); int joint_id = mj_name2id(model_, mjOBJ_JOINT, actuator->target->c_str());
transmission_path = joint_paths_[joint_id]; target_path = joint_paths_[joint_id];
} else { } else {
TF_WARN(UnsupportedActuatorTypeError, TF_WARN(UnsupportedActuatorTypeError,
"Unsupported actuator type for actuator %d", "Unsupported transmission type for actuator %d",
mjs_getId(actuator->element)); mjs_getId(actuator->element));
return; return;
} }
ApplyApiSchema(data_, transmission_path, CreateRelationshipSpec(data_, transmission_path,
MjcPhysicsTokens->MjcActuatorAPI); MjcPhysicsTokens->mjcTarget, target_path,
pxr::SdfVariabilityUniform);
WriteUniformAttribute(transmission_path, pxr::SdfValueTypeNames->Int,
MjcPhysicsTokens->mjcGroup, actuator->group);
if (!actuator->refsite->empty()) { if (!actuator->refsite->empty()) {
int refsite_id = int refsite_id =
@@ -1190,11 +1203,14 @@ class ModelWriter {
pxr::VtDoubleArray(actuator->biasprm, actuator->biasprm + 10)); pxr::VtDoubleArray(actuator->biasprm, actuator->biasprm + 10));
} }
void WriteActuators() { void WriteTransmissions() {
pxr::SdfPath scope_path =
CreatePrimSpec(data_, body_paths_[kWorldIndex],
kTokens->transmissionsScope, pxr::UsdGeomTokens->Scope);
mjsActuator *actuator = mjsActuator *actuator =
mjs_asActuator(mjs_firstElement(spec_, mjOBJ_ACTUATOR)); mjs_asActuator(mjs_firstElement(spec_, mjOBJ_ACTUATOR));
while (actuator) { while (actuator) {
WriteActuator(actuator); WriteTransmission(actuator, scope_path);
actuator = mjs_asActuator(mjs_nextElement(spec_, actuator->element)); actuator = mjs_asActuator(mjs_nextElement(spec_, actuator->element));
} }
} }
+63 -61
View File
@@ -21,7 +21,6 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include <mujoco/experimental/usd/mjcPhysics/actuatorAPI.h>
#include <mujoco/experimental/usd/mjcPhysics/collisionAPI.h> #include <mujoco/experimental/usd/mjcPhysics/collisionAPI.h>
#include <mujoco/experimental/usd/mjcPhysics/jointAPI.h> #include <mujoco/experimental/usd/mjcPhysics/jointAPI.h>
#include <mujoco/experimental/usd/mjcPhysics/keyframe.h> #include <mujoco/experimental/usd/mjcPhysics/keyframe.h>
@@ -29,6 +28,7 @@
#include <mujoco/experimental/usd/mjcPhysics/sceneAPI.h> #include <mujoco/experimental/usd/mjcPhysics/sceneAPI.h>
#include <mujoco/experimental/usd/mjcPhysics/siteAPI.h> #include <mujoco/experimental/usd/mjcPhysics/siteAPI.h>
#include <mujoco/experimental/usd/mjcPhysics/tokens.h> #include <mujoco/experimental/usd/mjcPhysics/tokens.h>
#include <mujoco/experimental/usd/mjcPhysics/transmission.h>
#include <mujoco/experimental/usd/usd.h> #include <mujoco/experimental/usd/usd.h>
#include <mujoco/experimental/usd/utils.h> #include <mujoco/experimental/usd/utils.h>
#include <mujoco/mujoco.h> #include <mujoco/mujoco.h>
@@ -553,19 +553,46 @@ void ParseMjcPhysicsMeshCollisionAPI(
} }
} }
void ParseMjcPhysicsGeneralActuatorAPI(mjSpec* spec, void ParseMjcPhysicsTransmission(mjSpec* spec,
const pxr::MjcPhysicsActuatorAPI& act, const pxr::MjcPhysicsTransmission& tran) {
mjtTrn tran_type, pxr::UsdPrim prim = tran.GetPrim();
const std::string* name) {
pxr::UsdPrim prim = act.GetPrim();
mjsActuator* mj_act = mjs_addActuator(spec, nullptr); mjsActuator* mj_act = mjs_addActuator(spec, nullptr);
mjs_setName(mj_act->element, prim.GetPath().GetAsString().c_str()); mjs_setName(mj_act->element, prim.GetPath().GetAsString().c_str());
mjs_setString(mj_act->target, name->c_str());
mj_act->trntype = tran_type;
if (tran_type == mjtTrn::mjTRN_SLIDERCRANK) { auto group_attr = tran.GetGroupAttr();
if (group_attr.HasAuthoredValue()) {
group_attr.Get(&mj_act->group);
}
pxr::SdfPathVector targets;
tran.GetMjcTargetRel().GetTargets(&targets);
if (targets.empty()) {
mju_warning("Transmission %s has no target, skipping.",
prim.GetPath().GetAsString().c_str());
return;
}
if (targets.size() > 1) {
mju_warning("Transmission has more than one target, using the first.");
}
mjs_setString(mj_act->target, targets[0].GetAsString().c_str());
auto target_prim = prim.GetStage()->GetPrimAtPath(targets[0]);
bool slider_crank = tran.GetMjcSliderSiteRel().HasAuthoredTargets();
if (target_prim.IsA<pxr::UsdPhysicsJoint>()) {
mj_act->trntype = mjTRN_JOINT;
} else if (target_prim.HasAPI<pxr::UsdPhysicsRigidBodyAPI>()) {
mj_act->trntype = mjTRN_BODY;
} else if (target_prim.HasAPI<pxr::MjcPhysicsSiteAPI>()) {
mj_act->trntype = slider_crank ? mjTRN_SLIDERCRANK : mjTRN_SITE;
} else {
mju_warning("Transmission %s has an invalid target type, skipping.",
prim.GetPath().GetAsString().c_str());
return;
}
if (slider_crank) {
pxr::SdfPathVector slider_sites; pxr::SdfPathVector slider_sites;
act.GetMjcSliderSiteRel().GetTargets(&slider_sites); tran.GetMjcSliderSiteRel().GetTargets(&slider_sites);
if (slider_sites.size() > 1) { if (slider_sites.size() > 1) {
mju_warning( mju_warning(
"Slider crank slider site relationship has more than one target, " "Slider crank slider site relationship has more than one target, "
@@ -590,9 +617,9 @@ void ParseMjcPhysicsGeneralActuatorAPI(mjSpec* spec,
} }
}; };
setLimitedField(mj_act, act.GetMjcCtrlLimitedAttr(), &mj_act->ctrllimited); setLimitedField(mj_act, tran.GetMjcCtrlLimitedAttr(), &mj_act->ctrllimited);
setLimitedField(mj_act, act.GetMjcForceLimitedAttr(), &mj_act->forcelimited); setLimitedField(mj_act, tran.GetMjcForceLimitedAttr(), &mj_act->forcelimited);
setLimitedField(mj_act, act.GetMjcActLimitedAttr(), &mj_act->actlimited); setLimitedField(mj_act, tran.GetMjcActLimitedAttr(), &mj_act->actlimited);
auto setRangeField = auto setRangeField =
[](mjsActuator* mj_act, const pxr::UsdAttribute& usd_min_attribute, [](mjsActuator* mj_act, const pxr::UsdAttribute& usd_min_attribute,
@@ -609,16 +636,16 @@ void ParseMjcPhysicsGeneralActuatorAPI(mjSpec* spec,
} }
}; };
setRangeField(mj_act, act.GetMjcCtrlRangeMinAttr(), setRangeField(mj_act, tran.GetMjcCtrlRangeMinAttr(),
act.GetMjcCtrlRangeMaxAttr(), mj_act->ctrlrange); tran.GetMjcCtrlRangeMaxAttr(), mj_act->ctrlrange);
setRangeField(mj_act, act.GetMjcForceRangeMinAttr(), setRangeField(mj_act, tran.GetMjcForceRangeMinAttr(),
act.GetMjcForceRangeMaxAttr(), mj_act->forcerange); tran.GetMjcForceRangeMaxAttr(), mj_act->forcerange);
setRangeField(mj_act, act.GetMjcActRangeMinAttr(), setRangeField(mj_act, tran.GetMjcActRangeMinAttr(),
act.GetMjcActRangeMaxAttr(), mj_act->actrange); tran.GetMjcActRangeMaxAttr(), mj_act->actrange);
setRangeField(mj_act, act.GetMjcLengthRangeMinAttr(), setRangeField(mj_act, tran.GetMjcLengthRangeMinAttr(),
act.GetMjcLengthRangeMaxAttr(), mj_act->lengthrange); tran.GetMjcLengthRangeMaxAttr(), mj_act->lengthrange);
auto gear_attr = act.GetMjcGearAttr(); auto gear_attr = tran.GetMjcGearAttr();
if (gear_attr.HasAuthoredValue()) { if (gear_attr.HasAuthoredValue()) {
pxr::VtDoubleArray gear; pxr::VtDoubleArray gear;
gear_attr.Get(&gear); gear_attr.Get(&gear);
@@ -627,14 +654,14 @@ void ParseMjcPhysicsGeneralActuatorAPI(mjSpec* spec,
} }
} }
auto crank_length_attr = act.GetMjcCrankLengthAttr(); auto crank_length_attr = tran.GetMjcCrankLengthAttr();
if (crank_length_attr.HasAuthoredValue()) { if (crank_length_attr.HasAuthoredValue()) {
double crank_length; double crank_length;
crank_length_attr.Get(&crank_length); crank_length_attr.Get(&crank_length);
mj_act->cranklength = crank_length; mj_act->cranklength = crank_length;
} }
auto dyn_type_attr = act.GetMjcDynTypeAttr(); auto dyn_type_attr = tran.GetMjcDynTypeAttr();
if (dyn_type_attr.HasAuthoredValue()) { if (dyn_type_attr.HasAuthoredValue()) {
pxr::TfToken dyn_type; pxr::TfToken dyn_type;
dyn_type_attr.Get(&dyn_type); dyn_type_attr.Get(&dyn_type);
@@ -653,7 +680,7 @@ void ParseMjcPhysicsGeneralActuatorAPI(mjSpec* spec,
} }
} }
auto gain_type_attr = act.GetMjcGainTypeAttr(); auto gain_type_attr = tran.GetMjcGainTypeAttr();
if (gain_type_attr.HasAuthoredValue()) { if (gain_type_attr.HasAuthoredValue()) {
pxr::TfToken gain_type; pxr::TfToken gain_type;
gain_type_attr.Get(&gain_type); gain_type_attr.Get(&gain_type);
@@ -668,7 +695,7 @@ void ParseMjcPhysicsGeneralActuatorAPI(mjSpec* spec,
} }
} }
auto biastype_attr = act.GetMjcBiasTypeAttr(); auto biastype_attr = tran.GetMjcBiasTypeAttr();
if (biastype_attr.HasAuthoredValue()) { if (biastype_attr.HasAuthoredValue()) {
pxr::TfToken biastype; pxr::TfToken biastype;
biastype_attr.Get(&biastype); biastype_attr.Get(&biastype);
@@ -695,25 +722,25 @@ void ParseMjcPhysicsGeneralActuatorAPI(mjSpec* spec,
} }
}; };
setPrmField(mj_act, act.GetMjcDynPrmAttr(), mj_act->dynprm); setPrmField(mj_act, tran.GetMjcDynPrmAttr(), mj_act->dynprm);
setPrmField(mj_act, act.GetMjcBiasPrmAttr(), mj_act->biasprm); setPrmField(mj_act, tran.GetMjcBiasPrmAttr(), mj_act->biasprm);
setPrmField(mj_act, act.GetMjcGainPrmAttr(), mj_act->gainprm); setPrmField(mj_act, tran.GetMjcGainPrmAttr(), mj_act->gainprm);
auto act_dim_attr = act.GetMjcActDimAttr(); auto act_dim_attr = tran.GetMjcActDimAttr();
if (act_dim_attr.HasAuthoredValue()) { if (act_dim_attr.HasAuthoredValue()) {
int act_dim; int act_dim;
act_dim_attr.Get(&act_dim); act_dim_attr.Get(&act_dim);
mj_act->actdim = act_dim; mj_act->actdim = act_dim;
} }
auto act_early_attr = act.GetMjcActEarlyAttr(); auto act_early_attr = tran.GetMjcActEarlyAttr();
if (act_early_attr.HasAuthoredValue()) { if (act_early_attr.HasAuthoredValue()) {
bool act_early; bool act_early;
act_early_attr.Get(&act_early); act_early_attr.Get(&act_early);
mj_act->actearly = (int)act_early; mj_act->actearly = (int)act_early;
} }
auto ref_site_rel = act.GetMjcRefSiteRel(); auto ref_site_rel = tran.GetMjcRefSiteRel();
if (ref_site_rel.HasAuthoredTargets()) { if (ref_site_rel.HasAuthoredTargets()) {
pxr::SdfPathVector targets; pxr::SdfPathVector targets;
ref_site_rel.GetTargets(&targets); ref_site_rel.GetTargets(&targets);
@@ -1126,12 +1153,6 @@ void ParseUsdPhysicsJoint(mjSpec* spec, const pxr::UsdPrim& prim, mjsBody* body,
SetDoubleArrFromGfVec3d(mj_joint->axis, rotated_axis); SetDoubleArrFromGfVec3d(mj_joint->axis, rotated_axis);
} }
if (prim.HasAPI<pxr::MjcPhysicsActuatorAPI>()) {
ParseMjcPhysicsGeneralActuatorAPI(spec, pxr::MjcPhysicsActuatorAPI(prim),
mjtTrn::mjTRN_JOINT,
mjs_getName(mj_joint->element));
}
if (prim.HasAPI<pxr::MjcPhysicsJointAPI>()) { if (prim.HasAPI<pxr::MjcPhysicsJointAPI>()) {
ParseMjcPhysicsJointAPI(mj_joint, pxr::MjcPhysicsJointAPI(prim)); ParseMjcPhysicsJointAPI(mj_joint, pxr::MjcPhysicsJointAPI(prim));
} }
@@ -1152,15 +1173,6 @@ void ParseMjcPhysicsSite(mjSpec* spec, const pxr::MjcPhysicsSiteAPI& site_api,
prim.GetTypeName().GetString().c_str()); prim.GetTypeName().GetString().c_str());
return; return;
} }
if (prim.HasAPI<pxr::MjcPhysicsActuatorAPI>()) {
auto act_api = pxr::MjcPhysicsActuatorAPI(prim);
bool slider_crank = act_api.GetMjcSliderSiteRel().HasAuthoredTargets();
ParseMjcPhysicsGeneralActuatorAPI(
spec, pxr::MjcPhysicsActuatorAPI(prim),
slider_crank ? mjtTrn::mjTRN_SLIDERCRANK : mjtTrn::mjTRN_SITE,
mjs_getName(site->element));
}
} }
void ParseMjcPhysicsKeyframe(mjSpec* spec, void ParseMjcPhysicsKeyframe(mjSpec* spec,
@@ -1236,12 +1248,6 @@ mjsBody* ParseUsdPhysicsRigidbody(
ParseUsdPhysicsMassAPIForBody(body, pxr::UsdPhysicsMassAPI(prim)); ParseUsdPhysicsMassAPIForBody(body, pxr::UsdPhysicsMassAPI(prim));
} }
if (prim.HasAPI<pxr::MjcPhysicsActuatorAPI>()) {
ParseMjcPhysicsGeneralActuatorAPI(spec, pxr::MjcPhysicsActuatorAPI(prim),
mjtTrn::mjTRN_BODY,
mjs_getName(body->element));
}
mujoco::usd::SetUsdPrimPathUserValue(body->element, prim.GetPath()); mujoco::usd::SetUsdPrimPathUserValue(body->element, prim.GetPath());
return body; return body;
@@ -1423,6 +1429,10 @@ mjSpec* mj_parseUSDStage(const pxr::UsdStageRefPtr stage) {
} else if (prim.IsA<pxr::MjcPhysicsKeyframe>()) { } else if (prim.IsA<pxr::MjcPhysicsKeyframe>()) {
ParseMjcPhysicsKeyframe(spec, pxr::MjcPhysicsKeyframe(prim)); ParseMjcPhysicsKeyframe(spec, pxr::MjcPhysicsKeyframe(prim));
it.PruneChildren();
} else if (prim.IsA<pxr::MjcPhysicsTransmission>()) {
ParseMjcPhysicsTransmission(spec, pxr::MjcPhysicsTransmission(prim));
it.PruneChildren(); it.PruneChildren();
} }
} }
@@ -1443,11 +1453,3 @@ mjSpec* mj_parseUSDStage(const pxr::UsdStageRefPtr stage) {
return spec; return spec;
} }
mjSpec* mj_parseUSDStage(const char* usd_path) {
pxr::UsdStageRefPtr stage = pxr::UsdStage::Open(usd_path);
if (!stage) {
mju_error("Could not open USD stage: %s", usd_path);
return nullptr;
}
return mj_parseUSDStage(stage);
}
@@ -18,13 +18,13 @@
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <mujoco/experimental/usd/mjcPhysics/actuatorAPI.h>
#include <mujoco/experimental/usd/mjcPhysics/collisionAPI.h> #include <mujoco/experimental/usd/mjcPhysics/collisionAPI.h>
#include <mujoco/experimental/usd/mjcPhysics/jointAPI.h> #include <mujoco/experimental/usd/mjcPhysics/jointAPI.h>
#include <mujoco/experimental/usd/mjcPhysics/meshCollisionAPI.h> #include <mujoco/experimental/usd/mjcPhysics/meshCollisionAPI.h>
#include <mujoco/experimental/usd/mjcPhysics/sceneAPI.h> #include <mujoco/experimental/usd/mjcPhysics/sceneAPI.h>
#include <mujoco/experimental/usd/mjcPhysics/siteAPI.h> #include <mujoco/experimental/usd/mjcPhysics/siteAPI.h>
#include <mujoco/experimental/usd/mjcPhysics/tokens.h> #include <mujoco/experimental/usd/mjcPhysics/tokens.h>
#include <mujoco/experimental/usd/mjcPhysics/transmission.h>
#include "test/experimental/usd/test_utils.h" #include "test/experimental/usd/test_utils.h"
#include "test/fixture.h" #include "test/fixture.h"
#include <pxr/base/gf/quatf.h> #include <pxr/base/gf/quatf.h>
@@ -1525,7 +1525,7 @@ TEST_F(MjcfSdfFileFormatPluginTest, TestMassAPIDensity) {
ExpectAttributeEqual(stage, "/test/body/box.physics:density", 1234.0f); ExpectAttributeEqual(stage, "/test/body/box.physics:density", 1234.0f);
} }
TEST_F(MjcfSdfFileFormatPluginTest, TestMjcPhysicsActuatorGeneral) { TEST_F(MjcfSdfFileFormatPluginTest, TestMjcPhysicsTransmission) {
static constexpr char xml[] = R"( static constexpr char xml[] = R"(
<mujoco model="test"> <mujoco model="test">
<worldbody> <worldbody>
@@ -1562,37 +1562,50 @@ TEST_F(MjcfSdfFileFormatPluginTest, TestMjcPhysicsActuatorGeneral) {
)"; )";
auto stage = OpenStageWithPhysics(xml); auto stage = OpenStageWithPhysics(xml);
EXPECT_PRIM_API_APPLIED(stage, "/test/body/site", pxr::MjcPhysicsActuatorAPI); EXPECT_PRIM_VALID(stage, "/test/Transmissions/general");
EXPECT_REL_HAS_TARGET(stage, "/test/body/site.mjc:refSite", "/test/body/ref"); EXPECT_PRIM_IS_A(stage, "/test/Transmissions/general",
ExpectAttributeEqual(stage, "/test/body/site.mjc:ctrlLimited", pxr::MjcPhysicsTransmission);
EXPECT_REL_HAS_TARGET(stage, "/test/Transmissions/general.mjc:target",
"/test/body/site");
EXPECT_REL_HAS_TARGET(stage, "/test/Transmissions/general.mjc:refSite",
"/test/body/ref");
ExpectAttributeEqual(stage, "/test/Transmissions/general.mjc:ctrlLimited",
pxr::MjcPhysicsTokens->true_); pxr::MjcPhysicsTokens->true_);
ExpectAttributeEqual(stage, "/test/body/site.mjc:ctrlRange:min", 0.0); ExpectAttributeEqual(stage, "/test/Transmissions/general.mjc:ctrlRange:min",
ExpectAttributeEqual(stage, "/test/body/site.mjc:ctrlRange:max", 1.0); 0.0);
ExpectAttributeEqual(stage, "/test/body/site.mjc:forceLimited", ExpectAttributeEqual(stage, "/test/Transmissions/general.mjc:ctrlRange:max",
1.0);
ExpectAttributeEqual(stage, "/test/Transmissions/general.mjc:forceLimited",
pxr::MjcPhysicsTokens->true_); pxr::MjcPhysicsTokens->true_);
ExpectAttributeEqual(stage, "/test/body/site.mjc:forceRange:min", 2.0); ExpectAttributeEqual(stage, "/test/Transmissions/general.mjc:forceRange:min",
ExpectAttributeEqual(stage, "/test/body/site.mjc:forceRange:max", 3.0); 2.0);
ExpectAttributeEqual(stage, "/test/body/site.mjc:actLimited", ExpectAttributeEqual(stage, "/test/Transmissions/general.mjc:forceRange:max",
3.0);
ExpectAttributeEqual(stage, "/test/Transmissions/general.mjc:actLimited",
pxr::MjcPhysicsTokens->false_); pxr::MjcPhysicsTokens->false_);
ExpectAttributeEqual(stage, "/test/body/site.mjc:actRange:min", 4.0); ExpectAttributeEqual(stage, "/test/Transmissions/general.mjc:actRange:min",
ExpectAttributeEqual(stage, "/test/body/site.mjc:actRange:max", 5.0); 4.0);
ExpectAttributeEqual(stage, "/test/body/site.mjc:lengthRange:min", 6.0); ExpectAttributeEqual(stage, "/test/Transmissions/general.mjc:actRange:max",
ExpectAttributeEqual(stage, "/test/body/site.mjc:lengthRange:max", 7.0); 5.0);
ExpectAttributeEqual(stage, "/test/body/site.mjc:actDim", 1); ExpectAttributeEqual(stage, "/test/Transmissions/general.mjc:lengthRange:min",
ExpectAttributeEqual(stage, "/test/body/site.mjc:dynType", 6.0);
ExpectAttributeEqual(stage, "/test/Transmissions/general.mjc:lengthRange:max",
7.0);
ExpectAttributeEqual(stage, "/test/Transmissions/general.mjc:actDim", 1);
ExpectAttributeEqual(stage, "/test/Transmissions/general.mjc:dynType",
MjcPhysicsTokens->filter); MjcPhysicsTokens->filter);
ExpectAttributeEqual(stage, "/test/body/site.mjc:gainType", ExpectAttributeEqual(stage, "/test/Transmissions/general.mjc:gainType",
MjcPhysicsTokens->user); MjcPhysicsTokens->user);
ExpectAttributeEqual(stage, "/test/body/site.mjc:biasType", ExpectAttributeEqual(stage, "/test/Transmissions/general.mjc:biasType",
MjcPhysicsTokens->user); MjcPhysicsTokens->user);
ExpectAttributeEqual(stage, "/test/body/site.mjc:actEarly", true); ExpectAttributeEqual(stage, "/test/Transmissions/general.mjc:actEarly", true);
ExpectAttributeEqual(stage, "/test/body/site.mjc:gear", ExpectAttributeEqual(stage, "/test/Transmissions/general.mjc:gear",
pxr::VtDoubleArray{{1, 2, 3, 4, 5, 6}}); pxr::VtDoubleArray{{1, 2, 3, 4, 5, 6}});
ExpectAttributeEqual(stage, "/test/body/site.mjc:dynPrm", ExpectAttributeEqual(stage, "/test/Transmissions/general.mjc:dynPrm",
pxr::VtDoubleArray{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}}); pxr::VtDoubleArray{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}});
ExpectAttributeEqual(stage, "/test/body/site.mjc:gainPrm", ExpectAttributeEqual(stage, "/test/Transmissions/general.mjc:gainPrm",
pxr::VtDoubleArray{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}}); pxr::VtDoubleArray{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}});
ExpectAttributeEqual(stage, "/test/body/site.mjc:biasPrm", ExpectAttributeEqual(stage, "/test/Transmissions/general.mjc:biasPrm",
pxr::VtDoubleArray{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}}); pxr::VtDoubleArray{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}});
} }
@@ -1617,8 +1630,11 @@ TEST_F(MjcfSdfFileFormatPluginTest, TestMjcPhysicsJointActuator) {
)"; )";
auto stage = OpenStageWithPhysics(xml); auto stage = OpenStageWithPhysics(xml);
EXPECT_PRIM_API_APPLIED(stage, "/test/axle/rod/rod_hinge", EXPECT_PRIM_VALID(stage, "/test/Transmissions/general");
pxr::MjcPhysicsActuatorAPI); EXPECT_PRIM_IS_A(stage, "/test/Transmissions/general",
pxr::MjcPhysicsTransmission);
EXPECT_REL_HAS_TARGET(stage, "/test/Transmissions/general.mjc:target",
"/test/axle/rod/rod_hinge");
} }
TEST_F(MjcfSdfFileFormatPluginTest, TestMjcPhysicsBodyActuator) { TEST_F(MjcfSdfFileFormatPluginTest, TestMjcPhysicsBodyActuator) {
@@ -1639,7 +1655,11 @@ TEST_F(MjcfSdfFileFormatPluginTest, TestMjcPhysicsBodyActuator) {
)"; )";
auto stage = OpenStageWithPhysics(xml); auto stage = OpenStageWithPhysics(xml);
EXPECT_PRIM_API_APPLIED(stage, "/test/body", pxr::MjcPhysicsActuatorAPI); EXPECT_PRIM_VALID(stage, "/test/Transmissions/general");
EXPECT_PRIM_IS_A(stage, "/test/Transmissions/general",
pxr::MjcPhysicsTransmission);
EXPECT_REL_HAS_TARGET(stage, "/test/Transmissions/general.mjc:target",
"/test/body");
} }
TEST_F(MjcfSdfFileFormatPluginTest, TestMjcPhysicsSliderCrankActuator) { TEST_F(MjcfSdfFileFormatPluginTest, TestMjcPhysicsSliderCrankActuator) {
@@ -1664,11 +1684,15 @@ TEST_F(MjcfSdfFileFormatPluginTest, TestMjcPhysicsSliderCrankActuator) {
)"; )";
auto stage = OpenStageWithPhysics(xml); auto stage = OpenStageWithPhysics(xml);
EXPECT_PRIM_API_APPLIED(stage, "/test/body/crank", EXPECT_PRIM_VALID(stage, "/test/Transmissions/general");
pxr::MjcPhysicsActuatorAPI); EXPECT_PRIM_IS_A(stage, "/test/Transmissions/general",
EXPECT_REL_HAS_TARGET(stage, "/test/body/crank.mjc:sliderSite", pxr::MjcPhysicsTransmission);
EXPECT_REL_HAS_TARGET(stage, "/test/Transmissions/general.mjc:target",
"/test/body/crank");
EXPECT_REL_HAS_TARGET(stage, "/test/Transmissions/general.mjc:sliderSite",
"/test/body/slider"); "/test/body/slider");
ExpectAttributeEqual(stage, "/test/body/crank.mjc:crankLength", 1.23); ExpectAttributeEqual(stage, "/test/Transmissions/general.mjc:crankLength",
1.23);
} }
TEST_F(MjcfSdfFileFormatPluginTest, TestMjcPhysicsJointAPI) { TEST_F(MjcfSdfFileFormatPluginTest, TestMjcPhysicsJointAPI) {
+7 -4
View File
@@ -36,10 +36,7 @@ def Xform "World"
uniform token[] xformOpOrder = ["xformOp:transform"] uniform token[] xformOpOrder = ["xformOp:transform"]
} }
def PhysicsRevoluteJoint "HingeJoint" ( def PhysicsRevoluteJoint "HingeJoint" {
prepend apiSchemas = ["PhysicsActuatorAPI"]
)
{
rel physics:body0 = </World/Axle> rel physics:body0 = </World/Axle>
rel physics:body1 = </World/Axle/Rod> rel physics:body1 = </World/Axle/Rod>
point3f physics:localPos0 = (0, 0, 0) point3f physics:localPos0 = (0, 0, 0)
@@ -67,5 +64,11 @@ def Xform "World"
rel physics:body1 = </World/Axle> rel physics:body1 = </World/Axle>
} }
} }
def Scope "Transmissions" {
def MjcTransmission "HingeActuator" {
rel mjc:target = </World/Axle/Rod/HingeJoint>
}
}
} }