API  4.5
For C++ developers
OpenSim::TwoFrameLinker< C, F > Class Template Referenceabstract

TwoFrameLinker is a utility class to extend a Component such that it connects two Frames. More...

+ Inheritance diagram for OpenSim::TwoFrameLinker< C, F >:

OpenSim Properties, Sockets, Outputs, Inputs

Properties (list)

Frames added to satisfy the sockets of this TwoFrameLinker Component

frames
 "Frames created/added to satisfy this component's connections." More...
 
Sockets
frame1
 "The first frame participating in this linker." More...
 
frame2
 "The second frame participating in this linker." More...
 

Public Member Functions

 TwoFrameLinker ()
 By default, the TwoFrameLinker is not connected to any frames. More...
 
 TwoFrameLinker (const std::string &name, const F &frame1, const F &frame2)
 Convenience Constructor. More...
 
 TwoFrameLinker (const std::string &name, const std::string &frame1Name, const std::string &frame2Name)
 Convenience Constructor. More...
 
 TwoFrameLinker (const std::string &name, const F &frame1, const SimTK::Transform &offsetOnFrame1, const F &frame2, const SimTK::Transform &offsetOnFrame2)
 Convenience Constructor with two Frames Construct a TwoFrameLinker where the two frames are specified by name and offset transforms on the respective frames. More...
 
 TwoFrameLinker (const std::string &name, const std::string &frame1Name, const SimTK::Transform &offsetOnFrame1, const std::string &frame2Name, const SimTK::Transform &offsetOnFrame2)
 Convenience Constructor Construct a TwoFrameLinker where the two frames are specified by name and offset transforms on the respective frames. More...
 
 TwoFrameLinker (const std::string &name, const PhysicalFrame &frame1, const SimTK::Vec3 &locationInFrame1, const SimTK::Vec3 &orientationInFrame1, const PhysicalFrame &frame2, const SimTK::Vec3 &locationInFrame2, const SimTK::Vec3 &orientationInFrame2)
 Backwards compatible Convenience Constructor TwoFrameLinker with offsets specified in terms of the location and orientation in respective PhysicalFrames. More...
 
 TwoFrameLinker (const std::string &name, const std::string &frame1Name, const SimTK::Vec3 &locationInFrame1, const SimTK::Vec3 &orientationInFrame1, const std::string &frame2Name, const SimTK::Vec3 &locationInFrame2, const SimTK::Vec3 &orientationInFrame2)
 Backwards compatible Convenience Constructor TwoFrameLinker with offsets specified in terms of the location and orientation in respective PhysicalFrames. More...
 
const F & getFrame1 () const
 Access the first frame the TwoFrameLinker component connects. More...
 
const F & getFrame2 () const
 Access the second frame the TwoFrameLinker component connects. More...
 
SimTK::Transform computeRelativeOffset (const SimTK::State &s) const
 Compute the relative offset Transform between the two frames linked by this TwoFrameLinker component at a given State, expressed in frame1. More...
 
SimTK::SpatialVec computeRelativeVelocity (const SimTK::State &s) const
 Compute the relative spatial velocity between the two frames linked by this TwoFrameLinker component at a given State, expressed in frame1. More...
 
SimTK::Vec6 computeDeflection (const SimTK::State &s) const
 Compute the deflection (spatial separation) of the two frames connected by the TwoFrameLinker. More...
 
SimTK::Vec6 computeDeflectionRate (const SimTK::State &s) const
 Compute the deflection rate (dqdot) of the two frames connected by this TwoFrameLinker component. More...
 
Property-related functions
const F & get_frames (int i) const
 Get the value of the i-th element of the frames property. More...
 
F & upd_frames (int i)
 Get a writable reference to the i-th element of the frames property. More...
 
void set_frames (int i, const F &value)
 Set the value of the i-th element of frames property. More...
 
int append_frames (const F &value)
 Append an element to the frames property. More...
 
Socket-related functions
void connectSocket_frame1 (const OpenSim::Object &object)
 Connect the 'frame1' Socket to an object of type F. More...
 
void connectSocket_frame2 (const OpenSim::Object &object)
 Connect the 'frame2' Socket to an object of type F. More...
 

Public Types

