Move headers from src/experimental/usd to include/experimental/usd

PiperOrigin-RevId: 775269423
Change-Id: Ifca6c3ead32b9fb3f02784ed38a9efae300be410
This commit is contained in:
Sam Haves
2025-06-24 09:32:13 -07:00
committed by Copybara-Service
parent 78df2ae7fa
commit 9089059517
21 changed files with 120 additions and 27 deletions
@@ -0,0 +1,41 @@
// Copyright 2025 DeepMind Technologies Limited
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUJOCO_SRC_EXPERIMENTAL_USD_LAYER_SINK_H_
#define MUJOCO_SRC_EXPERIMENTAL_USD_LAYER_SINK_H_
#include <vector>
#include <mujoco/mujoco.h>
#include <pxr/usd/sdf/path.h>
#include <pxr/usd/usd/common.h>
namespace mujoco {
namespace usd {
// A sink for writing pose data to an SDF layer.
// Opinions will be authored on the edit target layer for the
// passed stage argument.
class LayerSink {
public:
explicit LayerSink(pxr::UsdStageRefPtr stage);
void Update(const mjData* const data, std::vector<pxr::SdfPath> body_paths_);
private:
pxr::UsdStageRefPtr stage_;
};
} // namespace usd
} // namespace mujoco
#endif // MUJOCO_SRC_EXPERIMENTAL_USD_LAYER_SINK_H_
@@ -0,0 +1,811 @@
// Copyright 2025 DeepMind Technologies Limited
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MJCPHYSICS_GENERATED_ACTUATORAPI_H
#define MJCPHYSICS_GENERATED_ACTUATORAPI_H
/// \file mjcPhysics/actuatorAPI.h
#include <mujoco/experimental/usd/mjcPhysics/api.h>
#include <mujoco/experimental/usd/mjcPhysics/tokens.h>
#include "pxr/base/gf/matrix4d.h"
#include "pxr/base/gf/vec3d.h"
#include "pxr/base/gf/vec3f.h"
#include "pxr/base/tf/token.h"
#include "pxr/base/tf/type.h"
#include "pxr/base/vt/value.h"
#include "pxr/pxr.h"
#include "pxr/usd/usd/apiSchemaBase.h"
#include "pxr/usd/usd/prim.h"
#include "pxr/usd/usd/stage.h"
PXR_NAMESPACE_OPEN_SCOPE
class SdfAssetPath;
// -------------------------------------------------------------------------- //
// PHYSICSACTUATORAPI //
// -------------------------------------------------------------------------- //
/// \class MjcPhysicsActuatorAPI
///
/// API describing a Mujoco actuator.
///
/// 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
/// \ref MjcPhysicsTokens. So to set an attribute to the value "rightHanded",
/// use MjcPhysicsTokens->rightHanded as the value.
///
class MjcPhysicsActuatorAPI : public UsdAPISchemaBase {
public:
/// Compile time constant representing what kind of schema this class is.
///
/// \sa UsdSchemaKind
static const UsdSchemaKind schemaKind = UsdSchemaKind::SingleApplyAPI;
/// Construct a MjcPhysicsActuatorAPI on UsdPrim \p prim .
/// Equivalent to MjcPhysicsActuatorAPI::Get(prim.GetStage(), prim.GetPath())
/// for a \em valid \p prim, but will not immediately throw an error for
/// an invalid \p prim
explicit MjcPhysicsActuatorAPI(const UsdPrim &prim = UsdPrim())
: UsdAPISchemaBase(prim) {}
/// Construct a MjcPhysicsActuatorAPI on the prim held by \p schemaObj .
/// Should be preferred over MjcPhysicsActuatorAPI(schemaObj.GetPrim()),
/// as it preserves SchemaBase state.
explicit MjcPhysicsActuatorAPI(const UsdSchemaBase &schemaObj)
: UsdAPISchemaBase(schemaObj) {}
/// Destructor.
MJCPHYSICS_API
virtual ~MjcPhysicsActuatorAPI();
/// Return a vector of names of all pre-declared attributes for this schema
/// class and all its ancestor classes. Does not include attributes that
/// may be authored by custom/extended methods of the schemas involved.
MJCPHYSICS_API
static const TfTokenVector &GetSchemaAttributeNames(
bool includeInherited = true);
/// Return a MjcPhysicsActuatorAPI holding the prim adhering to this
/// schema at \p path on \p stage. If no prim exists at \p path on
/// \p stage, or if the prim at that path does not adhere to this schema,
/// return an invalid schema object. This is shorthand for the following:
///
/// \code
/// MjcPhysicsActuatorAPI(stage->GetPrimAtPath(path));
/// \endcode
///
MJCPHYSICS_API
static MjcPhysicsActuatorAPI Get(const UsdStagePtr &stage,
const SdfPath &path);
/// Returns true if this <b>single-apply</b> API schema can be applied to
/// the given \p prim. If this schema can not be a applied to the prim,
/// 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
/// that calling Apply will fail. Callers are expected to call CanApply
/// before calling Apply if they want to ensure that it is valid to
/// apply a schema.
///
/// \sa UsdPrim::GetAppliedSchemas()
/// \sa UsdPrim::HasAPI()
/// \sa UsdPrim::CanApplyAPI()
/// \sa UsdPrim::ApplyAPI()
/// \sa UsdPrim::RemoveAPI()
///
MJCPHYSICS_API
static bool CanApply(const UsdPrim &prim, std::string *whyNot = nullptr);
/// Applies this <b>single-apply</b> API schema to the given \p prim.
/// This information is stored by adding "PhysicsActuatorAPI" 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:
/// Returns the kind of schema this class belongs to.
///
/// \sa UsdSchemaKind
MJCPHYSICS_API
UsdSchemaKind _GetSchemaKind() const override;
private:
// needs to invoke _GetStaticTfType.
friend class UsdSchemaRegistry;
MJCPHYSICS_API
static const TfType &_GetStaticTfType();
static bool _IsTypedSchema();
// override SchemaBase virtuals.
MJCPHYSICS_API
const TfType &_GetTfType() const override;
public:
// --------------------------------------------------------------------- //
// MJCCTRLLIMITED
// --------------------------------------------------------------------- //
/// 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.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform token mjc:ctrlLimited = "auto"` |
/// | C++ Type | TfToken |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
/// | \ref MjcPhysicsTokens "Allowed Values" | false, true, auto |
MJCPHYSICS_API
UsdAttribute GetMjcCtrlLimitedAttr() const;
/// See GetMjcCtrlLimitedAttr(), 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 CreateMjcCtrlLimitedAttr(VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCFORCELIMITED
// --------------------------------------------------------------------- //
/// If true, the force output of this actuator is automatically clamped to
/// forcerange at runtime. If false, force clamping is disabled. If 'auto' and
/// autolimits is set in compiler, force clamping will automatically be set to
/// true if forcerange is defined without explicitly setting this attribute to
/// 'true'.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform token mjc:forceLimited = "auto"` |
/// | C++ Type | TfToken |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
/// | \ref MjcPhysicsTokens "Allowed Values" | false, true, auto |
MJCPHYSICS_API
UsdAttribute GetMjcForceLimitedAttr() const;
/// See GetMjcForceLimitedAttr(), 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 CreateMjcForceLimitedAttr(
VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCACTLIMITED
// --------------------------------------------------------------------- //
/// If true, the internal state (activation) associated with this actuator is
/// automatically clamped to actrange at runtime. If false, activation
/// clamping is disabled. If 'auto' and autolimits is set in compiler,
/// activation clamping will automatically be set to true if actrange is
/// defined without explicitly setting this attribute to 'true'. See the
/// Activation clamping section for more details.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform token mjc:actLimited = "auto"` |
/// | C++ Type | TfToken |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
/// | \ref MjcPhysicsTokens "Allowed Values" | false, true, auto |
MJCPHYSICS_API
UsdAttribute GetMjcActLimitedAttr() const;
/// See GetMjcActLimitedAttr(), 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 CreateMjcActLimitedAttr(VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCCTRLRANGEMIN
// --------------------------------------------------------------------- //
/// Minimum range for clamping the control input. The first value must be
/// smaller than the second value. Setting this attribute without specifying
/// ctrllimited is an error if autolimits is 'false' in compiler.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform double mjc:ctrlRange:min = 0` |
/// | C++ Type | double |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetMjcCtrlRangeMinAttr() const;
/// See GetMjcCtrlRangeMinAttr(), 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 CreateMjcCtrlRangeMinAttr(
VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCCTRLRANGEMAX
// --------------------------------------------------------------------- //
/// Maximum range for clamping the control input. The first value must be
/// smaller than the second value. Setting this attribute without specifying
/// ctrllimited is an error if autolimits is 'false' in compiler.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform double mjc:ctrlRange:max = 0` |
/// | C++ Type | double |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetMjcCtrlRangeMaxAttr() const;
/// See GetMjcCtrlRangeMaxAttr(), 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 CreateMjcCtrlRangeMaxAttr(
VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCFORCERANGEMIN
// --------------------------------------------------------------------- //
/// Minimum range for clamping the force output. The first value must be no
/// greater than the second value. Setting this attribute without specifying
/// forcelimited is an error if autolimits is 'false' in compiler.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform double mjc:forceRange:min = 0` |
/// | C++ Type | double |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetMjcForceRangeMinAttr() const;
/// See GetMjcForceRangeMinAttr(), 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 CreateMjcForceRangeMinAttr(
VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCFORCERANGEMAX
// --------------------------------------------------------------------- //
/// Maximum range for clamping the force output. The first value must be no
/// greater than the second value. Setting this attribute without specifying
/// forcelimited is an error if autolimits is 'false' in compiler.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform double mjc:forceRange:max = 0` |
/// | C++ Type | double |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetMjcForceRangeMaxAttr() const;
/// See GetMjcForceRangeMaxAttr(), 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 CreateMjcForceRangeMaxAttr(
VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCACTRANGEMIN
// --------------------------------------------------------------------- //
/// Minimum range for clamping the activation state. The first value must be
/// no greater than the second value. See the Activation clamping section for
/// more details. Setting this attribute without specifying actlimited is an
/// error if autolimits is 'false' in compiler.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform double mjc:actRange:min = 0` |
/// | C++ Type | double |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetMjcActRangeMinAttr() const;
/// See GetMjcActRangeMinAttr(), 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 CreateMjcActRangeMinAttr(VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCACTRANGEMAX
// --------------------------------------------------------------------- //
/// Maximum range for clamping the activation state. The first value must be
/// no greater than the second value. See the Activation clamping section for
/// more details. Setting this attribute without specifying actlimited is an
/// error if autolimits is 'false' in compiler.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform double mjc:actRange:max = 0` |
/// | C++ Type | double |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetMjcActRangeMaxAttr() const;
/// See GetMjcActRangeMaxAttr(), 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 CreateMjcActRangeMaxAttr(VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCLENGTHRANGEMIN
// --------------------------------------------------------------------- //
/// Minimum range of feasible lengths of the actuator’s transmission.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform double mjc:lengthRange:min = 0` |
/// | C++ Type | double |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetMjcLengthRangeMinAttr() const;
/// See GetMjcLengthRangeMinAttr(), 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 CreateMjcLengthRangeMinAttr(
VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCLENGTHRANGEMAX
// --------------------------------------------------------------------- //
/// Maximum range of feasible lengths of the actuator’s transmission.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform double mjc:lengthRange:max = 0` |
/// | C++ Type | double |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetMjcLengthRangeMaxAttr() const;
/// See GetMjcLengthRangeMaxAttr(), 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 CreateMjcLengthRangeMaxAttr(
VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCGEAR
// --------------------------------------------------------------------- //
/// This attribute scales the length (and consequently moment arms, velocity
/// and force) of the actuator, for all transmission types. It is different
/// from the gain in the force generation mechanism, because the gain only
/// scales the force output and does not affect the length, moment arms and
/// velocity. For actuators with scalar transmission, only the first element
/// of this vector is used. The remaining elements are needed for joint,
/// jointinparent and site transmissions where this attribute is used to
/// specify 3D force and torque axes.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform double[] mjc:gear = [1, 0, 0, 0, 0, 0]` |
/// | C++ Type | VtArray<double> |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->DoubleArray |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetMjcGearAttr() const;
/// See GetMjcGearAttr(), 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 CreateMjcGearAttr(VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCCRANKLENGTH
// --------------------------------------------------------------------- //
/// Used only for the slider-crank transmission type. Specifies the length of
/// the connecting rod. The compiler expects this value to be positive when a
/// slider-crank transmission is present.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform double mjc:crankLength = 0` |
/// | C++ Type | double |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetMjcCrankLengthAttr() const;
/// See GetMjcCrankLengthAttr(), 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 CreateMjcCrankLengthAttr(VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCJOINTINPARENT
// --------------------------------------------------------------------- //
/// If true and applied to ball and free joints, the 3d rotation axis given by
/// gear is defined in the parent frame (which is the world frame for free
/// joints) rather than the child frame.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform bool mjc:jointInParent = 0` |
/// | C++ Type | bool |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetMjcJointInParentAttr() const;
/// See GetMjcJointInParentAttr(), 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 CreateMjcJointInParentAttr(
VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCACTDIM
// --------------------------------------------------------------------- //
/// Dimension of the activation state. The default value of -1 instructs the
/// compiler to set the dimension according to the dyntype. Values larger than
/// 1 are only allowed for user-defined activation dynamics, as native types
/// require dimensions of only 0 or 1. For activation dimensions bigger than
/// 1, the last element is used to generate force.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform int mjc:actDim = -1` |
/// | C++ Type | int |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Int |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetMjcActDimAttr() const;
/// See GetMjcActDimAttr(), 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 CreateMjcActDimAttr(VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCDYNTYPE
// --------------------------------------------------------------------- //
/// Activation dynamics type for the actuator. The available dynamics types
/// were already described in the Actuation model section.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform token mjc:dynType = "none"` |
/// | C++ Type | TfToken |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
/// | \ref MjcPhysicsTokens "Allowed Values" | none, integrator, filter,
/// filterexact, muscle, user |
MJCPHYSICS_API
UsdAttribute GetMjcDynTypeAttr() const;
/// See GetMjcDynTypeAttr(), 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 CreateMjcDynTypeAttr(VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCGAINTYPE
// --------------------------------------------------------------------- //
/// The gain and bias together determine the output of the force generation
/// mechanism, which is currently assumed to be affine.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform token mjc:gainType = "fixed"` |
/// | C++ Type | TfToken |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
/// | \ref MjcPhysicsTokens "Allowed Values" | fixed, affine, muscle, user |
MJCPHYSICS_API
UsdAttribute GetMjcGainTypeAttr() const;
/// See GetMjcGainTypeAttr(), 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 CreateMjcGainTypeAttr(VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCBIASTYPE
// --------------------------------------------------------------------- //
/// The gain and bias together determine the output of the force generation
/// mechanism, which is currently assumed to be affine.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform token mjc:biasType = "none"` |
/// | C++ Type | TfToken |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
/// | \ref MjcPhysicsTokens "Allowed Values" | none, affine, muscle, user |
MJCPHYSICS_API
UsdAttribute GetMjcBiasTypeAttr() const;
/// See GetMjcBiasTypeAttr(), 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 CreateMjcBiasTypeAttr(VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCDYNPRM
// --------------------------------------------------------------------- //
/// Activation dynamics parameters. The built-in activation types (except for
/// muscle) use only the first parameter, but we provide additional parameters
/// in case user callbacks implement a more elaborate model. The length of
/// this array is not enforced by the parser, so the user can enter as many
/// parameters as needed. These defaults are not compatible with muscle
/// actuators.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform double[] mjc:dynPrm = [1, 0, 0, 0, 0, 0, 0, 0, 0,
/// 0]` | | C++ Type | VtArray<double> | | \ref Usd_Datatypes "Usd Type" |
/// SdfValueTypeNames->DoubleArray | | \ref SdfVariability "Variability" |
/// SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetMjcDynPrmAttr() const;
/// See GetMjcDynPrmAttr(), 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 CreateMjcDynPrmAttr(VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCGAINPRM
// --------------------------------------------------------------------- //
/// Gain parameters. The built-in gain types (except for muscle) use only the
/// first parameter, but we provide additional parameters in case user
/// callbacks implement a more elaborate model. The length of this array is
/// not enforced by the parser, so the user can enter as many parameters as
/// needed. These defaults are not compatible with muscle actuators.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform double[] mjc:gainPrm = [1, 0, 0, 0, 0, 0, 0, 0,
/// 0, 0]` | | C++ Type | VtArray<double> | | \ref Usd_Datatypes "Usd Type" |
/// SdfValueTypeNames->DoubleArray | | \ref SdfVariability "Variability" |
/// SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetMjcGainPrmAttr() const;
/// See GetMjcGainPrmAttr(), 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 CreateMjcGainPrmAttr(VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCBIASPRM
// --------------------------------------------------------------------- //
/// Bias parameters. The affine bias type uses three parameters. The length of
/// this array is not enforced by the parser, so the user can enter as many
/// parameters as needed. These defaults are not compatible with muscle
/// actuators.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform double[] mjc:biasPrm = [0, 0, 0, 0, 0, 0, 0, 0,
/// 0, 0]` | | C++ Type | VtArray<double> | | \ref Usd_Datatypes "Usd Type" |
/// SdfValueTypeNames->DoubleArray | | \ref SdfVariability "Variability" |
/// SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetMjcBiasPrmAttr() const;
/// See GetMjcBiasPrmAttr(), 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 CreateMjcBiasPrmAttr(VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCACTEARLY
// --------------------------------------------------------------------- //
/// If true, force computation will use the next value of the activation
/// variable rather than the current one. Setting this flag reduces the delay
/// between the control and accelerations by one time-step.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform bool mjc:actEarly = 0` |
/// | C++ Type | bool |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetMjcActEarlyAttr() const;
/// See GetMjcActEarlyAttr(), 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 CreateMjcActEarlyAttr(VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// --------------------------------------------------------------------- //
// MJCREFSITE
// --------------------------------------------------------------------- //
/// When applied to a site, measure the translation and rotation w.r.t the
/// frame of the refsite. In this case the actuator does have length and
/// position actuators can be used to directly control an end effector, see
/// refsite.xml example model. As above, the length is the dot product of the
/// gear vector and the frame difference. So gear='0 1 0 0 0 0' means
/// 'Y-offset of site in the refsite frame', while gear='0 0 0 0 0 1' means
/// rotation 'Z- rotation of site in the refsite frame'. It is recommended to
/// use a normalized gear vector with nonzeros in only the first 3 or the last
/// 3 elements of gear, so the actuator length will be in either length units
/// or radians, respectively. As with ball joints (see joint above), for
/// rotations which exceed a total angle of pi will wrap around, so tighter
/// limits are recommended.
///
MJCPHYSICS_API
UsdRelationship GetMjcRefSiteRel() const;
/// See GetMjcRefSiteRel(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create
MJCPHYSICS_API
UsdRelationship CreateMjcRefSiteRel() const;
public:
// --------------------------------------------------------------------- //
// MJCSLIDERSITE
// --------------------------------------------------------------------- //
/// 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.
///
MJCPHYSICS_API
UsdRelationship GetMjcSliderSiteRel() const;
/// See GetMjcSliderSiteRel(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create
MJCPHYSICS_API
UsdRelationship CreateMjcSliderSiteRel() const;
public:
// ===================================================================== //
// Feel free to add custom code below this line, it will be preserved by
// the code generator.
//
// Just remember to:
// - Close the class declaration with };
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
// - Close the include guard with #endif
// ===================================================================== //
// --(BEGIN CUSTOM CODE)--
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif
@@ -0,0 +1,42 @@
// Copyright 2025 DeepMind Technologies Limited
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MJCPHYSICS_API_H
#define MJCPHYSICS_API_H
#include "pxr/base/arch/export.h"
#if defined(PXR_STATIC)
#define MJCPHYSICS_API
#define MJCPHYSICS_API_TEMPLATE_CLASS(...)
#define MJCPHYSICS_API_TEMPLATE_STRUCT(...)
#define MJCPHYSICS_LOCAL
#else
#if defined(MJCPHYSICS_EXPORTS)
#define MJCPHYSICS_API ARCH_EXPORT
#define MJCPHYSICS_API_TEMPLATE_CLASS(...) \
ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__)
#define MJCPHYSICS_API_TEMPLATE_STRUCT(...) \
ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__)
#else
#define MJCPHYSICS_API ARCH_IMPORT
#define MJCPHYSICS_API_TEMPLATE_CLASS(...) \
ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__)
#define MJCPHYSICS_API_TEMPLATE_STRUCT(...) \
ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__)
#endif
#define MJCPHYSICS_LOCAL ARCH_HIDDEN
#endif
#endif
@@ -0,0 +1,185 @@
// Copyright 2025 DeepMind Technologies Limited
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MJCPHYSICS_GENERATED_COLLISIONAPI_H
#define MJCPHYSICS_GENERATED_COLLISIONAPI_H
/// \file mjcPhysics/collisionAPI.h
#include <mujoco/experimental/usd/mjcPhysics/api.h>
#include <mujoco/experimental/usd/mjcPhysics/tokens.h>
#include "pxr/base/gf/matrix4d.h"
#include "pxr/base/gf/vec3d.h"
#include "pxr/base/gf/vec3f.h"
#include "pxr/base/tf/token.h"
#include "pxr/base/tf/type.h"
#include "pxr/base/vt/value.h"
#include "pxr/pxr.h"
#include "pxr/usd/usd/apiSchemaBase.h"
#include "pxr/usd/usd/prim.h"
#include "pxr/usd/usd/stage.h"
PXR_NAMESPACE_OPEN_SCOPE
class SdfAssetPath;
// -------------------------------------------------------------------------- //
// COLLISIONAPI //
// -------------------------------------------------------------------------- //
/// \class MjcPhysicsCollisionAPI
///
/// API describing a Mujoco collider.
///
class MjcPhysicsCollisionAPI : public UsdAPISchemaBase {
public:
/// Compile time constant representing what kind of schema this class is.
///
/// \sa UsdSchemaKind
static const UsdSchemaKind schemaKind = UsdSchemaKind::SingleApplyAPI;
/// Construct a MjcPhysicsCollisionAPI on UsdPrim \p prim .
/// Equivalent to MjcPhysicsCollisionAPI::Get(prim.GetStage(), prim.GetPath())
/// for a \em valid \p prim, but will not immediately throw an error for
/// an invalid \p prim
explicit MjcPhysicsCollisionAPI(const UsdPrim &prim = UsdPrim())
: UsdAPISchemaBase(prim) {}
/// Construct a MjcPhysicsCollisionAPI on the prim held by \p schemaObj .
/// Should be preferred over MjcPhysicsCollisionAPI(schemaObj.GetPrim()),
/// as it preserves SchemaBase state.
explicit MjcPhysicsCollisionAPI(const UsdSchemaBase &schemaObj)
: UsdAPISchemaBase(schemaObj) {}
/// Destructor.
MJCPHYSICS_API
virtual ~MjcPhysicsCollisionAPI();
/// Return a vector of names of all pre-declared attributes for this schema
/// class and all its ancestor classes. Does not include attributes that
/// may be authored by custom/extended methods of the schemas involved.
MJCPHYSICS_API
static const TfTokenVector &GetSchemaAttributeNames(
bool includeInherited = true);
/// Return a MjcPhysicsCollisionAPI holding the prim adhering to this
/// schema at \p path on \p stage. If no prim exists at \p path on
/// \p stage, or if the prim at that path does not adhere to this schema,
/// return an invalid schema object. This is shorthand for the following:
///
/// \code
/// MjcPhysicsCollisionAPI(stage->GetPrimAtPath(path));
/// \endcode
///
MJCPHYSICS_API
static MjcPhysicsCollisionAPI Get(const UsdStagePtr &stage,
const SdfPath &path);
/// Returns true if this <b>single-apply</b> API schema can be applied to
/// the given \p prim. If this schema can not be a applied to the prim,
/// 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
/// that calling Apply will fail. Callers are expected to call CanApply
/// before calling Apply if they want to ensure that it is valid to
/// apply a schema.
///
/// \sa UsdPrim::GetAppliedSchemas()
/// \sa UsdPrim::HasAPI()
/// \sa UsdPrim::CanApplyAPI()
/// \sa UsdPrim::ApplyAPI()
/// \sa UsdPrim::RemoveAPI()
///
MJCPHYSICS_API
static bool CanApply(const UsdPrim &prim, std::string *whyNot = nullptr);
/// Applies this <b>single-apply</b> API schema to the given \p prim.
/// This information is stored by adding "CollisionAPI" to the
/// token-valued, listOp metadata \em apiSchemas on the prim.
///
/// \return A valid MjcPhysicsCollisionAPI object is returned upon success.
/// An invalid (or empty) MjcPhysicsCollisionAPI 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 MjcPhysicsCollisionAPI Apply(const UsdPrim &prim);
protected:
/// Returns the kind of schema this class belongs to.
///
/// \sa UsdSchemaKind
MJCPHYSICS_API
UsdSchemaKind _GetSchemaKind() const override;
private:
// needs to invoke _GetStaticTfType.
friend class UsdSchemaRegistry;
MJCPHYSICS_API
static const TfType &_GetStaticTfType();
static bool _IsTypedSchema();
// override SchemaBase virtuals.
MJCPHYSICS_API
const TfType &_GetTfType() const override;
public:
// --------------------------------------------------------------------- //
// SHELLINERTIA
// --------------------------------------------------------------------- //
/// Enables handling of the inertia assuming mass is concentrated on the
/// surface.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform bool mjc:shellinertia = 0` |
/// | C++ Type | bool |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
MJCPHYSICS_API
UsdAttribute GetShellInertiaAttr() const;
/// See GetShellInertiaAttr(), 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 CreateShellInertiaAttr(VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// ===================================================================== //
// Feel free to add custom code below this line, it will be preserved by
// the code generator.
//
// Just remember to:
// - Close the class declaration with };
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
// - Close the include guard with #endif
// ===================================================================== //
// --(BEGIN CUSTOM CODE)--
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif
@@ -0,0 +1,191 @@
// Copyright 2025 DeepMind Technologies Limited
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MJCPHYSICS_GENERATED_MESHCOLLISIONAPI_H
#define MJCPHYSICS_GENERATED_MESHCOLLISIONAPI_H
/// \file mjcPhysics/meshCollisionAPI.h
#include <mujoco/experimental/usd/mjcPhysics/api.h>
#include <mujoco/experimental/usd/mjcPhysics/tokens.h>
#include "pxr/base/gf/matrix4d.h"
#include "pxr/base/gf/vec3d.h"
#include "pxr/base/gf/vec3f.h"
#include "pxr/base/tf/token.h"
#include "pxr/base/tf/type.h"
#include "pxr/base/vt/value.h"
#include "pxr/pxr.h"
#include "pxr/usd/usd/apiSchemaBase.h"
#include "pxr/usd/usd/prim.h"
#include "pxr/usd/usd/stage.h"
PXR_NAMESPACE_OPEN_SCOPE
class SdfAssetPath;
// -------------------------------------------------------------------------- //
// MESHCOLLISIONAPI //
// -------------------------------------------------------------------------- //
/// \class MjcPhysicsMeshCollisionAPI
///
/// API describing a Mujoco collider.
///
/// 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
/// \ref MjcPhysicsTokens. So to set an attribute to the value "rightHanded",
/// use MjcPhysicsTokens->rightHanded as the value.
///
class MjcPhysicsMeshCollisionAPI : public UsdAPISchemaBase {
public:
/// Compile time constant representing what kind of schema this class is.
///
/// \sa UsdSchemaKind
static const UsdSchemaKind schemaKind = UsdSchemaKind::SingleApplyAPI;
/// Construct a MjcPhysicsMeshCollisionAPI on UsdPrim \p prim .
/// Equivalent to MjcPhysicsMeshCollisionAPI::Get(prim.GetStage(),
/// prim.GetPath()) for a \em valid \p prim, but will not immediately throw an
/// error for an invalid \p prim
explicit MjcPhysicsMeshCollisionAPI(const UsdPrim &prim = UsdPrim())
: UsdAPISchemaBase(prim) {}
/// Construct a MjcPhysicsMeshCollisionAPI on the prim held by \p schemaObj .
/// Should be preferred over MjcPhysicsMeshCollisionAPI(schemaObj.GetPrim()),
/// as it preserves SchemaBase state.
explicit MjcPhysicsMeshCollisionAPI(const UsdSchemaBase &schemaObj)
: UsdAPISchemaBase(schemaObj) {}
/// Destructor.
MJCPHYSICS_API
virtual ~MjcPhysicsMeshCollisionAPI();
/// Return a vector of names of all pre-declared attributes for this schema
/// class and all its ancestor classes. Does not include attributes that
/// may be authored by custom/extended methods of the schemas involved.
MJCPHYSICS_API
static const TfTokenVector &GetSchemaAttributeNames(
bool includeInherited = true);
/// Return a MjcPhysicsMeshCollisionAPI holding the prim adhering to this
/// schema at \p path on \p stage. If no prim exists at \p path on
/// \p stage, or if the prim at that path does not adhere to this schema,
/// return an invalid schema object. This is shorthand for the following:
///
/// \code
/// MjcPhysicsMeshCollisionAPI(stage->GetPrimAtPath(path));
/// \endcode
///
MJCPHYSICS_API
static MjcPhysicsMeshCollisionAPI Get(const UsdStagePtr &stage,
const SdfPath &path);
/// Returns true if this <b>single-apply</b> API schema can be applied to
/// the given \p prim. If this schema can not be a applied to the prim,
/// 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
/// that calling Apply will fail. Callers are expected to call CanApply
/// before calling Apply if they want to ensure that it is valid to
/// apply a schema.
///
/// \sa UsdPrim::GetAppliedSchemas()
/// \sa UsdPrim::HasAPI()
/// \sa UsdPrim::CanApplyAPI()
/// \sa UsdPrim::ApplyAPI()
/// \sa UsdPrim::RemoveAPI()
///
MJCPHYSICS_API
static bool CanApply(const UsdPrim &prim, std::string *whyNot = nullptr);
/// Applies this <b>single-apply</b> API schema to the given \p prim.
/// This information is stored by adding "MeshCollisionAPI" to the
/// token-valued, listOp metadata \em apiSchemas on the prim.
///
/// \return A valid MjcPhysicsMeshCollisionAPI object is returned upon
/// success. An invalid (or empty) MjcPhysicsMeshCollisionAPI 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 MjcPhysicsMeshCollisionAPI Apply(const UsdPrim &prim);
protected:
/// Returns the kind of schema this class belongs to.
///
/// \sa UsdSchemaKind
MJCPHYSICS_API
UsdSchemaKind _GetSchemaKind() const override;
private:
// needs to invoke _GetStaticTfType.
friend class UsdSchemaRegistry;
MJCPHYSICS_API
static const TfType &_GetStaticTfType();
static bool _IsTypedSchema();
// override SchemaBase virtuals.
MJCPHYSICS_API
const TfType &_GetTfType() const override;
public:
// --------------------------------------------------------------------- //
// INERTIA
// --------------------------------------------------------------------- //
/// Controls how a mesh is used when mass and inertia are inferred from
/// geometry.
///
/// | ||
/// | -- | -- |
/// | Declaration | `uniform token mjc:inertia = "legacy"` |
/// | C++ Type | TfToken |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
/// | \ref MjcPhysicsTokens "Allowed Values" | legacy, convex, exact, shell |
MJCPHYSICS_API
UsdAttribute GetInertiaAttr() const;
/// See GetInertiaAttr(), 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 CreateInertiaAttr(VtValue const &defaultValue = VtValue(),
bool writeSparsely = false) const;
public:
// ===================================================================== //
// Feel free to add custom code below this line, it will be preserved by
// the code generator.
//
// Just remember to:
// - Close the class declaration with };
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
// - Close the include guard with #endif
// ===================================================================== //
// --(BEGIN CUSTOM CODE)--
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,158 @@
// Copyright 2025 DeepMind Technologies Limited
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MJCPHYSICS_GENERATED_SITEAPI_H
#define MJCPHYSICS_GENERATED_SITEAPI_H
/// \file mjcPhysics/siteAPI.h
#include <mujoco/experimental/usd/mjcPhysics/api.h>
#include "pxr/base/gf/matrix4d.h"
#include "pxr/base/gf/vec3d.h"
#include "pxr/base/gf/vec3f.h"
#include "pxr/base/tf/token.h"
#include "pxr/base/tf/type.h"
#include "pxr/base/vt/value.h"
#include "pxr/pxr.h"
#include "pxr/usd/usd/apiSchemaBase.h"
#include "pxr/usd/usd/prim.h"
#include "pxr/usd/usd/stage.h"
PXR_NAMESPACE_OPEN_SCOPE
class SdfAssetPath;
// -------------------------------------------------------------------------- //
// SITEAPI //
// -------------------------------------------------------------------------- //
/// \class MjcPhysicsSiteAPI
///
/// API describing a Mujoco site.
///
class MjcPhysicsSiteAPI : public UsdAPISchemaBase {
public:
/// Compile time constant representing what kind of schema this class is.
///
/// \sa UsdSchemaKind
static const UsdSchemaKind schemaKind = UsdSchemaKind::SingleApplyAPI;
/// Construct a MjcPhysicsSiteAPI on UsdPrim \p prim .
/// Equivalent to MjcPhysicsSiteAPI::Get(prim.GetStage(), prim.GetPath())
/// for a \em valid \p prim, but will not immediately throw an error for
/// an invalid \p prim
explicit MjcPhysicsSiteAPI(const UsdPrim &prim = UsdPrim())
: UsdAPISchemaBase(prim) {}
/// Construct a MjcPhysicsSiteAPI on the prim held by \p schemaObj .
/// Should be preferred over MjcPhysicsSiteAPI(schemaObj.GetPrim()),
/// as it preserves SchemaBase state.
explicit MjcPhysicsSiteAPI(const UsdSchemaBase &schemaObj)
: UsdAPISchemaBase(schemaObj) {}
/// Destructor.
MJCPHYSICS_API
virtual ~MjcPhysicsSiteAPI();
/// Return a vector of names of all pre-declared attributes for this schema
/// class and all its ancestor classes. Does not include attributes that
/// may be authored by custom/extended methods of the schemas involved.
MJCPHYSICS_API
static const TfTokenVector &GetSchemaAttributeNames(
bool includeInherited = true);
/// Return a MjcPhysicsSiteAPI holding the prim adhering to this
/// schema at \p path on \p stage. If no prim exists at \p path on
/// \p stage, or if the prim at that path does not adhere to this schema,
/// return an invalid schema object. This is shorthand for the following:
///
/// \code
/// MjcPhysicsSiteAPI(stage->GetPrimAtPath(path));
/// \endcode
///
MJCPHYSICS_API
static MjcPhysicsSiteAPI Get(const UsdStagePtr &stage, const SdfPath &path);
/// Returns true if this <b>single-apply</b> API schema can be applied to
/// the given \p prim. If this schema can not be a applied to the prim,
/// 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
/// that calling Apply will fail. Callers are expected to call CanApply
/// before calling Apply if they want to ensure that it is valid to
/// apply a schema.
///
/// \sa UsdPrim::GetAppliedSchemas()
/// \sa UsdPrim::HasAPI()
/// \sa UsdPrim::CanApplyAPI()
/// \sa UsdPrim::ApplyAPI()
/// \sa UsdPrim::RemoveAPI()
///
MJCPHYSICS_API
static bool CanApply(const UsdPrim &prim, std::string *whyNot = nullptr);
/// Applies this <b>single-apply</b> API schema to the given \p prim.
/// This information is stored by adding "SiteAPI" to the
/// token-valued, listOp metadata \em apiSchemas on the prim.
///
/// \return A valid MjcPhysicsSiteAPI object is returned upon success.
/// An invalid (or empty) MjcPhysicsSiteAPI 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 MjcPhysicsSiteAPI Apply(const UsdPrim &prim);
protected:
/// Returns the kind of schema this class belongs to.
///
/// \sa UsdSchemaKind
MJCPHYSICS_API
UsdSchemaKind _GetSchemaKind() const override;
private:
// needs to invoke _GetStaticTfType.
friend class UsdSchemaRegistry;
MJCPHYSICS_API
static const TfType &_GetStaticTfType();
static bool _IsTypedSchema();
// override SchemaBase virtuals.
MJCPHYSICS_API
const TfType &_GetTfType() const override;
public:
// ===================================================================== //
// Feel free to add custom code below this line, it will be preserved by
// the code generator.
//
// Just remember to:
// - Close the class declaration with };
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
// - Close the include guard with #endif
// ===================================================================== //
// --(BEGIN CUSTOM CODE)--
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif
@@ -0,0 +1,517 @@
// Copyright 2025 DeepMind Technologies Limited
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MJCPHYSICS_TOKENS_H
#define MJCPHYSICS_TOKENS_H
/// \file mjcPhysics/tokens.h
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//
// This is an automatically generated file (by usdGenSchema.py).
// Do not hand-edit!
//
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <vector>
#include <mujoco/experimental/usd/mjcPhysics/api.h>
#include "pxr/base/tf/staticData.h"
#include "pxr/base/tf/token.h"
#include "pxr/pxr.h"
PXR_NAMESPACE_OPEN_SCOPE
/// \class MjcPhysicsTokensType
///
/// \link MjcPhysicsTokens \endlink provides static, efficient
/// \link TfToken TfTokens\endlink for use in all public USD API.
///
/// These tokens are auto-generated from the module's schema, representing
/// property names, for when you need to fetch an attribute or relationship
/// directly by name, e.g. UsdPrim::GetAttribute(), in the most efficient
/// manner, and allow the compiler to verify that you spelled the name
/// correctly.
///
/// MjcPhysicsTokens also contains all of the \em allowedTokens values
/// declared for schema builtin attributes of 'token' scene description type.
/// Use MjcPhysicsTokens like so:
///
/// \code
/// gprim.GetMyTokenValuedAttr().Set(MjcPhysicsTokens->affine);
/// \endcode
struct MjcPhysicsTokensType {
MJCPHYSICS_API MjcPhysicsTokensType();
/// \brief "affine"
///
/// Possible value for MjcPhysicsActuatorAPI::GetMjcBiasTypeAttr(), Possible
/// value for MjcPhysicsActuatorAPI::GetMjcGainTypeAttr()
const TfToken affine;
/// \brief "auto"
///
/// Fallback value for MjcPhysicsSceneAPI::GetJacobianAttr(), Fallback value
/// for MjcPhysicsActuatorAPI::GetMjcActLimitedAttr(), Fallback value for
/// MjcPhysicsActuatorAPI::GetMjcCtrlLimitedAttr(), Fallback value for
/// MjcPhysicsActuatorAPI::GetMjcForceLimitedAttr(), This token represents
/// the auto constraint Jacobian and matrices computed from it.
const TfToken auto_;
/// \brief "cg"
///
/// Possible value for MjcPhysicsSceneAPI::GetSolverAttr(), This token
/// represents the CG constraint solver algorithm.
const TfToken cg;
/// \brief "convex"
///
/// Possible value for MjcPhysicsMeshCollisionAPI::GetInertiaAttr()
const TfToken convex;
/// \brief "dense"
///
/// Possible value for MjcPhysicsSceneAPI::GetJacobianAttr(), This token
/// represents the dense constraint Jacobian and matrices computed from it.
const TfToken dense;
/// \brief "elliptic"
///
/// Possible value for MjcPhysicsSceneAPI::GetConeAttr(), This token
/// represents the elliptic contact friction cone type.
const TfToken elliptic;
/// \brief "euler"
///
/// Fallback value for MjcPhysicsSceneAPI::GetIntegratorAttr(), This token
/// represents the Euler numerical integrator.
const TfToken euler;
/// \brief "exact"
///
/// Possible value for MjcPhysicsMeshCollisionAPI::GetInertiaAttr()
const TfToken exact;
/// \brief "false"
///
/// Possible value for MjcPhysicsActuatorAPI::GetMjcActLimitedAttr(), Possible
/// value for MjcPhysicsActuatorAPI::GetMjcCtrlLimitedAttr(), Possible value
/// for MjcPhysicsActuatorAPI::GetMjcForceLimitedAttr()
const TfToken false_;
/// \brief "filter"
///
/// Possible value for MjcPhysicsActuatorAPI::GetMjcDynTypeAttr()
const TfToken filter;
/// \brief "filterexact"
///
/// Possible value for MjcPhysicsActuatorAPI::GetMjcDynTypeAttr()
const TfToken filterexact;
/// \brief "fixed"
///
/// Fallback value for MjcPhysicsActuatorAPI::GetMjcGainTypeAttr()
const TfToken fixed;
/// \brief "implicit"
///
/// Possible value for MjcPhysicsSceneAPI::GetIntegratorAttr(), This token
/// represents the implicit numerical integrator.
const TfToken implicit;
/// \brief "implicitfast"
///
/// Possible value for MjcPhysicsSceneAPI::GetIntegratorAttr(), This token
/// represents the implicitfast numerical integrator.
const TfToken implicitfast;
/// \brief "integrator"
///
/// Possible value for MjcPhysicsActuatorAPI::GetMjcDynTypeAttr()
const TfToken integrator;
/// \brief "legacy"
///
/// Fallback value for MjcPhysicsMeshCollisionAPI::GetInertiaAttr()
const TfToken legacy;
/// \brief "mjc:actDim"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcActDim;
/// \brief "mjc:actEarly"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcActEarly;
/// \brief "mjc:actLimited"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcActLimited;
/// \brief "mjc:actRange:max"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcActRangeMax;
/// \brief "mjc:actRange:min"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcActRangeMin;
/// \brief "mjc:biasPrm"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcBiasPrm;
/// \brief "mjc:biasType"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcBiasType;
/// \brief "mjc:crankLength"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcCrankLength;
/// \brief "mjc:ctrlLimited"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcCtrlLimited;
/// \brief "mjc:ctrlRange:max"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcCtrlRangeMax;
/// \brief "mjc:ctrlRange:min"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcCtrlRangeMin;
/// \brief "mjc:dynPrm"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcDynPrm;
/// \brief "mjc:dynType"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcDynType;
/// \brief "mjc:flag:actuation"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagActuation;
/// \brief "mjc:flag:autoreset"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagAutoreset;
/// \brief "mjc:flag:clampctrl"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagClampctrl;
/// \brief "mjc:flag:constraint"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagConstraint;
/// \brief "mjc:flag:contact"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagContact;
/// \brief "mjc:flag:energy"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagEnergy;
/// \brief "mjc:flag:equality"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagEquality;
/// \brief "mjc:flag:eulerdamp"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagEulerdamp;
/// \brief "mjc:flag:filterparent"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagFilterparent;
/// \brief "mjc:flag:frictionloss"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagFrictionloss;
/// \brief "mjc:flag:fwdinv"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagFwdinv;
/// \brief "mjc:flag:gravity"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagGravity;
/// \brief "mjc:flag:invdiscrete"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagInvdiscrete;
/// \brief "mjc:flag:island"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagIsland;
/// \brief "mjc:flag:limit"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagLimit;
/// \brief "mjc:flag:midphase"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagMidphase;
/// \brief "mjc:flag:multiccd"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagMulticcd;
/// \brief "mjc:flag:nativeccd"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagNativeccd;
/// \brief "mjc:flag:override"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagOverride;
/// \brief "mjc:flag:passive"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagPassive;
/// \brief "mjc:flag:refsafe"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagRefsafe;
/// \brief "mjc:flag:sensor"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagSensor;
/// \brief "mjc:flag:warmstart"
///
/// MjcPhysicsSceneAPI
const TfToken mjcFlagWarmstart;
/// \brief "mjc:forceLimited"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcForceLimited;
/// \brief "mjc:forceRange:max"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcForceRangeMax;
/// \brief "mjc:forceRange:min"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcForceRangeMin;
/// \brief "mjc:gainPrm"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcGainPrm;
/// \brief "mjc:gainType"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcGainType;
/// \brief "mjc:gear"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcGear;
/// \brief "mjc:inertia"
///
/// MjcPhysicsMeshCollisionAPI
const TfToken mjcInertia;
/// \brief "mjc:jointInParent"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcJointInParent;
/// \brief "mjc:lengthRange:max"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcLengthRangeMax;
/// \brief "mjc:lengthRange:min"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcLengthRangeMin;
/// \brief "mjc:option:actuatorgroupdisable"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionActuatorgroupdisable;
/// \brief "mjc:option:apirate"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionApirate;
/// \brief "mjc:option:ccd_iterations"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionCcd_iterations;
/// \brief "mjc:option:ccd_tolerance"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionCcd_tolerance;
/// \brief "mjc:option:cone"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionCone;
/// \brief "mjc:option:density"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionDensity;
/// \brief "mjc:option:impratio"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionImpratio;
/// \brief "mjc:option:integrator"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionIntegrator;
/// \brief "mjc:option:iterations"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionIterations;
/// \brief "mjc:option:jacobian"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionJacobian;
/// \brief "mjc:option:ls_iterations"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionLs_iterations;
/// \brief "mjc:option:ls_tolerance"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionLs_tolerance;
/// \brief "mjc:option:magnetic"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionMagnetic;
/// \brief "mjc:option:noslip_iterations"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionNoslip_iterations;
/// \brief "mjc:option:noslip_tolerance"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionNoslip_tolerance;
/// \brief "mjc:option:o_friction"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionO_friction;
/// \brief "mjc:option:o_margin"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionO_margin;
/// \brief "mjc:option:o_solimp"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionO_solimp;
/// \brief "mjc:option:o_solref"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionO_solref;
/// \brief "mjc:option:sdf_initpoints"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionSdf_initpoints;
/// \brief "mjc:option:sdf_iterations"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionSdf_iterations;
/// \brief "mjc:option:solver"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionSolver;
/// \brief "mjc:option:timestep"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionTimestep;
/// \brief "mjc:option:tolerance"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionTolerance;
/// \brief "mjc:option:viscosity"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionViscosity;
/// \brief "mjc:option:wind"
///
/// MjcPhysicsSceneAPI
const TfToken mjcOptionWind;
/// \brief "mjc:refSite"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcRefSite;
/// \brief "mjc:shellinertia"
///
/// MjcPhysicsCollisionAPI
const TfToken mjcShellinertia;
/// \brief "mjc:sliderSite"
///
/// MjcPhysicsActuatorAPI
const TfToken mjcSliderSite;
/// \brief "muscle"
///
/// Possible value for MjcPhysicsActuatorAPI::GetMjcBiasTypeAttr(), Possible
/// value for MjcPhysicsActuatorAPI::GetMjcDynTypeAttr(), Possible value for
/// MjcPhysicsActuatorAPI::GetMjcGainTypeAttr()
const TfToken muscle;
/// \brief "newton"
///
/// Fallback value for MjcPhysicsSceneAPI::GetSolverAttr(), This token
/// represents the Newton constraint solver algorithm.
const TfToken newton;
/// \brief "none"
///
/// Fallback value for MjcPhysicsActuatorAPI::GetMjcBiasTypeAttr(), Fallback
/// value for MjcPhysicsActuatorAPI::GetMjcDynTypeAttr()
const TfToken none;
/// \brief "pgs"
///
/// Possible value for MjcPhysicsSceneAPI::GetSolverAttr(), This token
/// represents the PGS constraint solver algorithm.
const TfToken pgs;
/// \brief "pyramidal"
///
/// Fallback value for MjcPhysicsSceneAPI::GetConeAttr(), This token
/// represents the pyramidal contact friction cone type.
const TfToken pyramidal;
/// \brief "rk4"
///
/// Possible value for MjcPhysicsSceneAPI::GetIntegratorAttr(), This token
/// represents the RK4 numerical integrator.
const TfToken rk4;
/// \brief "shell"
///
/// Possible value for MjcPhysicsMeshCollisionAPI::GetInertiaAttr()
const TfToken shell;
/// \brief "sparse"
///
/// Possible value for MjcPhysicsSceneAPI::GetJacobianAttr(), This token
/// represents the sparse constraint Jacobian and matrices computed from it.
const TfToken sparse;
/// \brief "true"
///
/// Possible value for MjcPhysicsActuatorAPI::GetMjcActLimitedAttr(), Possible
/// value for MjcPhysicsActuatorAPI::GetMjcCtrlLimitedAttr(), Possible value
/// for MjcPhysicsActuatorAPI::GetMjcForceLimitedAttr()
const TfToken true_;
/// \brief "user"
///
/// Possible value for MjcPhysicsActuatorAPI::GetMjcBiasTypeAttr(), Possible
/// value for MjcPhysicsActuatorAPI::GetMjcDynTypeAttr(), Possible value for
/// MjcPhysicsActuatorAPI::GetMjcGainTypeAttr()
const TfToken user;
/// \brief "CollisionAPI"
///
/// Schema identifer and family for MjcPhysicsCollisionAPI
const TfToken CollisionAPI;
/// \brief "MeshCollisionAPI"
///
/// Schema identifer and family for MjcPhysicsMeshCollisionAPI
const TfToken MeshCollisionAPI;
/// \brief "PhysicsActuatorAPI"
///
/// Schema identifer and family for MjcPhysicsActuatorAPI
const TfToken PhysicsActuatorAPI;
/// \brief "SceneAPI"
///
/// Schema identifer and family for MjcPhysicsSceneAPI
const TfToken SceneAPI;
/// \brief "SiteAPI"
///
/// Schema identifer and family for MjcPhysicsSiteAPI
const TfToken SiteAPI;
/// A vector of all of the tokens listed above.
const std::vector<TfToken> allTokens;
};
/// \var MjcPhysicsTokens
///
/// A global variable with static, efficient \link TfToken TfTokens\endlink
/// for use in all public USD API. \sa MjcPhysicsTokensType
extern MJCPHYSICS_API TfStaticData<MjcPhysicsTokensType> MjcPhysicsTokens;
PXR_NAMESPACE_CLOSE_SCOPE
#endif
+35
View File
@@ -0,0 +1,35 @@
// Copyright 2025 DeepMind Technologies Limited
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUJOCO_SRC_EXPERIMENTAL_USD_UTILS_H_
#define MUJOCO_SRC_EXPERIMENTAL_USD_UTILS_H_
#include <mujoco/mujoco.h>
#include <pxr/usd/sdf/path.h>
namespace mujoco {
namespace usd {
// Sets a user value on an mjsElement with the key "usd_primpath".
void SetUsdPrimPathUserValue(mjsElement* element,
const pxr::SdfPath& prim_path);
// Gets the user value associated with the key "usd_primpath" from an
// mjsElement. Returns empty pxr::SdfPath() if the value is not found.
pxr::SdfPath GetUsdPrimPathUserValue(mjsElement* element);
} // namespace usd
} // namespace mujoco
#endif // MUJOCO_SRC_EXPERIMENTAL_USD_UTILS_H_
+52
View File
@@ -0,0 +1,52 @@
// Copyright 2025 DeepMind Technologies Limited
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MUJOCO_SRC_EXPERIMENTAL_USD_WRITER_H_
#define MUJOCO_SRC_EXPERIMENTAL_USD_WRITER_H_
#include <functional>
#include <vector>
#include <mujoco/mujoco.h>
#include <pxr/usd/sdf/path.h>
#include <pxr/usd/usd/common.h>
namespace mujoco {
namespace usd {
using PoseSinkFn =
std::function<void(const mjData* const, std::vector<pxr::SdfPath>)>;
class Writer {
public:
Writer(pxr::UsdStageRefPtr stage, mjSpec* spec, mjModel_* model);
~Writer();
Writer(const Writer&) = delete;
Writer& operator=(const Writer&) = delete;
void Update(const mjData* const data);
void AddSink(PoseSinkFn sink_fn);
private:
void BuildMjUsdMapping();
pxr::UsdStageRefPtr stage_;
std::vector<pxr::SdfPath> body_id_to_path_;
mjSpec* spec_ = nullptr;
mjModel_* model_ = nullptr;
std::vector<PoseSinkFn> pose_sinks_;
};
} // namespace usd
} // namespace mujoco
#endif // MUJOCO_SRC_EXPERIMENTAL_USD_WRITER_H_