HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
driveAPI.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef USDPHYSICS_GENERATED_DRIVEAPI_H
25 #define USDPHYSICS_GENERATED_DRIVEAPI_H
26 
27 /// \file usdPhysics/driveAPI.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdPhysics/api.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
35 
36 #include "pxr/base/vt/value.h"
37 
38 #include "pxr/base/gf/vec3d.h"
39 #include "pxr/base/gf/vec3f.h"
40 #include "pxr/base/gf/matrix4d.h"
41 
42 #include "pxr/base/tf/token.h"
43 #include "pxr/base/tf/type.h"
44 
46 
47 class SdfAssetPath;
48 
49 // -------------------------------------------------------------------------- //
50 // PHYSICSDRIVEAPI //
51 // -------------------------------------------------------------------------- //
52 
53 /// \class UsdPhysicsDriveAPI
54 ///
55 /// The PhysicsDriveAPI when applied to any joint primitive will drive
56 /// the joint towards a given target. The PhysicsDriveAPI is a multipleApply
57 /// schema: drive can be set per axis "transX", "transY", "transZ", "rotX",
58 /// "rotY", "rotZ" or its "linear" for prismatic joint or "angular" for revolute
59 /// joints. Setting these as a multipleApply schema TfToken name will
60 /// define the degree of freedom the DriveAPI is applied to. Each drive is an
61 /// implicit force-limited damped spring:
62 /// Force or acceleration = stiffness * (targetPosition - position)
63 /// + damping * (targetVelocity - velocity)
64 ///
65 /// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
66 /// that are text/tokens, the actual token is published and defined in \ref UsdPhysicsTokens.
67 /// So to set an attribute to the value "rightHanded", use UsdPhysicsTokens->rightHanded
68 /// as the value.
69 ///
71 {
72 public:
73  /// Compile time constant representing what kind of schema this class is.
74  ///
75  /// \sa UsdSchemaKind
77 
78  /// Construct a UsdPhysicsDriveAPI on UsdPrim \p prim with
79  /// name \p name . Equivalent to
80  /// UsdPhysicsDriveAPI::Get(
81  /// prim.GetStage(),
82  /// prim.GetPath().AppendProperty(
83  /// "drive:name"));
84  ///
85  /// for a \em valid \p prim, but will not immediately throw an error for
86  /// an invalid \p prim
88  const UsdPrim& prim=UsdPrim(), const TfToken &name=TfToken())
89  : UsdAPISchemaBase(prim, /*instanceName*/ name)
90  { }
91 
92  /// Construct a UsdPhysicsDriveAPI on the prim held by \p schemaObj with
93  /// name \p name. Should be preferred over
94  /// UsdPhysicsDriveAPI(schemaObj.GetPrim(), name), as it preserves
95  /// SchemaBase state.
97  const UsdSchemaBase& schemaObj, const TfToken &name)
98  : UsdAPISchemaBase(schemaObj, /*instanceName*/ name)
99  { }
100 
101  /// Destructor.
103  virtual ~UsdPhysicsDriveAPI();
104 
105  /// Return a vector of names of all pre-declared attributes for this schema
106  /// class and all its ancestor classes. Does not include attributes that
107  /// may be authored by custom/extended methods of the schemas involved.
109  static const TfTokenVector &
110  GetSchemaAttributeNames(bool includeInherited=true);
111 
112  /// Return a vector of names of all pre-declared attributes for this schema
113  /// class and all its ancestor classes for a given instance name. Does not
114  /// include attributes that may be authored by custom/extended methods of
115  /// the schemas involved. The names returned will have the proper namespace
116  /// prefix.
118  static TfTokenVector
119  GetSchemaAttributeNames(bool includeInherited, const TfToken &instanceName);
120 
121  /// Returns the name of this multiple-apply schema instance
122  TfToken GetName() const {
123  return _GetInstanceName();
124  }
125 
126  /// Return a UsdPhysicsDriveAPI holding the prim adhering to this
127  /// schema at \p path on \p stage. If no prim exists at \p path on
128  /// \p stage, or if the prim at that path does not adhere to this schema,
129  /// return an invalid schema object. \p path must be of the format
130  /// <path>.drive:name .
131  ///
132  /// This is shorthand for the following:
133  ///
134  /// \code
135  /// TfToken name = SdfPath::StripNamespace(path.GetToken());
136  /// UsdPhysicsDriveAPI(
137  /// stage->GetPrimAtPath(path.GetPrimPath()), name);
138  /// \endcode
139  ///
141  static UsdPhysicsDriveAPI
142  Get(const UsdStagePtr &stage, const SdfPath &path);
143 
144  /// Return a UsdPhysicsDriveAPI with name \p name holding the
145  /// prim \p prim. Shorthand for UsdPhysicsDriveAPI(prim, name);
147  static UsdPhysicsDriveAPI
148  Get(const UsdPrim &prim, const TfToken &name);
149 
150  /// Return a vector of all named instances of UsdPhysicsDriveAPI on the
151  /// given \p prim.
153  static std::vector<UsdPhysicsDriveAPI>
154  GetAll(const UsdPrim &prim);
155 
156  /// Checks if the given name \p baseName is the base name of a property
157  /// of PhysicsDriveAPI.
159  static bool
160  IsSchemaPropertyBaseName(const TfToken &baseName);
161 
162  /// Checks if the given path \p path is of an API schema of type
163  /// PhysicsDriveAPI. If so, it stores the instance name of
164  /// the schema in \p name and returns true. Otherwise, it returns false.
166  static bool
168 
169  /// Returns true if this <b>multiple-apply</b> API schema can be applied,
170  /// with the given instance name, \p name, to the given \p prim. If this
171  /// schema can not be a applied the prim, this returns false and, if
172  /// provided, populates \p whyNot with the reason it can not be applied.
173  ///
174  /// Note that if CanApply returns false, that does not necessarily imply
175  /// that calling Apply will fail. Callers are expected to call CanApply
176  /// before calling Apply if they want to ensure that it is valid to
177  /// apply a schema.
178  ///
179  /// \sa UsdPrim::GetAppliedSchemas()
180  /// \sa UsdPrim::HasAPI()
181  /// \sa UsdPrim::CanApplyAPI()
182  /// \sa UsdPrim::ApplyAPI()
183  /// \sa UsdPrim::RemoveAPI()
184  ///
186  static bool
187  CanApply(const UsdPrim &prim, const TfToken &name,
188  std::string *whyNot=nullptr);
189 
190  /// Applies this <b>multiple-apply</b> API schema to the given \p prim
191  /// along with the given instance name, \p name.
192  ///
193  /// This information is stored by adding "PhysicsDriveAPI:<i>name</i>"
194  /// to the token-valued, listOp metadata \em apiSchemas on the prim.
195  /// For example, if \p name is 'instance1', the token
196  /// 'PhysicsDriveAPI:instance1' is added to 'apiSchemas'.
197  ///
198  /// \return A valid UsdPhysicsDriveAPI object is returned upon success.
199  /// An invalid (or empty) UsdPhysicsDriveAPI object is returned upon
200  /// failure. See \ref UsdPrim::ApplyAPI() for
201  /// conditions resulting in failure.
202  ///
203  /// \sa UsdPrim::GetAppliedSchemas()
204  /// \sa UsdPrim::HasAPI()
205  /// \sa UsdPrim::CanApplyAPI()
206  /// \sa UsdPrim::ApplyAPI()
207  /// \sa UsdPrim::RemoveAPI()
208  ///
210  static UsdPhysicsDriveAPI
211  Apply(const UsdPrim &prim, const TfToken &name);
212 
213 protected:
214  /// Returns the kind of schema this class belongs to.
215  ///
216  /// \sa UsdSchemaKind
218  UsdSchemaKind _GetSchemaKind() const override;
219 
220 private:
221  // needs to invoke _GetStaticTfType.
222  friend class UsdSchemaRegistry;
224  static const TfType &_GetStaticTfType();
225 
226  static bool _IsTypedSchema();
227 
228  // override SchemaBase virtuals.
230  const TfType &_GetTfType() const override;
231 
232 public:
233  // --------------------------------------------------------------------- //
234  // TYPE
235  // --------------------------------------------------------------------- //
236  /// Drive spring is for the acceleration at the joint (rather
237  /// than the force).
238  ///
239  /// | ||
240  /// | -- | -- |
241  /// | Declaration | `uniform token physics:type = "force"` |
242  /// | C++ Type | TfToken |
243  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
244  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
245  /// | \ref UsdPhysicsTokens "Allowed Values" | force, acceleration |
247  UsdAttribute GetTypeAttr() const;
248 
249  /// See GetTypeAttr(), and also
250  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
251  /// If specified, author \p defaultValue as the attribute's default,
252  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
253  /// the default for \p writeSparsely is \c false.
255  UsdAttribute CreateTypeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
256 
257 public:
258  // --------------------------------------------------------------------- //
259  // MAXFORCE
260  // --------------------------------------------------------------------- //
261  /// Maximum force that can be applied to drive. Units:
262  /// if linear drive: mass*DIST_UNITS/second/second
263  /// if angular drive: mass*DIST_UNITS*DIST_UNITS/second/second
264  /// inf means not limited. Must be non-negative.
265  ///
266  ///
267  /// | ||
268  /// | -- | -- |
269  /// | Declaration | `float physics:maxForce = inf` |
270  /// | C++ Type | float |
271  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
274 
275  /// See GetMaxForceAttr(), and also
276  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
277  /// If specified, author \p defaultValue as the attribute's default,
278  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
279  /// the default for \p writeSparsely is \c false.
281  UsdAttribute CreateMaxForceAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
282 
283 public:
284  // --------------------------------------------------------------------- //
285  // TARGETPOSITION
286  // --------------------------------------------------------------------- //
287  /// Target value for position. Units:
288  /// if linear drive: distance
289  /// if angular drive: degrees.
290  ///
291  /// | ||
292  /// | -- | -- |
293  /// | Declaration | `float physics:targetPosition = 0` |
294  /// | C++ Type | float |
295  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
298 
299  /// See GetTargetPositionAttr(), and also
300  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
301  /// If specified, author \p defaultValue as the attribute's default,
302  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
303  /// the default for \p writeSparsely is \c false.
305  UsdAttribute CreateTargetPositionAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
306 
307 public:
308  // --------------------------------------------------------------------- //
309  // TARGETVELOCITY
310  // --------------------------------------------------------------------- //
311  /// Target value for velocity. Units:
312  /// if linear drive: distance/second
313  /// if angular drive: degrees/second.
314  ///
315  /// | ||
316  /// | -- | -- |
317  /// | Declaration | `float physics:targetVelocity = 0` |
318  /// | C++ Type | float |
319  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
322 
323  /// See GetTargetVelocityAttr(), and also
324  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
325  /// If specified, author \p defaultValue as the attribute's default,
326  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
327  /// the default for \p writeSparsely is \c false.
329  UsdAttribute CreateTargetVelocityAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
330 
331 public:
332  // --------------------------------------------------------------------- //
333  // DAMPING
334  // --------------------------------------------------------------------- //
335  /// Damping of the drive. Units:
336  /// if linear drive: mass/second
337  /// If angular drive: mass*DIST_UNITS*DIST_UNITS/second/degrees.
338  ///
339  /// | ||
340  /// | -- | -- |
341  /// | Declaration | `float physics:damping = 0` |
342  /// | C++ Type | float |
343  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
346 
347  /// See GetDampingAttr(), and also
348  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
349  /// If specified, author \p defaultValue as the attribute's default,
350  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
351  /// the default for \p writeSparsely is \c false.
353  UsdAttribute CreateDampingAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
354 
355 public:
356  // --------------------------------------------------------------------- //
357  // STIFFNESS
358  // --------------------------------------------------------------------- //
359  /// Stiffness of the drive. Units:
360  /// if linear drive: mass/second/second
361  /// if angular drive: mass*DIST_UNITS*DIST_UNITS/degrees/second/second.
362  ///
363  /// | ||
364  /// | -- | -- |
365  /// | Declaration | `float physics:stiffness = 0` |
366  /// | C++ Type | float |
367  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
370 
371  /// See GetStiffnessAttr(), and also
372  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
373  /// If specified, author \p defaultValue as the attribute's default,
374  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
375  /// the default for \p writeSparsely is \c false.
377  UsdAttribute CreateStiffnessAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
378 
379 public:
380  // ===================================================================== //
381  // Feel free to add custom code below this line, it will be preserved by
382  // the code generator.
383  //
384  // Just remember to:
385  // - Close the class declaration with };
386  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
387  // - Close the include guard with #endif
388  // ===================================================================== //
389  // --(BEGIN CUSTOM CODE)--
390 };
391 
393 
394 #endif
static USDPHYSICS_API std::vector< UsdPhysicsDriveAPI > GetAll(const UsdPrim &prim)
USDPHYSICS_API UsdAttribute CreateStiffnessAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDPHYSICS_API UsdSchemaKind _GetSchemaKind() const override
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
USDPHYSICS_API UsdAttribute GetDampingAttr() const
static USDPHYSICS_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
const TfToken & _GetInstanceName() const
USDPHYSICS_API UsdAttribute CreateDampingAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: token.h:87
USDPHYSICS_API UsdAttribute GetTargetPositionAttr() const
static USDPHYSICS_API bool CanApply(const UsdPrim &prim, const TfToken &name, std::string *whyNot=nullptr)
static USDPHYSICS_API bool IsSchemaPropertyBaseName(const TfToken &baseName)
UsdPhysicsDriveAPI(const UsdPrim &prim=UsdPrim(), const TfToken &name=TfToken())
Definition: driveAPI.h:87
static USDPHYSICS_API UsdPhysicsDriveAPI Apply(const UsdPrim &prim, const TfToken &name)
static USDPHYSICS_API bool IsPhysicsDriveAPIPath(const SdfPath &path, TfToken *name)
USDPHYSICS_API UsdAttribute GetMaxForceAttr() const
static const UsdSchemaKind schemaKind
Definition: driveAPI.h:76
USDPHYSICS_API UsdAttribute CreateTypeAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: prim.h:135
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
GLuint const GLchar * name
Definition: glcorearb.h:786
Definition: path.h:291
USDPHYSICS_API UsdAttribute GetStiffnessAttr() const
USDPHYSICS_API UsdAttribute CreateTargetVelocityAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
#define USDPHYSICS_API
Definition: api.h:40
UsdSchemaKind
Definition: common.h:127
USDPHYSICS_API UsdAttribute GetTypeAttr() const
virtual USDPHYSICS_API ~UsdPhysicsDriveAPI()
Destructor.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
static USDPHYSICS_API UsdPhysicsDriveAPI Get(const UsdStagePtr &stage, const SdfPath &path)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
Definition: type.h:64
UsdPhysicsDriveAPI(const UsdSchemaBase &schemaObj, const TfToken &name)
Definition: driveAPI.h:96
USDPHYSICS_API UsdAttribute CreateMaxForceAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
TfToken GetName() const
Returns the name of this multiple-apply schema instance.
Definition: driveAPI.h:122
USDPHYSICS_API UsdAttribute GetTargetVelocityAttr() const
Definition: value.h:167
Multiple Apply API Schema.
USDPHYSICS_API UsdAttribute CreateTargetPositionAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const