typedef TwoFrameLinker Self
 This typedef might be useful within the member functions of this class. More...
 
typedef C Super
 Use this typedef to refer to the superclass of this class. More...
 

Protected Member Functions

void convertInternalForceToForcesOnFrames (const SimTK::State &state, SimTK::Vec6 f, SimTK::SpatialVec &F1_G, SimTK::SpatialVec &F2_G) const
 Helper method to convert internal force expressed in the mobility basis between frame1 and frame2, dq, as individual spatial forces acting on each frame linked by this component. More...
 
void addInPhysicalForcesFromInternal (const SimTK::State &state, SimTK::Vec6 f, SimTK::Vector_< SimTK::SpatialVec > &spatialForces) const
 Helper method to add in the equivalent system spatial forces given internal forces. More...
 
Component Interface

These methods adhere to the Component Interface

void extendConnectToModel (Model &model) override
 
void updateFromXMLNode (SimTK::Xml::Element &aNode, int versionNumber) override
 

Auto-generated functions

static TwoFrameLinkersafeDownCast (OpenSim::Object *obj)
 For use in MATLAB and Python to access the concrete class. More...
 
static const std::string & getClassName ()
 This returns "TwoFrameLinker_<T>_". More...
 
void assign (Object &aObject) override
 This allows copy assignment in the Java GUI. More...
 
TwoFrameLinkerclone () const override=0
 
const std::string & getConcreteClassName () const override=0
 

Detailed Description

template<class C = Component, class F = Frame>
class OpenSim::TwoFrameLinker< C, F >

TwoFrameLinker is a utility class to extend a Component such that it connects two Frames.

For example, a WeldConstraint and BushingForces operate between two frames to restrict their motion. A TwoFrameLinker<Force, PhysicalFrame>, for example, is a Force that operates between two PhyscialFrames and it is the base class for BushingForces. (A class whose super class is a template parameter is called a mixin class.)

class BushingForce : public TwoFrameLinker<Force, PhysicalFrame>
Template Parameters
CThe base class.
FThe type of frame that the class links together.
Author
Ajay Seth

Member Typedef Documentation

◆ Self

template<class C = Component, class F = Frame>
typedef TwoFrameLinker OpenSim::TwoFrameLinker< C, F >::Self

This typedef might be useful within the member functions of this class.

This is generated by the OpenSim_DECLARE_*_OBJECT macros.

◆ Super

template<class C = Component, class F = Frame>
typedef C OpenSim::TwoFrameLinker< C, F >::Super

Use this typedef to refer to the superclass of this class.

Avoid using the explicit type name of the superclass; this would introduce bugs if the superclass is changed.

This is generated by the OpenSim_DECLARE_*_OBJECT macros.

Constructor & Destructor Documentation

◆ TwoFrameLinker() [1/7]

template<class C , class F >
OpenSim::TwoFrameLinker< C, F >::TwoFrameLinker ( )

By default, the TwoFrameLinker is not connected to any frames.

◆ TwoFrameLinker() [2/7]

template<class C , class F>
OpenSim::TwoFrameLinker< C, F >::TwoFrameLinker ( const std::string &  name,
const F &  frame1,
const F &  frame2 
)

Convenience Constructor.

Create a TwoFrameLinker Component between two Frames.

Parameters
[in]namethe name of this TwoFrameLinker component
[in]frame1the name of the first Frame being linked
[in]frame2the name of the second Frame being linked

◆ TwoFrameLinker() [3/7]

template<class C , class F>
OpenSim::TwoFrameLinker< C, F >::TwoFrameLinker ( const std::string &  name,
const std::string &  frame1Name,
const std::string &  frame2Name 
)

Convenience Constructor.

Create a TwoFrameLinker Component between two Frames identified by name.

Parameters
[in]namethe name of this TwoFrameLinker component
[in]frame1Namethe name of the first Frame being linked
[in]frame2Namethe name of the second Frame being linked

◆ TwoFrameLinker() [4/7]

template<class C , class F>
OpenSim::TwoFrameLinker< C, F >::TwoFrameLinker ( const std::string &  name,
const F &  frame1,
const SimTK::Transform &  offsetOnFrame1,
const F &  frame2,
const SimTK::Transform &  offsetOnFrame2 
)

