WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
warptwin::Body Class Reference

Class to define a body as a frame with mass and inertia. More...

#include <Body.h>

Inheritance diagram for warptwin::Body:

Public Member Functions

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

Public Attributes

clockwerk::DataIO< floating_point > mass = clockwerk::DataIO<floating_point>(nullptr, "mass", 1.0)
 Signal/parameter for the body's mass.
clockwerk::DataIO< clockwerk::Matrix< 3, 3 > > inertia
 Signal/parameter for the body's inertia.
clockwerk::DataIO< floating_point > composite_mass = clockwerk::DataIO<floating_point>(nullptr, "composite_mass", 1.0)
 Signal/parameter for the body's composite mass.
clockwerk::DataIO< clockwerk::Matrix< 3, 3 > > composite_inertia
 Signal/parameter for the body's composite inertia.
clockwerk::DataIO< Body * > self_id = clockwerk::DataIO<Body*>(nullptr, "self_id", this)
Public Attributes inherited from warptwin::Frame
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 Member Functions

void _calcCompositeMassInertiaCM ()
 Function to recurse through children and calculate body composite inertia.
void _calcAppliedForceMoment (const clockwerk::CartesianVector< 3 > &force, const clockwerk::CartesianVector< 3 > &moment)
 Function to resolve forces and moments to body frame as applied and passed through.
Protected Member Functions inherited from clockwerk::GraphTreeObject
int16 _setStorage (GraphTreeObject **storage_array, uint8 storage_size)
 Getter for object's string address.
void _recalculateDescendants ()
 Function to recursively re-calculate the number of descendants of a given node on the tree.
void _recalculateRank ()
 Function to recursively re-calculate the rank of a given node on the tree.
int16 _addChild (GraphTreeObject *child)
 Function to decompose a string into a series of substrings via indexing.
int16 _removeChild (GraphTreeObject *child)
 Function to remove a child from the graph node's children.

Protected Attributes

clockwerk::CartesianVector< 3 > _ext_force__b
 Applied external force and moment on the body.
clockwerk::CartesianVector< 3 > _ext_moment__b
clockwerk::CartesianVector< 3 > _passthrough_force__b
 Passthrough force on the body – force not applied here but passed on to parent body.
clockwerk::CartesianVector< 3 > _passthrough_moment__b
Protected Attributes inherited from warptwin::Frame
clockwerk::CartesianVector< 3 > _acc_f_p__p
clockwerk::CartesianVector< 3 > _alpha_f_p__f
Joint _t_joint
Joint _r_joint
 Translational.
void * _integrator_ptr = nullptr
 Rotational.
Frame_parent
 Variable to hold our parent.
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.
uint8 _num_children = 0
 Number of direct children of the tree (not including the tree itself).
uint8 _rank = 0
int8 _graph_tree_type = BASE_GRAPH_TREE
 Variable to store graph tree object type.
bool _loggable = false
 Variable to indicate whether the selected object is loggable. Set to false by default.
uint32 _index = 0
 Index pointing to the next write location for the graph tree children.

Detailed Description

Class to define a body as a frame with mass and inertia.

This file defines the base body class which forms the basis for 6-DOF dynaics. Bodies are special invocations of the Frame object with mass and inertia, which allows them to interact with frames freely.

For the individual body, inertia is assumed to be about the frame center.

TODO For now, the body class enforces the following constraints in order to make things simpler and verify dynamics.

  • Bodies may only be children of frames
  • Nodes may only be children of bodies
  • Joints are restricted to fully free or fully locked

Unless otherwise noted units should be assumed metric

Constructor & Destructor Documentation

◆ Body()

warptwin::Body::Body ( const std::string & name,
Frame * par = nullptr )

Parent constructor for the body object.

Parameters
nameThe name of the body
parThe frame parent. Default is nullptr

Member Function Documentation

◆ _calcAppliedForceMoment()

void warptwin::Body::_calcAppliedForceMoment ( const clockwerk::CartesianVector< 3 > & force,
const clockwerk::CartesianVector< 3 > & moment )
protected

