ModelSpace
Documentation for ModelSpace models and classes.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
modelspace::Frame Class Reference

Frame class definition. More...

#include <Frame.h>

Inheritance diagram for modelspace::Frame:

Public Member Functions

 Frame (const std::string &name, Frame *par=nullptr, bool free=false)
 Constructor for the frame object. More...
 
virtual ~Frame ()
 
std::vector< Frame * > frameChildren ()
 Return all children of the frame as a vector of frames. More...
 
FramegetFrameByAddress (const std::string &address)
 Function to get an object from the graph tree by string address. More...
 
JointtJoint ()
 Function to get reference to the frame's translational joint. More...
 
JointrJoint ()
 Function to get reference to the frame's rotational joint. More...
 
int parent (Frame *new_parent)
 Function to assign the frame's parent via pointer. More...
 
int parent (Frame &new_parent)
 
Frameparent ()
 
void setParentRelAcceleration (clockwerk::CartesianVector< 3 > accel)
 Function to set parent relative acceleration of frame. More...
 
void setParentRelAngularAcceleration (clockwerk::CartesianVector< 3 > alpha)
 Function to set parent relative angular acceleration. More...
 
clockwerk::CartesianVector< 3 > parentRelAcceleration ()
 Function to get the acceleration of the frame relative to parent expressed in parent coords. More...
 
clockwerk::CartesianVector< 3 > parentRelAngularAcceleration ()
 Function to get angular acceleration relative to parent in frame coords. More...
 
void rootRelPosition (clockwerk::CartesianVector< 3 > &pos_o_root__root)
 Returns the position of the frame origin wrt the root origin, in root coordinates. More...
 
clockwerk::CartesianVector< 3 > rootRelPosition ()
 
void rootRelVelocity (clockwerk::CartesianVector< 3 > &vel_o_root__root)
 Returns the velocity of the frame origin wrt the root origin, in root coordinates. More...
 
clockwerk::CartesianVector< 3 > rootRelVelocity ()
 
void rootRelAcceleration (clockwerk::CartesianVector< 3 > &acc_o_root__root)
 Returns the acceleration of the frame origin wrt the root origin, in root coordinates. More...
 
clockwerk::CartesianVector< 3 > rootRelAcceleration ()
 
void rootRelQuaternion (clockwerk::Quaternion &quat_f_root)
 Returns the quaternion representing the frame origin wrt the root frame. More...
 
clockwerk::Quaternion rootRelQuaternion ()
 
void rootRelDCM (clockwerk::DCM &dcm_f_root)
 Returns the clockwerk::DCM of the frame origin wrt the root frame. More...
 
clockwerk::DCM rootRelDCM ()
 
void rootRelAngularVelocity (clockwerk::CartesianVector< 3 > &w_f_root__f)
 Returns the angular velocity of the frame origin wrt the root, expressed in this frame's coordinates. More...
 
clockwerk::CartesianVector< 3 > rootRelAngularVelocity ()
 
void rootRelAngularAcceleration (clockwerk::CartesianVector< 3 > &alpha_f_root__f)
 Returns the angular acceleration of the frame origin wrt the root, expressed in this frame's coordinates. More...
 
clockwerk::CartesianVector< 3 > rootRelAngularAcceleration ()
 
int calcFrameTreeExtForcesMoments ()
 Function to recurse through the body and its children to apply external forces and moments to the "correct" body by resolving them to locations where there are degrees of freedom. More...
 
int calcFrameTreeExtAcceleration ()
 Function to recurse through the body and its children to resolve applied external forces and moments into acceleration and angular acceleration. More...
 
void integrator (void *integ_ptr)
 Getter and setter for integrator pointer. More...
 
void * integrator ()
 
void setStateFromStateVector (const std::array< floating_point, 13 > &state_f_p__f)
 Function to set frame state based on NUM_INTEGRATED_STATES-element state vector. More...
 