Convenience Constructor with two Frames Construct a TwoFrameLinker where the two frames are specified by name and offset transforms on the respective frames.

Parameters
[in]namethe name of this TwoFrameLinker component
[in]frame1the first Frame being linked
[in]offsetOnFrame1offset Transform on the first frame
[in]frame2the second Frame being linked
[in]offsetOnFrame2offset Transform on the second frame

◆ TwoFrameLinker() [5/7]

template<class C , class F>
OpenSim::TwoFrameLinker< C, F >::TwoFrameLinker ( const std::string &  name,
const std::string &  frame1Name,
const SimTK::Transform &  offsetOnFrame1,
const std::string &  frame2Name,
const SimTK::Transform &  offsetOnFrame2 
)

Convenience Constructor Construct a TwoFrameLinker where the two frames are specified by name and offset transforms on the respective frames.

Parameters
[in]namethe name of this TwoFrameLinker component
[in]frame1Namethe name of the first Frame being linked
[in]offsetOnFrame1offset Transform on the first frame
[in]frame2Namethe name of the second Frame being linked
[in]offsetOnFrame2offset Transform on the second frame

◆ TwoFrameLinker() [6/7]

template<class C , class F>
OpenSim::TwoFrameLinker< C, F >::TwoFrameLinker ( const std::string &  name,
const PhysicalFrame frame1,
const SimTK::Vec3 &  locationInFrame1,
const SimTK::Vec3 &  orientationInFrame1,
const PhysicalFrame frame2,
const SimTK::Vec3 &  locationInFrame2,
const SimTK::Vec3 &  orientationInFrame2 
)

Backwards compatible Convenience Constructor TwoFrameLinker with offsets specified in terms of the location and orientation in respective PhysicalFrames.

Parameters
[in]namethe name of this TwoFrameLinker component
[in]frame1the first Frame being linked
[in]locationInFrame1Vec3 of offset location on the first frame
[in]orientationInFrame1Vec3 of orientation offset expressed as XYZ body-fixed Euler angles w.r.t frame1.
[in]frame2the second Frame being linked
[in]locationInFrame2Vec3 of offset location on the second frame
[in]orientationInFrame2Vec3 of orientation offset expressed as XYZ body-fixed Euler angles w.r.t frame2.

◆ TwoFrameLinker() [7/7]

template<class C , class F>
OpenSim::TwoFrameLinker< C, F >::TwoFrameLinker ( const std::string &  name,
const std::string &  frame1Name,
const SimTK::Vec3 &  locationInFrame1,
const SimTK::Vec3 &  orientationInFrame1,
const std::string &  frame2Name,
const SimTK::Vec3 &  locationInFrame2,
const SimTK::Vec3 &  orientationInFrame2 
)

Backwards compatible Convenience Constructor TwoFrameLinker with offsets specified in terms of the location and orientation in respective PhysicalFrames.

Parameters
[in]namethe name of this TwoFrameLinker component
[in]frame1Namethe name of the first Frame being linked
[in]locationInFrame1Vec3 of offset location on the first frame
[in]orientationInFrame1Vec3 of orientation offset expressed as XYZ body-fixed Euler angles w.r.t frame1.
[in]frame2Namethe name of the second Frame being linked
[in]locationInFrame2Vec3 of offset location on the second frame
[in]orientationInFrame2Vec3 of orientation offset expressed as XYZ body-fixed Euler angles w.r.t frame2.

Member Function Documentation

◆ addInPhysicalForcesFromInternal()

template<class C , class F >
void OpenSim::TwoFrameLinker< C, F >::addInPhysicalForcesFromInternal ( const SimTK::State &  state,
SimTK::Vec6  f,
SimTK::Vector_< SimTK::SpatialVec > &  spatialForces 
) const
protected

Helper method to add in the equivalent system spatial forces given internal forces.

Internal forces are expressed in the mobility basis as parameterized by the deflection between frame1 and frame2, dq, and its time derivative, dqdot. The intended usage is within a Force::computeForce() which is tasked with populating vectors of generalized forces and/or (mobilized body) spatial forces. This method will populate (add in) the spatialForces given the internal force.

