|
| 1 | +// Copyright 2025 DeepMind Technologies Limited |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +#ifndef MJCPHYSICS_GENERATED_KEYFRAME_H |
| 16 | +#define MJCPHYSICS_GENERATED_KEYFRAME_H |
| 17 | + |
| 18 | +/// \file mjcPhysics/keyframe.h |
| 19 | + |
| 20 | +#include <mujoco/experimental/usd/mjcPhysics/api.h> |
| 21 | +#include <mujoco/experimental/usd/mjcPhysics/tokens.h> |
| 22 | +#include <pxr/base/gf/matrix4d.h> |
| 23 | +#include <pxr/base/gf/vec3d.h> |
| 24 | +#include <pxr/base/gf/vec3f.h> |
| 25 | +#include <pxr/base/tf/token.h> |
| 26 | +#include <pxr/base/tf/type.h> |
| 27 | +#include <pxr/base/vt/value.h> |
| 28 | +#include <pxr/pxr.h> |
| 29 | +#include <pxr/usd/usd/prim.h> |
| 30 | +#include <pxr/usd/usd/stage.h> |
| 31 | +#include <pxr/usd/usd/typed.h> |
| 32 | + |
| 33 | +PXR_NAMESPACE_OPEN_SCOPE |
| 34 | + |
| 35 | +class SdfAssetPath; |
| 36 | + |
| 37 | +// -------------------------------------------------------------------------- // |
| 38 | +// KEYFRAME // |
| 39 | +// -------------------------------------------------------------------------- // |
| 40 | + |
| 41 | +/// \class MjcPhysicsKeyframe |
| 42 | +/// |
| 43 | +/// Represents time independent keyframe values. |
| 44 | +/// |
| 45 | +class MjcPhysicsKeyframe : public UsdTyped { |
| 46 | + public: |
| 47 | + /// Compile time constant representing what kind of schema this class is. |
| 48 | + /// |
| 49 | + /// \sa UsdSchemaKind |
| 50 | + static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped; |
| 51 | + |
| 52 | + /// Construct a MjcPhysicsKeyframe on UsdPrim \p prim . |
| 53 | + /// Equivalent to MjcPhysicsKeyframe::Get(prim.GetStage(), prim.GetPath()) |
| 54 | + /// for a \em valid \p prim, but will not immediately throw an error for |
| 55 | + /// an invalid \p prim |
| 56 | + explicit MjcPhysicsKeyframe(const UsdPrim &prim = UsdPrim()) |
| 57 | + : UsdTyped(prim) {} |
| 58 | + |
| 59 | + /// Construct a MjcPhysicsKeyframe on the prim held by \p schemaObj . |
| 60 | + /// Should be preferred over MjcPhysicsKeyframe(schemaObj.GetPrim()), |
| 61 | + /// as it preserves SchemaBase state. |
| 62 | + explicit MjcPhysicsKeyframe(const UsdSchemaBase &schemaObj) |
| 63 | + : UsdTyped(schemaObj) {} |
| 64 | + |
| 65 | + /// Destructor. |
| 66 | + MJCPHYSICS_API |
| 67 | + virtual ~MjcPhysicsKeyframe(); |
| 68 | + |
| 69 | + /// Return a vector of names of all pre-declared attributes for this schema |
| 70 | + /// class and all its ancestor classes. Does not include attributes that |
| 71 | + /// may be authored by custom/extended methods of the schemas involved. |
| 72 | + MJCPHYSICS_API |
| 73 | + static const TfTokenVector &GetSchemaAttributeNames( |
| 74 | + bool includeInherited = true); |
| 75 | + |
| 76 | + /// Return a MjcPhysicsKeyframe holding the prim adhering to this |
| 77 | + /// schema at \p path on \p stage. If no prim exists at \p path on |
| 78 | + /// \p stage, or if the prim at that path does not adhere to this schema, |
| 79 | + /// return an invalid schema object. This is shorthand for the following: |
| 80 | + /// |
| 81 | + /// \code |
| 82 | + /// MjcPhysicsKeyframe(stage->GetPrimAtPath(path)); |
| 83 | + /// \endcode |
| 84 | + /// |
| 85 | + MJCPHYSICS_API |
| 86 | + static MjcPhysicsKeyframe Get(const UsdStagePtr &stage, const SdfPath &path); |
| 87 | + |
| 88 | + /// Attempt to ensure a \a UsdPrim adhering to this schema at \p path |
| 89 | + /// is defined (according to UsdPrim::IsDefined()) on this stage. |
| 90 | + /// |
| 91 | + /// If a prim adhering to this schema at \p path is already defined on this |
| 92 | + /// stage, return that prim. Otherwise author an \a SdfPrimSpec with |
| 93 | + /// \a specifier == \a SdfSpecifierDef and this schema's prim type name for |
| 94 | + /// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s |
| 95 | + /// with \p specifier == \a SdfSpecifierDef and empty typeName at the |
| 96 | + /// current EditTarget for any nonexistent, or existing but not \a Defined |
| 97 | + /// ancestors. |
| 98 | + /// |
| 99 | + /// The given \a path must be an absolute prim path that does not contain |
| 100 | + /// any variant selections. |
| 101 | + /// |
| 102 | + /// If it is impossible to author any of the necessary PrimSpecs, (for |
| 103 | + /// example, in case \a path cannot map to the current UsdEditTarget's |
| 104 | + /// namespace) issue an error and return an invalid \a UsdPrim. |
| 105 | + /// |
| 106 | + /// Note that this method may return a defined prim whose typeName does not |
| 107 | + /// specify this schema class, in case a stronger typeName opinion overrides |
| 108 | + /// the opinion at the current EditTarget. |
| 109 | + /// |
| 110 | + MJCPHYSICS_API |
| 111 | + static MjcPhysicsKeyframe Define(const UsdStagePtr &stage, |
| 112 | + const SdfPath &path); |
| 113 | + |
| 114 | + protected: |
| 115 | + /// Returns the kind of schema this class belongs to. |
| 116 | + /// |
| 117 | + /// \sa UsdSchemaKind |
| 118 | + MJCPHYSICS_API |
| 119 | + UsdSchemaKind _GetSchemaKind() const override; |
| 120 | + |
| 121 | + private: |
| 122 | + // needs to invoke _GetStaticTfType. |
| 123 | + friend class UsdSchemaRegistry; |
| 124 | + MJCPHYSICS_API |
| 125 | + static const TfType &_GetStaticTfType(); |
| 126 | + |
| 127 | + static bool _IsTypedSchema(); |
| 128 | + |
| 129 | + // override SchemaBase virtuals. |
| 130 | + MJCPHYSICS_API |
| 131 | + const TfType &_GetTfType() const override; |
| 132 | + |
| 133 | + public: |
| 134 | + // --------------------------------------------------------------------- // |
| 135 | + // MJCQPOS |
| 136 | + // --------------------------------------------------------------------- // |
| 137 | + /// Vector of joint positions, copied into mjData.qpos when the simulation |
| 138 | + /// state is set to this keyframe. |
| 139 | + /// |
| 140 | + /// | || |
| 141 | + /// | -- | -- | |
| 142 | + /// | Declaration | `double[] mjc:qpos` | |
| 143 | + /// | C++ Type | VtArray<double> | |
| 144 | + /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->DoubleArray | |
| 145 | + MJCPHYSICS_API |
| 146 | + UsdAttribute GetMjcQposAttr() const; |
| 147 | + |
| 148 | + /// See GetMjcQposAttr(), and also |
| 149 | + /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. |
| 150 | + /// If specified, author \p defaultValue as the attribute's default, |
| 151 | + /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - |
| 152 | + /// the default for \p writeSparsely is \c false. |
| 153 | + MJCPHYSICS_API |
| 154 | + UsdAttribute CreateMjcQposAttr(VtValue const &defaultValue = VtValue(), |
| 155 | + bool writeSparsely = false) const; |
| 156 | + |
| 157 | + public: |
| 158 | + // --------------------------------------------------------------------- // |
| 159 | + // MJCQVEL |
| 160 | + // --------------------------------------------------------------------- // |
| 161 | + /// Vector of joint velocities, copied into mjData.qvel when the simulation |
| 162 | + /// state is set to this keyframe. |
| 163 | + /// |
| 164 | + /// | || |
| 165 | + /// | -- | -- | |
| 166 | + /// | Declaration | `double[] mjc:qvel` | |
| 167 | + /// | C++ Type | VtArray<double> | |
| 168 | + /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->DoubleArray | |
| 169 | + MJCPHYSICS_API |
| 170 | + UsdAttribute GetMjcQvelAttr() const; |
| 171 | + |
| 172 | + /// See GetMjcQvelAttr(), and also |
| 173 | + /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. |
| 174 | + /// If specified, author \p defaultValue as the attribute's default, |
| 175 | + /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - |
| 176 | + /// the default for \p writeSparsely is \c false. |
| 177 | + MJCPHYSICS_API |
| 178 | + UsdAttribute CreateMjcQvelAttr(VtValue const &defaultValue = VtValue(), |
| 179 | + bool writeSparsely = false) const; |
| 180 | + |
| 181 | + public: |
| 182 | + // --------------------------------------------------------------------- // |
| 183 | + // MJCACT |
| 184 | + // --------------------------------------------------------------------- // |
| 185 | + /// Vector of actuator activations, copied into mjData.act when the simulation |
| 186 | + /// state is set to this keyframe. |
| 187 | + /// |
| 188 | + /// | || |
| 189 | + /// | -- | -- | |
| 190 | + /// | Declaration | `double[] mjc:act` | |
| 191 | + /// | C++ Type | VtArray<double> | |
| 192 | + /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->DoubleArray | |
| 193 | + MJCPHYSICS_API |
| 194 | + UsdAttribute GetMjcActAttr() const; |
| 195 | + |
| 196 | + /// See GetMjcActAttr(), and also |
| 197 | + /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. |
| 198 | + /// If specified, author \p defaultValue as the attribute's default, |
| 199 | + /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - |
| 200 | + /// the default for \p writeSparsely is \c false. |
| 201 | + MJCPHYSICS_API |
| 202 | + UsdAttribute CreateMjcActAttr(VtValue const &defaultValue = VtValue(), |
| 203 | + bool writeSparsely = false) const; |
| 204 | + |
| 205 | + public: |
| 206 | + // --------------------------------------------------------------------- // |
| 207 | + // MJCCTRL |
| 208 | + // --------------------------------------------------------------------- // |
| 209 | + /// Vector of controls, copied into mjData.ctrl when the simulation state is |
| 210 | + /// set to this keyframe. |
| 211 | + /// |
| 212 | + /// | || |
| 213 | + /// | -- | -- | |
| 214 | + /// | Declaration | `double[] mjc:ctrl` | |
| 215 | + /// | C++ Type | VtArray<double> | |
| 216 | + /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->DoubleArray | |
| 217 | + MJCPHYSICS_API |
| 218 | + UsdAttribute GetMjcCtrlAttr() const; |
| 219 | + |
| 220 | + /// See GetMjcCtrlAttr(), and also |
| 221 | + /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. |
| 222 | + /// If specified, author \p defaultValue as the attribute's default, |
| 223 | + /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - |
| 224 | + /// the default for \p writeSparsely is \c false. |
| 225 | + MJCPHYSICS_API |
| 226 | + UsdAttribute CreateMjcCtrlAttr(VtValue const &defaultValue = VtValue(), |
| 227 | + bool writeSparsely = false) const; |
| 228 | + |
| 229 | + public: |
| 230 | + // --------------------------------------------------------------------- // |
| 231 | + // MJCMPOS |
| 232 | + // --------------------------------------------------------------------- // |
| 233 | + /// Vector of mocap body positions, copied into mjData.mocap_pos when the |
| 234 | + /// simulation state is set to this keyframe. |
| 235 | + /// |
| 236 | + /// | || |
| 237 | + /// | -- | -- | |
| 238 | + /// | Declaration | `double[] mjc:mpos` | |
| 239 | + /// | C++ Type | VtArray<double> | |
| 240 | + /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->DoubleArray | |
| 241 | + MJCPHYSICS_API |
| 242 | + UsdAttribute GetMjcMposAttr() const; |
| 243 | + |
| 244 | + /// See GetMjcMposAttr(), and also |
| 245 | + /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. |
| 246 | + /// If specified, author \p defaultValue as the attribute's default, |
| 247 | + /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - |
| 248 | + /// the default for \p writeSparsely is \c false. |
| 249 | + MJCPHYSICS_API |
| 250 | + UsdAttribute CreateMjcMposAttr(VtValue const &defaultValue = VtValue(), |
| 251 | + bool writeSparsely = false) const; |
| 252 | + |
| 253 | + public: |
| 254 | + // --------------------------------------------------------------------- // |
| 255 | + // MJCMQUAT |
| 256 | + // --------------------------------------------------------------------- // |
| 257 | + /// Vector of mocap body quaternions, copied into mjData.mocap_quat when the |
| 258 | + /// simulation state is set to this keyframe. |
| 259 | + /// |
| 260 | + /// | || |
| 261 | + /// | -- | -- | |
| 262 | + /// | Declaration | `double[] mjc:mquat` | |
| 263 | + /// | C++ Type | VtArray<double> | |
| 264 | + /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->DoubleArray | |
| 265 | + MJCPHYSICS_API |
| 266 | + UsdAttribute GetMjcMquatAttr() const; |
| 267 | + |
| 268 | + /// See GetMjcMquatAttr(), and also |
| 269 | + /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. |
| 270 | + /// If specified, author \p defaultValue as the attribute's default, |
| 271 | + /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - |
| 272 | + /// the default for \p writeSparsely is \c false. |
| 273 | + MJCPHYSICS_API |
| 274 | + UsdAttribute CreateMjcMquatAttr(VtValue const &defaultValue = VtValue(), |
| 275 | + bool writeSparsely = false) const; |
| 276 | + |
| 277 | + public: |
| 278 | + // ===================================================================== // |
| 279 | + // Feel free to add custom code below this line, it will be preserved by |
| 280 | + // the code generator. |
| 281 | + // |
| 282 | + // Just remember to: |
| 283 | + // - Close the class declaration with }; |
| 284 | + // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE |
| 285 | + // - Close the include guard with #endif |
| 286 | + // ===================================================================== // |
| 287 | + // --(BEGIN CUSTOM CODE)-- |
| 288 | +}; |
| 289 | + |
| 290 | +PXR_NAMESPACE_CLOSE_SCOPE |
| 291 | + |
| 292 | +#endif |
0 commit comments