void getStateAsStateVector (std::array< floating_point, 13 > &state_f_p__f)
 Function to return frame state as a NUM_INTEGRATED_STATES-element state vector. More...
 
void getStateVectorDot (std::array< floating_point, 13 > &state_dot)
 Function to get the rate of change in the frame state vector. More...
 
int setRootRelPosition (const clockwerk::CartesianVector< 3 > &pos_f_root__root)
 Function to set the frame's position relative to root. More...
 
int setRootRelVelocity (const clockwerk::CartesianVector< 3 > &vel_f_root__root)
 Function to set the frame's velocity relative to root. More...
 
int setRootRelAttitude (const clockwerk::Quaternion &quat_f_root)
 Function to set the frame's attitude relative to root. More...
 
int setRootRelAngularVelocity (const clockwerk::CartesianVector< 3 > &w_f_root__f)
 Function to set the frame's position relative to root. More...
 
FramegetFrameRootPointer ()
 Function to get a pointer to this frame's root frame. More...
 
void dump ()
 Dump all information associated with the frame. More...
 
- Public Member Functions inherited from clockwerk::GraphTreeObject
 GraphTreeObject (const char *gt_nme="", GraphTreeObject **storage_array=nullptr, uint32 storage_size=0)
 Name-based constructor for GraphTreeObject which will have no children by default. More...
 
virtual ~GraphTreeObject ()
 Destructor. More...
 
GraphTreeObjectparent ()
 Functions to get object's parent/children. More...
 
GraphTreeObject ** children ()
 
GraphTreeObjectchildAtIndex (uint8 i) const
 
int16 parent (GraphTreeObject *new_parent)
 Function to assign the node's parent via pointer. More...
 
int16 parent (GraphTreeObject &new_parent)
 Function to assign the node's parent via reference. More...
 
uint8 nChildren () const
 Getters for number of children and descendants. More...
 
uint16 nDescendants () const
 
uint8 capacity () const
 
const char * name () const
 Getter and setter for object name. More...
 
int16 name (const char *new_name)
 
uint8 rank ()
 Getter for the object rank. More...
 
int8 type ()
 Function to indicate type – -1 by default unless implemented downstream. More...
 
bool loggable ()
 Getter for object logability flag – note no setter because should only be set by this or a derived class in its definition. More...
 
GraphTreeObjectgetRootDataPointer ()
 Get the pointer to the highest object in the graph tree. More...
 
virtual int16 str (char *output, size_t size) const
 Get object represented as string. More...
 
virtual int16 fromStr (const char *val)
 Set value of graphtreeobject from string. More...
 

Public Attributes

clockwerk::DataIO< clockwerk::CartesianVector< 3 > > pos_f_p__p
 
clockwerk::DataIO< clockwerk::CartesianVector< 3 > > vel_f_p__p
 
clockwerk::DataIO< clockwerk::Quaternionquat_f_p
 
clockwerk::DataIO< clockwerk::CartesianVector< 3 > > ang_vel_f_p__f
 
clockwerk::DataIO< Frame * > self_id = clockwerk::DataIO<Frame*>(nullptr, "self_id", this)
 

Protected Attributes

clockwerk::CartesianVector< 3 > _acc_f_p__p
 
clockwerk::CartesianVector< 3 > _alpha_f_p__f
 
Joint _t_joint
 
Joint _r_joint
 Translational. More...
 
void * _integrator_ptr = nullptr
 Rotational. More...
 
Frame_parent
 Variable to hold our parent. More...
 
- Protected Attributes inherited from clockwerk::GraphTreeObject
GraphTreeObject_parent = nullptr
 
GraphTreeObject ** _children_ptr = nullptr
 
uint32 _max_num_children = 0
 
uint16 _num_descendants = 0
 
char _name [MAXIMUM_NAME_CHARS] = ""
 String name for object. More...
 
uint8 _num_children = 0
 Number of direct children of the tree (not including the tree itself) More...
 
uint8 _rank = 0
 