Function to resolve forces and moments to body frame as applied and passed through.

◆ _calcCompositeMassInertiaCM()

void warptwin::Body::_calcCompositeMassInertiaCM ( )
protected

Function to recurse through children and calculate body composite inertia.

◆ calcFrameTreeExtAcceleration()

int warptwin::Body::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
Specific implementation of this function for body class. Overwrites frame class implementation

◆ calcFrameTreeExtForcesMoments()

int warptwin::Body::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.

Note
Specific implementation of this function for body class. Overwrites frame class implementation

◆ dump()

void warptwin::Body::dump ( )

Dump all information associated with the frame.

◆ externalForce()

clockwerk::CartesianVector< 3 > warptwin::Body::externalForce ( )
inline

Getters for force and moment stuff.

◆ externalMoment()

clockwerk::CartesianVector< 3 > warptwin::Body::externalMoment ( )
inline

◆ getFMPairAtParentOrigin()

void warptwin::Body::getFMPairAtParentOrigin ( clockwerk::CartesianVector< 3 > & force_parentcg__p,
clockwerk::CartesianVector< 3 > & moment_parentcg__p )

Function to resolve passthrough forces/moments into a force/moment pair in parent body frame origin.

Parameters
force_parentcg__pImplicit return of passthrough force applied to this body in the parent body frame
moment_parentcg__pImplicit return of passthrough moment applied to this body in the parent body frame, RESOLVED TO A FORCE/MOMENT COUPLE AT THE PARENT FRAME LOCATION

◆ passthroughForce()

clockwerk::CartesianVector< 3 > warptwin::Body::passthroughForce ( )
inline

◆ passthroughMoment()

clockwerk::CartesianVector< 3 > warptwin::Body::passthroughMoment ( )
inline

Member Data Documentation

◆ _ext_force__b

clockwerk::CartesianVector<3> warptwin::Body::_ext_force__b
protected

Applied external force and moment on the body.

◆ _ext_moment__b

clockwerk::CartesianVector<3> warptwin::Body::_ext_moment__b
protected

◆ _passthrough_force__b

clockwerk::CartesianVector<3> warptwin::Body::_passthrough_force__b
protected

Passthrough force on the body – force not applied here but passed on to parent body.

◆ _passthrough_moment__b

clockwerk::CartesianVector<3> warptwin::Body::_passthrough_moment__b
protected

◆ composite_inertia

clockwerk::DataIO<clockwerk::Matrix<3, 3> > warptwin::Body::composite_inertia
Initial value:
= clockwerk::DataIO<clockwerk::Matrix<3, 3>>(nullptr, "composite_inertia",
clockwerk::Matrix<3, 3>({{1.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,1.0}}))
Class for inter-object communication.
Definition DataIO.hpp:60
Matrix math implementation.
Definition Matrix.hpp:55

Signal/parameter for the body's composite inertia.

Note
Is calculated – should not be modified

◆ composite_mass

clockwerk::DataIO<floating_point> warptwin::Body::composite_mass = clockwerk::DataIO<floating_point>(nullptr, "composite_mass", 1.0)

Signal/parameter for the body's composite mass.

Note
Is calculated – should not be modified

◆ inertia

clockwerk::DataIO<clockwerk::Matrix<3, 3> > warptwin::Body::inertia
Initial value:
clockwerk::Matrix<3, 3>({{1.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,1.0}}))

Signal/parameter for the body's inertia.

◆ mass

clockwerk::DataIO<floating_point> warptwin::Body::mass = clockwerk::DataIO<floating_point>(nullptr, "mass", 1.0)

Signal/parameter for the body's mass.

◆ self_id

clockwerk::DataIO<Body*> warptwin::Body::self_id = clockwerk::DataIO<Body*>(nullptr, "self_id", this)

The documentation for this class was generated from the following files:
  • /Users/mickey/Documents/Projects/warptwin/cpp/src/frames/Body.h
  • /Users/mickey/Documents/Projects/warptwin/cpp/src/frames/Body.cpp