Parameters
stateconst State of current system configuration
[in]fVec6 of forces in the basis of the deflection
[in,out]spatialForcesVector of SpatialVec's (torque, force) on each PhysicalFrame's base frame in the System. This is equivalent to each MobilizedBody.
See also
convertInternalForceToForcesOnFrames()
PhysicalFrame::findBaseFrame()

◆ append_frames()

template<class C = Component, class F = Frame>
int OpenSim::TwoFrameLinker< C, F >::append_frames ( const F &  value)
inline

Append an element to the frames property.

◆ assign()

template<class C = Component, class F = Frame>
void OpenSim::TwoFrameLinker< C, F >::assign ( Object aObject)
inlineoverride

This allows copy assignment in the Java GUI.

Exceptions
Exceptionif the argument is not of type TwoFrameLinker.

◆ clone()

template<class C = Component, class F = Frame>
TwoFrameLinker* OpenSim::TwoFrameLinker< C, F >::clone ( ) const
overridepure virtual

◆ computeDeflection()

template<class C , class F >
SimTK::Vec6 OpenSim::TwoFrameLinker< C, F >::computeDeflection ( const SimTK::State &  s) const

Compute the deflection (spatial separation) of the two frames connected by the TwoFrameLinker.

Angular deflections expressed as XYZ body-fixed Euler angles of frame2 w.r.t frame1. NOTE: When using deflections to compute spatial forces, these forces may not be valid for large deflections, because Euler angles are unable to uniquely distinguish an X rotation angle of +/-180 degs, and subsequent rotations that are +/-90 degs. It is mainly useful for calculating errors for constraints and forces for computing restoration forces.

Returns
dq Vec6 of (3) angular and (3) translational deflections.

◆ computeDeflectionRate()

template<class C , class F >
SimTK::Vec6 OpenSim::TwoFrameLinker< C, F >::computeDeflectionRate ( const SimTK::State &  s) const

Compute the deflection rate (dqdot) of the two frames connected by this TwoFrameLinker component.

Angular velocity is expressed as Euler (XYZ body-fixed) angle derivatives. Note that the derivatives become singular as the second Euler angle approaches 90 degs.

Returns
dqdot Vec6 of (3) angular and (3) translational deflection rates.

◆ computeRelativeOffset()

template<class C , class F >
SimTK::Transform OpenSim::TwoFrameLinker< C, F >::computeRelativeOffset ( const SimTK::State &  s) const

Compute the relative offset Transform between the two frames linked by this TwoFrameLinker component at a given State, expressed in frame1.

◆ computeRelativeVelocity()

template<class C , class F >
SimTK::SpatialVec OpenSim::TwoFrameLinker< C, F >::computeRelativeVelocity ( const SimTK::State &  s) const

Compute the relative spatial velocity between the two frames linked by this TwoFrameLinker component at a given State, expressed in frame1.

◆ connectSocket_frame1()

template<class C = Component, class F = Frame>
void OpenSim::TwoFrameLinker< C, F >::connectSocket_frame1 ( const OpenSim::Object object)
inline

Connect the 'frame1' Socket to an object of type F.

Call finalizeConnections() afterwards to update the socket's connectee path property. The reference to the connectee set here takes precedence over the connectee path property.

◆ connectSocket_frame2()

template<class C = Component, class F = Frame>
void OpenSim::TwoFrameLinker< C, F >::connectSocket_frame2 ( const OpenSim::Object object)
inline

Connect the 'frame2' Socket to an object of type F.

Call finalizeConnections() afterwards to update the socket's connectee path property. The reference to the connectee set here takes precedence over the connectee path property.

◆ convertInternalForceToForcesOnFrames()

template<class C , class F >
void OpenSim::TwoFrameLinker< C, F >::convertInternalForceToForcesOnFrames ( const SimTK::State &  state,
SimTK::Vec6  f,
SimTK::SpatialVec F1_G,
SimTK::SpatialVec F2_G 
) const
protected

Helper method to convert internal force expressed in the mobility basis between frame1 and frame2, dq, as individual spatial forces acting on each frame linked by this component.

The internal force, f, is directed onto frame2 from frame1. In computeDeflection(), frame2's pose in frame1 is decomposed in to 6 internal coordinates dq (similar to the q's of a free joint). Their derivatives, dqdot, form a internal coordinates "mobility" basis that can be used to express frame2's spatial velocity in frame1 or to apply internal (generalized) forces that apply equal and opposite spatial forces to the two frames.

Parameters
stateconst State of current system configuration
[in]fVec6 of forces in the basis of the deflection
[in,out]F1_GSpatialVec Force (torque, force) applied to frame1 expressed in ground.
[in,out]F2_GSpatialVec Force (torque, force) applied to frame2 expressed in ground.

◆ extendConnectToModel()

template<class C , class F >
void OpenSim::TwoFrameLinker< C, F >::extendConnectToModel ( Model model)
overrideprotected

◆ get_frames()

template<class C = Component, class F = Frame>
const F& OpenSim::TwoFrameLinker< C, F >::get_frames ( int  i) const
inline

Get the value of the i-th element of the frames property.

◆ getClassName()

template<class C = Component, class F = Frame>
static const std::string& OpenSim::TwoFrameLinker< C, F >::getClassName ( )
inlinestatic

This returns "TwoFrameLinker_<T>_".

T is the template argument for this class. See getConcreteClassName() if you want the class name of the underlying concrete object instead.

This is generated by the OpenSim_DECLARE_*_OBJECT macros.

◆ getConcreteClassName()

template<class C = Component, class F = Frame>
const std::string& OpenSim::TwoFrameLinker< C, F >::getConcreteClassName ( ) const
overridepure virtual

◆ getFrame1()

template<class C , class F >
const F & OpenSim::TwoFrameLinker< C, F >::getFrame1 ( ) const

Access the first frame the TwoFrameLinker component connects.

Note, if an offset was introduced at construction, then this will be the offset frame.

◆ getFrame2()

template<class C , class F >
const F & OpenSim::TwoFrameLinker< C, F >::getFrame2 ( ) const

Access the second frame the TwoFrameLinker component connects.

Note, if an offset was introduced at construction, then this will be the offset frame.

◆ safeDownCast()

template<class C = Component, class F = Frame>
static TwoFrameLinker* OpenSim::TwoFrameLinker< C, F >::safeDownCast ( OpenSim::Object obj)
inlinestatic

For use in MATLAB and Python to access the concrete class.

Example: cObj = TwoFrameLinker.safeDownCast(obj). This is equivalent to dynamic_cast<TwoFrameLinker*>(obj) in C++.

◆ set_frames()

template<class C = Component, class F = Frame>
void OpenSim::TwoFrameLinker< C, F >::set_frames ( int  i,
const F &  value 
)
inline

Set the value of the i-th element of frames property.

◆ upd_frames()

template<class C = Component, class F = Frame>
F& OpenSim::TwoFrameLinker< C, F >::upd_frames ( int  i)
inline

Get a writable reference to the i-th element of the frames property.

◆ updateFromXMLNode()

template<class C , class F >
void OpenSim::TwoFrameLinker< C, F >::updateFromXMLNode ( SimTK::Xml::Element &  aNode,
int  versionNumber 
)
overrideprotected

OpenSim Property, Socket, Output, Input Documentation

◆ frame1

template<class C = Component, class F = Frame>
F OpenSim::TwoFrameLinker< C, F >::frame1

"The first frame participating in this linker."

In an XML file, you can set this Socket's connectee path via the <socket_frame1 > element. This socket was generated with the OpenSim_DECLARE_SOCKET macro; see AbstractSocket for more information.

See also
connectSocket_frame1()

◆ frame2

template<class C = Component, class F = Frame>
F OpenSim::TwoFrameLinker< C, F >::frame2

"The second frame participating in this linker."

In an XML file, you can set this Socket's connectee path via the <socket_frame2 > element. This socket was generated with the OpenSim_DECLARE_SOCKET macro; see AbstractSocket for more information.

See also
connectSocket_frame2()

◆ frames

template<class C = Component, class F = Frame>
F OpenSim::TwoFrameLinker< C, F >::frames

"Frames created/added to satisfy this component's connections."

This property appears in XML files under the tag <frames>. This property holds a list of objects, and was generated with the OpenSim_DECLARE_LIST_PROPERTY macro; see Property to learn about the property system.

See also
get_frames(), upd_frames(), set_frames(), append_frames()

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