int8 _graph_tree_type = BASE_GRAPH_TREE
 Variable to store graph tree object type. More...
 
bool _loggable = false
 Variable to indicate whether the selected object is loggable. Set to false by default. More...
 
uint32 _index = 0
 Index pointing to the next write location for the graph tree children. More...
 

Additional Inherited Members

- Protected Member Functions inherited from clockwerk::GraphTreeObject
int16 _setStorage (GraphTreeObject **storage_array, uint8 storage_size)
 Getter for object's string address. More...
 
void _recalculateDescendants ()
 Function to recursively re-calculate the number of descendants of a given node on the tree. More...
 
void _recalculateRank ()
 Function to recursively re-calculate the rank of a given node on the tree. More...
 
int16 _addChild (GraphTreeObject *child)
 Function to decompose a string into a series of substrings via indexing. More...
 
int16 _removeChild (GraphTreeObject *child)
 Function to remove a child from the graph node's children. More...
 

Detailed Description

Frame class definition.

This file defines the frame class, which is the base of all 6-DOF kinematics and dynamics. This frame class is designed for recursive chaining, and represents the relationship of a frame to its parent.

The frame class tracks the frame's relationship to its parent via the following four key parameters: pos_f_p__p - The position of the child frame relative to its parent, in PARENT coords vel_f_p__p - The velocity of the child frame IN THE PARENT Frame , in PARENT coords. quat_f_p - The attitude quaternion of the child frame relative to its parent ang_vel_f_p__f - The angular velocity of the child frame relative to its parent, in Frame coords

Frame relationships to their parents are also defined by the Joint class, which is a method for tracking the degrees of freedom (and thus, which channels can have a nonzero velocity value). Each frame has a translational and rotational joint, which sets degrees of freedom in the velocity (represented in parent coordinates) and angular velocity (represented in frame coordinates). The frame joint is set to fully fixed by default, but can be set to free or modified later.

Frame states may be set by calling the parent relative states directly (they are DataIO objects, but buyer beware that you can set the frame states with almost no restrictions.)

Alternatively, users may get and set frame states relative to the root frame by calling the root relative functions which are provided by this class. The functions rootRelPosition, rootRelVelocity, rootRel... and so on all return the frame state relative to root. The functions setRootRel... will set the frame's state relative to the root frame. For many applications it is better to work with the root functions, rather than parent relative functions.

Naming conventions

  • The naming convention for all vectors is: variablename_obj1_obj2__frameN (note the double underscore preceding frame) and reads back as: "variable variablename representing the relationship between obj1 and obj2 represented in frameN"
  • The naming convention for attitude representations is the same as the above, with the trailing frame representation omitted.
  • The omega vector is sometimes denoted by w and assumed frame consistent with the attitude representation. For example, if a clockwerk::DCM represents the relative orientation between two frames [BN] the omega vector is assumed to be w_(B/N)
  • The frame represented by this class is denoted with "f" for simplicity
  • Unless otherwise noted angles and angular rates are in RADIANS
  • Where relevant and unless otherwise noted, all units are metric

Constructor & Destructor Documentation

◆ Frame()

modelspace::Frame::Frame ( const std::string &  name,
Frame par = nullptr,
bool  free = false 
)

Constructor for the frame object.

Parameters
nameName of the frame
parParent of the frame. Defaults to nullptr
freeBoolean indicating whether frame should be free or fixed.

◆ ~Frame()

virtual modelspace::Frame::~Frame ( )
inlinevirtual

Member Function Documentation

◆ calcFrameTreeExtAcceleration()

int modelspace::Frame::calcFrameTreeExtAcceleration ( )

Function to recurse through the body and its children to resolve applied external forces and moments into acceleration and angular acceleration.

Note
Implicitly applies acceleration/ang accel to the body frame
Assumes calcBodyTreeForcesMoments has been called to calculate forces/moments

◆ calcFrameTreeExtForcesMoments()

int modelspace::Frame::calcFrameTreeExtForcesMoments ( )

