Simbody  3.5
SimTK::Motion::Custom Class Reference

This class can be used to define new motions. More...

+ Inheritance diagram for SimTK::Motion::Custom:

Classes

class  Implementation
 This is the abstract base class for Custom Motion implementations. More...
 

Public Member Functions

 Custom (MobilizedBody &mobod, Implementation *implementation)
 Create a Custom Motion. More...
 
 Custom ()
 Default constructor creates an empty handle that can be assigned to reference any Motion::Custom object. More...
 
- Public Member Functions inherited from SimTK::Motion
 Motion ()
 Default constructor creates an empty Motion handle that can be assigned to reference any kind of Motion object. More...
 
Level getLevel (const State &) const
 Get the highest level being driven by this Motion. More...
 
Method getLevelMethod (const State &) const
 Get the method being used to control the indicated Level. More...
 
void disable (State &state) const
 Disable this Motion, effectively removing it from the mobilizer to which it belongs and allowing the mobilizer to move freely (unless locked). More...
 
void enable (State &state) const
 Enable this Motion, without necessarily satisfying it. More...
 
bool isDisabled (const State &state) const
 Test whether this Motion is currently disabled in the supplied State. More...
 
void setDisabledByDefault (bool shouldBeDisabled)
 Specify that a Motion is to be inactive by default. More...
 
bool isDisabledByDefault () const
 Test whether this Motion is disabled by default in which case it must be explicitly enabled before it will take effect. More...
 
const MobilizedBodygetMobilizedBody () const
 Get the MobilizedBody to which this Motion belongs. More...
 
void calcAllMethods (const State &s, Method &qMethod, Method &uMethod, Method &udotMethod) const
 (Advanced) This implements the above table. More...
 
- Public Member Functions inherited from SimTK::PIMPLHandle< Motion, MotionImpl, true >
bool isEmptyHandle () const
 Returns true if this handle is empty, that is, does not refer to any implementation object. More...
 
bool isOwnerHandle () const
 Returns true if this handle is the owner of the implementation object to which it refers. More...
 
bool isSameHandle (const Motion &other) const
 Determine whether the supplied handle is the same object as "this" PIMPLHandle. More...
 
void disown (Motion &newOwner)
 Give up ownership of the implementation to an empty handle. More...
 
PIMPLHandlereferenceAssign (const Motion &source)
 "Copy" assignment but with shallow (pointer) semantics. More...
 
PIMPLHandlecopyAssign (const Motion &source)
 This is real copy assignment, with ordinary C++ object ("value") semantics. More...
 
void clearHandle ()
 Make this an empty handle, deleting the implementation object if this handle is the owner of it. More...
 
const MotionImpl & getImpl () const
 Get a const reference to the implementation associated with this Handle. More...
 
MotionImpl & updImpl ()
 Get a writable reference to the implementation associated with this Handle. More...
 
int getImplHandleCount () const
 Return the number of handles the implementation believes are referencing it. More...
 

Protected Member Functions

const ImplementationgetImplementation () const
 
ImplementationupdImplementation ()
 
- Protected Member Functions inherited from SimTK::Motion
 Motion (MotionImpl *r)
 For internal use: construct a new Motion handle referencing a particular implementation object. More...
 
- Protected Member Functions inherited from SimTK::PIMPLHandle< Motion, MotionImpl, true >
 PIMPLHandle ()
 The default constructor makes this an empty handle. More...
 
 PIMPLHandle (MotionImpl *p)
 This provides consruction of a handle referencing an existing implementation object. More...
 
 PIMPLHandle (const PIMPLHandle &source)
 The copy constructor makes either a deep (value) or shallow (reference) copy of the supplied source PIMPL object, based on whether this is a "pointer semantics" (PTR=true) or "object (value) semantics" (PTR=false, default) class. More...
 
 ~PIMPLHandle ()
 Note that the destructor is non-virtual. More...
 
PIMPLHandleoperator= (const PIMPLHandle &source)
 Copy assignment makes the current handle either a deep (value) or shallow (reference) copy of the supplied source PIMPL object, based on whether this is a "pointer sematics" (PTR=true) or "object (value) semantics" (PTR=false, default) class. More...
 
void setImpl (MotionImpl *p)
 Set the implementation for this empty handle. More...
 
bool hasSameImplementation (const Motion &other) const
 Determine whether the supplied handle is a reference to the same implementation object as is referenced by "this" PIMPLHandle. More...
 

Additional Inherited Members

- Public Types inherited from SimTK::Motion
enum  Level {
  NoLevel = -1,
  Acceleration = 0,
  Velocity = 1,
  Position = 2
}
 What is the highest level of motion that is driven? Lower levels are also driven; higher levels are determined by integration. More...
 
enum  Method {
  NoMethod = -1,
  Zero = 0,
  Discrete = 1,
  Prescribed = 2,
  Free = 3,
  Fast = 4
}
 There are several ways to specify the motion at this Level, and the selected method also determines lower-level motions. More...
 
- Public Types inherited from SimTK::PIMPLHandle< Motion, MotionImpl, true >
typedef PIMPLHandle< Motion, MotionImpl, PTR > HandleBase
 
typedef HandleBase ParentHandle
 
- Static Public Member Functions inherited from SimTK::Motion
static const char * nameOfLevel (Level)
 Returns a human-readable name corresponding to the given Level; useful for debugging. More...
 
static const char * nameOfMethod (Method)
 Returns a human-readable name corresponding to the given Method; useful for debugging. More...
 

Detailed Description

This class can be used to define new motions.

To use it, create a class that extends Motion::Custom::Implementation. You can then create an instance of it and pass it to the Motion::Custom constructor:

Motion::Custom myMotion(mobod, new MyMotionImplementation());

Alternatively, you can create a subclass of Motion::Custom which creates the Implementation itself:

class MyMotion : public Motion::Custom {
public:
  MyMotion(MobilizedBody& mobod) 
    : Motion::Custom(mobod, new MyMotionImplementation()) {}
};

This allows a user to simply write

MyMotion(mobod);

and not worry about implementation classes or creating objects on the heap. If you do this, your Motion::Custom handle subclass must not have any data members or virtual methods. If it does, it will not work correctly. Instead, store all data in the Implementation subclass.

See also
SimTK::Motion::Custom::Implementation, SimTK::Motion

Constructor & Destructor Documentation

SimTK::Motion::Custom::Custom ( MobilizedBody mobod,
Implementation implementation 
)

Create a Custom Motion.

Parameters
mobodthe MobilizedBody to which this Motion should be added
implementationthe object which implements the custom Motion. The Motion::Custom takes over ownership of the implementation object, and deletes it when the Motion itself is deleted.

Default constructor creates an empty handle that can be assigned to reference any Motion::Custom object.

Member Function Documentation

const Implementation& SimTK::Motion::Custom::getImplementation ( ) const
protected
Implementation& SimTK::Motion::Custom::updImplementation ( )
protected

The documentation for this class was generated from the following file: