Simbody
3.4 (development)
|
The handle class MobilizedBody::Custom (dataless) and its companion class MobilizedBody::Custom::Implementation can be used together to define new MobilizedBody types with arbitrary properties. More...
#include <MobilizedBody_Custom.h>
Classes | |
class | Implementation |
This is the implementation class for Custom mobilizers. More... | |
Public Member Functions | |
Custom () | |
Default constructor provides an empty handle that can be assigned to reference any MobilizedBody::Custom. | |
Custom (MobilizedBody &parent, Implementation *implementation, const Transform &X_PF, const Body &bodyInfo, const Transform &X_BM, Direction direction=Forward) | |
Create a Custom mobilizer between an existing parent (inboard) body P and a new child (outboard) body B created by copying the given bodyInfo into a privately-owned Body within the constructed MobilizedBody object. | |
Custom (MobilizedBody &parent, Implementation *implementation, const Body &bodyInfo, Direction direction=Forward) | |
Abbreviated constructor you can use if the mobilizer frames are coincident with the parent and child body frames. | |
Protected Member Functions | |
const Implementation & | getImplementation () const |
Implementation & | updImplementation () |
The handle class MobilizedBody::Custom (dataless) and its companion class MobilizedBody::Custom::Implementation can be used together to define new MobilizedBody types with arbitrary properties.
To use it, create a class that extends MobilizedBody::Custom::Implementation. You can then create an instance of it and pass it to the MobilizedBody::Custom constructor:
MobilizedBody::Custom myMobilizedBody(new MyMobilizedBodyImplementation(args));
("args" here and below stands for whatever arguments are needed for your particular mobilizer; it isn't meant literally.)
Alternatively, you can also create a new Handle class which is a subclass of MobilizedBody::Custom and which creates the Implementation itself in its constructors.
class MyMobilizedBody : public MobilizedBody::Custom { public: MyMobilizedBody(args) : MobilizedBody::Custom(new MyMobilizedBodyImplementation(args)) {} };
This allows an end user to simply write
MyMobilizedBody(args);
and not worry about implementation classes or creating objects on the heap. If you do this, your MobilizedBody::Custom 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.
SimTK::MobilizedBody::Custom::Custom | ( | ) | [inline] |
Default constructor provides an empty handle that can be assigned to reference any MobilizedBody::Custom.
SimTK::MobilizedBody::Custom::Custom | ( | MobilizedBody & | parent, |
Implementation * | implementation, | ||
const Transform & | X_PF, | ||
const Body & | bodyInfo, | ||
const Transform & | X_BM, | ||
Direction | direction = Forward |
||
) |
Create a Custom mobilizer between an existing parent (inboard) body P and a new child (outboard) body B created by copying the given bodyInfo into a privately-owned Body within the constructed MobilizedBody object.
Specify the mobilizer frames F fixed to parent P and M fixed to child B.
parent | the MobilizedBody's parent (inboard) body |
implementation | the object which implements the custom mobilized body. The MobilizedBody::Custom takes over ownership of the implementation object, and deletes it when the MobilizedBody itself is deleted. |
X_PF | the MobilizedBody's F (inboard) frame |
bodyInfo | describes this MobilizedBody's physical properties |
X_BM | the MobilizedBody's M (outboard) frame |
direction | whether you want the coordinates defined as though parent & child were swapped |
SimTK::MobilizedBody::Custom::Custom | ( | MobilizedBody & | parent, |
Implementation * | implementation, | ||
const Body & | bodyInfo, | ||
Direction | direction = Forward |
||
) |
Abbreviated constructor you can use if the mobilizer frames are coincident with the parent and child body frames.
const Implementation& SimTK::MobilizedBody::Custom::getImplementation | ( | ) | const [protected] |
Implementation& SimTK::MobilizedBody::Custom::updImplementation | ( | ) | [protected] |