Function to recurse through the body and its children to apply external forces and moments to the "correct" body by resolving them to locations where there are degrees of freedom.

◆ dump()

void modelspace::Frame::dump ( )

Dump all information associated with the frame.

◆ frameChildren()

std::vector< Frame * > modelspace::Frame::frameChildren ( )

Return all children of the frame as a vector of frames.

Returns
All children of the frame in a single vector

◆ getFrameByAddress()

Frame * modelspace::Frame::getFrameByAddress ( const std::string &  address)

Function to get an object from the graph tree by string address.

Parameters
addressThe exact string address to access the variable with
Returns
Pointer to the frame at the address, or nullptr if address is not valid or returns

◆ getFrameRootPointer()

Frame * modelspace::Frame::getFrameRootPointer ( )

Function to get a pointer to this frame's root frame.

Returns
Pointer to root frame. Pointer to self if this frame is root

◆ getStateAsStateVector()

void modelspace::Frame::getStateAsStateVector ( std::array< floating_point, 13 > &  state_f_p__f)

Function to return frame state as a NUM_INTEGRATED_STATES-element state vector.

Parameters
stateReturn of NUM_INTEGRATED_STATES-element state vector as [pos][vel][quat][omega]

◆ getStateVectorDot()

void modelspace::Frame::getStateVectorDot ( std::array< floating_point, 13 > &  state_dot)

Function to get the rate of change in the frame state vector.

Parameters
state_dotRate of change in each element of the state vector

◆ integrator() [1/2]

void* modelspace::Frame::integrator ( )
inline

◆ integrator() [2/2]

void modelspace::Frame::integrator ( void *  integ_ptr)
inline

Getter and setter for integrator pointer.

◆ parent() [1/3]

Frame* modelspace::Frame::parent ( )
inline

◆ parent() [2/3]

int modelspace::Frame::parent ( Frame new_parent)
inline

◆ parent() [3/3]

int modelspace::Frame::parent ( Frame new_parent)

Function to assign the frame's parent via pointer.

Parameters
new_parentThe new parent to assign the node to
Returns
Error code corresponding to success/failure
Note
This function is the only method to ADD or REMOVE a node from a tree. To add, pass the address to a GraphTreeObject to this function. To remove, pass a nullptr. Note that parents for objects on an existing tree can be reassigned

◆ parentRelAcceleration()

clockwerk::CartesianVector<3> modelspace::Frame::parentRelAcceleration ( )
inline

Function to get the acceleration of the frame relative to parent expressed in parent coords.

Returns
Accel relative to parent in parent coords

◆ parentRelAngularAcceleration()

clockwerk::CartesianVector<3> modelspace::Frame::parentRelAngularAcceleration ( )
inline

Function to get angular acceleration relative to parent in frame coords.

Returns
Angular accel relative to parent in frame coords

◆ rJoint()

Joint& modelspace::Frame::rJoint ( )
inline

Function to get reference to the frame's rotational joint.

Returns
The frame's rotational joint

◆ rootRelAcceleration() [1/2]

clockwerk::CartesianVector< 3 > modelspace::Frame::rootRelAcceleration ( )

◆ rootRelAcceleration() [2/2]

void modelspace::Frame::rootRelAcceleration ( clockwerk::CartesianVector< 3 > &  acc_o_root__root)

Returns the acceleration of the frame origin wrt the root origin, in root coordinates.

Parameters
acc_o_root__rootImplicit return of acceleration of origin relative to root, in root
Returns
Error code corresponding to success/failure
Note
Overloaded for explicit and implicit return

◆ rootRelAngularAcceleration() [1/2]

clockwerk::CartesianVector< 3 > modelspace::Frame::rootRelAngularAcceleration ( )

◆ rootRelAngularAcceleration() [2/2]

void modelspace::Frame::rootRelAngularAcceleration ( clockwerk::CartesianVector< 3 > &  alpha_f_root__f)

Returns the angular acceleration of the frame origin wrt the root, expressed in this frame's coordinates.

Parameters
alpha_f_root__fImplicit return of angular acceleration relative to root, expressed in f frame
Returns
Error code corresponding to success/failure
Note
Overloaded for explicit and implicit return

◆ rootRelAngularVelocity() [1/2]

clockwerk::CartesianVector< 3 > modelspace::Frame::rootRelAngularVelocity ( )

◆ rootRelAngularVelocity() [2/2]

void modelspace::Frame::rootRelAngularVelocity ( clockwerk::CartesianVector< 3 > &  w_f_root__f)

Returns the angular velocity of the frame origin wrt the root, expressed in this frame's coordinates.

Parameters
w_f_root__fImplicit return of angular velocity relative to root, expressed in f frame
Returns
Error code corresponding to success/failure
Note
Overloaded for explicit and implicit return

◆ rootRelDCM() [1/2]

clockwerk::DCM modelspace::Frame::rootRelDCM ( )

◆ rootRelDCM() [2/2]

void modelspace::Frame::rootRelDCM ( clockwerk::DCM dcm_f_root)

Returns the clockwerk::DCM of the frame origin wrt the root frame.

Parameters
dcm_f_rootImplicit return of attitude relative to root
Returns
Error code corresponding to success/failure
Note
Overloaded for explicit and implicit return

◆ rootRelPosition() [1/2]

clockwerk::CartesianVector< 3 > modelspace::Frame::rootRelPosition ( )

◆ rootRelPosition() [2/2]

void modelspace::Frame::rootRelPosition ( clockwerk::CartesianVector< 3 > &  pos_o_root__root)

Returns the position of the frame origin wrt the root origin, in root coordinates.

Parameters
pos_o_root__rootImplicit return of position of origin relative to root, in root
Returns
Error code corresponding to success/failure
Note
Overloaded for explicit and implicit return

◆ rootRelQuaternion() [1/2]

clockwerk::Quaternion modelspace::Frame::rootRelQuaternion ( )

◆ rootRelQuaternion() [2/2]

void modelspace::Frame::rootRelQuaternion ( clockwerk::Quaternion quat_f_root)

Returns the quaternion representing the frame origin wrt the root frame.

Parameters
quat_f_rootImplicit return of attitude relative to root
Returns
Error code corresponding to success/failure
Note
Overloaded for explicit and implicit return

◆ rootRelVelocity() [1/2]

clockwerk::CartesianVector< 3 > modelspace::Frame::rootRelVelocity ( )

◆ rootRelVelocity() [2/2]

void modelspace::Frame::rootRelVelocity ( clockwerk::CartesianVector< 3 > &  vel_o_root__root)

Returns the velocity of the frame origin wrt the root origin, in root coordinates.

Parameters
vel_o_root__rootImplicit return of velocity of origin relative to root in root
Returns
Error code corresponding to success/failure
Note
Overloaded for explicit and implicit return

◆ setParentRelAcceleration()

void modelspace::Frame::setParentRelAcceleration ( clockwerk::CartesianVector< 3 >  accel)
inline

Function to set parent relative acceleration of frame.

Parameters
accelacceleration of frame relative to parent in parent frame coords

◆ setParentRelAngularAcceleration()

void modelspace::Frame::setParentRelAngularAcceleration ( clockwerk::CartesianVector< 3 >  alpha)
inline

Function to set parent relative angular acceleration.

Parameters
alphaangular accel of the frame relative to parent in parent frame coords

◆ setRootRelAngularVelocity()

int modelspace::Frame::setRootRelAngularVelocity ( const clockwerk::CartesianVector< 3 > &  w_f_root__f)

Function to set the frame's position relative to root.

Parameters
w_f_root__fAngular velocity of this frame wrt root frame origin, as specified in this frame
Note
If parent is not yet assigned, will throw error
With great power comes great responsibility. This thing will set ang vel to whatever you want, minimal questions asked, independent of if you later change attitude, etc.

◆ setRootRelAttitude()

int modelspace::Frame::setRootRelAttitude ( const clockwerk::Quaternion quat_f_root)

Function to set the frame's attitude relative to root.

Parameters
quat_f_rootAttitude of this frame wrt root frame
Note
If parent is not yet assigned, will throw error
With great power comes great responsibility. This thing will set attitude to whatever you want, minimal questions asked, independent of if you later change attitude, etc.

◆ setRootRelPosition()

int modelspace::Frame::setRootRelPosition ( const clockwerk::CartesianVector< 3 > &  pos_f_root__root)

Function to set the frame's position relative to root.

Parameters
pos_f_root__rootPosition of this frame wrt root frame origin, as specified in the root frame
Note
If parent is not yet assigned, will throw error
With great power comes great responsibility. This thing will set position to whatever you want, minimal questions asked, independent of if you later change attitude, etc.

◆ setRootRelVelocity()

int modelspace::Frame::setRootRelVelocity ( const clockwerk::CartesianVector< 3 > &  vel_f_root__root)

Function to set the frame's velocity relative to root.

Parameters
vel_f_root__rootVelocity of this frame wrt root frame origin, as specified in the root frame
Note
If parent is not yet assigned, will throw error
With great power comes great responsibility. This thing will set velocity to whatever you want, minimal questions asked, independent of if you later change attitude, etc.

◆ setStateFromStateVector()

void modelspace::Frame::setStateFromStateVector ( const std::array< floating_point, 13 > &  state_f_p__f)

Function to set frame state based on NUM_INTEGRATED_STATES-element state vector.

Parameters
stateNUM_INTEGRATED_STATES-element state vector as [pos][vel][quat][omega]

◆ tJoint()

Joint& modelspace::Frame::tJoint ( )
inline

Function to get reference to the frame's translational joint.

Returns
The frame's translational joint

Member Data Documentation

◆ _acc_f_p__p

clockwerk::CartesianVector<3> modelspace::Frame::_acc_f_p__p
protected

Internal variables to store accelerations applied to this frame. Note: these are not states. They are temporary variables and treated slightly differently.

◆ _alpha_f_p__f

clockwerk::CartesianVector<3> modelspace::Frame::_alpha_f_p__f
protected

◆ _integrator_ptr

void* modelspace::Frame::_integrator_ptr = nullptr
protected

Rotational.

Pointer to the integrator that is integrating this frame. Nullptr if unused

◆ _parent

Frame* modelspace::Frame::_parent
protected

Variable to hold our parent.

◆ _r_joint

Joint modelspace::Frame::_r_joint
protected

Translational.

◆ _t_joint

Joint modelspace::Frame::_t_joint
protected

Translational and rotational joints relating this frame to its parent. Set locked by default.

◆ ang_vel_f_p__f

clockwerk::DataIO<clockwerk::CartesianVector<3> > modelspace::Frame::ang_vel_f_p__f
Initial value:
=
Class for inter-object communication.
Definition: DataIO.hpp:59

Angular velocity of the frame with respect to parent, in frame coordinates

◆ pos_f_p__p

clockwerk::DataIO<clockwerk::CartesianVector<3> > modelspace::Frame::pos_f_p__p
Initial value:

Position of the frame with respect to parent, in parent coordinates

◆ quat_f_p

clockwerk::DataIO<clockwerk::Quaternion> modelspace::Frame::quat_f_p
Initial value:
=
Quaternion class for attitude representation.
Definition: Quaternion.h:68

Attitude quaternion of the frame with respect to parent

◆ self_id

clockwerk::DataIO<Frame*> modelspace::Frame::self_id = clockwerk::DataIO<Frame*>(nullptr, "self_id", this)

◆ vel_f_p__p

clockwerk::DataIO<clockwerk::CartesianVector<3> > modelspace::Frame::vel_f_p__p
Initial value:

Velocity of the frame with respect to parent, in parent coordinates. Note that this is the velocity IN the parent frame, which takes into account rotation.


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