![]() |
ModelSpace
|
Node class to apply forces and moments to frames. More...
#include <Node.hpp>
Public Member Functions | |
Node (const std::string &name, Frame< T > *par=nullptr) | |
Basic constructor for the node object. | |
clockwerk::Joint< T > | tJoint () |
Function to get the frame's translational joint. | |
clockwerk::Joint< T > | rJoint () |
Function to get the frame's rotational joint. | |
void | getFMPairAtParentOrigin (CartesianVector< T, 3 > &force_parentcg__p, CartesianVector< T, 3 > &moment_parentcg__p) |
Function to resolve applied forces/moments into a force/moment pair in parent body frame origin. | |
CartesianVector< T, 3 > | passthroughForce () |
CartesianVector< T, 3 > | passthroughMoment () |
int | parent (Frame< T > *new_parent) |
Function to assign the frame's parent via pointer. | |
Frame< T > * | parent () |
int | parent (GraphTreeObject *new_parent) |
Function to assign the node's parent via pointer. | |
int | parent (GraphTreeObject &new_parent) |
Function to assign the node's parent via reference. | |
void | setParentRelAcceleration (CartesianVector< T, 3 > accel) |
Function to set parent relative acceleration of frame. | |
void | setParentRelAngularAcceleration (CartesianVector< T, 3 > alpha) |
Function to set parent relative angular acceleration. | |
CartesianVector< T, 3 > | parentRelAcceleration () |
Function to get the acceleration of the frame relative to parent expressed in parent coords. | |
CartesianVector< T, 3 > | parentRelAngularAcceleration () |
Function to get angular acceleration relative to parent in frame coords. | |
void | rootRelPosition (CartesianVector< T, 3 > &pos_o_root__root) |
Returns the position of the frame origin wrt the root origin, in root coordinates. | |
CartesianVector< T, 3 > | rootRelPosition () |
void | rootRelVelocity (CartesianVector< T, 3 > &vel_o_root__root) |
Returns the velocity of the frame origin wrt the root origin, in root coordinates. | |
CartesianVector< T, 3 > | rootRelVelocity () |
void | rootRelAcceleration (CartesianVector< T, 3 > &acc_o_root__root) |
Returns the acceleration of the frame origin wrt the root origin, in root coordinates. | |
CartesianVector< T, 3 > | rootRelAcceleration () |
void | rootRelQuaternion (Quaternion< T > &quat_f_root) |
Returns the quaternion representing the frame origin wrt the root frame. | |
Quaternion< T > | rootRelQuaternion () |
void | rootRelDCM (DCM< T > &dcm_f_root) |
Returns the DCM of the frame origin wrt the root frame. | |
DCM< T > | rootRelDCM () |
void | rootRelAngularVelocity (CartesianVector< T, 3 > &w_f_root__f) |
Returns the angular velocity of the frame origin wrt the root, expressed in this frame's coordinates. | |
CartesianVector< T, 3 > | rootRelAngularVelocity () |
void | rootRelAngularAcceleration (CartesianVector< T, 3 > &alpha_f_root__f) |
Returns the angular acceleration of the frame origin wrt the root, expressed in this frame's coordinates. | |
CartesianVector< T, 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. | |
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< T, 13 > &state_f_p__f) |
Function to set frame state based on NUM_INTEGRATED_STATES-element state vector. | |
void | getStateAsStateVector (std::array< T, 13 > &state_f_p__f) |
Function to return frame state as a NUM_INTEGRATED_STATES-element state vector. | |
void | getStateVectorDot (std::array< T, 13 > &state_dot) |
Function to get the rate of change in the frame state vector. | |
int | setRootRelPosition (const CartesianVector< T, 3 > &pos_f_root__root) |
Function to set the frame's position relative to root. | |
int | setRootRelVelocity (const CartesianVector< T, 3 > &vel_f_root__root) |
Function to set the frame's velocity relative to root. | |
int | setRootRelAttitude (const Quaternion< T > &quat_f_root) |
Function to set the frame's attitude relative to root. | |
int | setRootRelAngularVelocity (const CartesianVector< T, 3 > &w_f_root__f) |
Function to set the frame's position relative to root. | |
Frame< T > * | getFrameRootPointer () |
Function to get a pointer to this frame's root frame. | |
std::vector< GraphTreeObject * > & | children () |
unsigned int | nChildren () |
Getters for number of children and descendants. | |
unsigned int | nDescendants () |
std::string | name () const |
Getter and setter for object name. | |
int | name (const std::string &new_name) |
int | rank () |
Getter for the object rank. | |
virtual int | 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. | |
std::string | address () |
Getter for object's string address. | |
std::vector< std::string > | search (const std::string &address) |
Function to search through the graph tree by string address. | |
GraphTreeObject * | getByAddress (const std::string &address) |
Function to get an object from the graph tree by string address. | |
void | dump (bool recursive=false) |
Function to dump the graph node, optionally including descendents. | |
void | graphNodeInfo () |
Function to return all info associated with a given graph node. | |
void | recurseGraphNodeInfo (unsigned int counter) |
Function to recurse through graph tree and print all node info. | |
virtual int | header (void *logger) |
Function to pass headers for this object to the logger. | |
virtual std::vector< std::string > | header_info () const |
void | findLoggable (std::vector< GraphTreeObject * > &matches) |
Function to find all loggable parameters in this node and its children. | |
virtual int | log (void *logger) |
Function to log data to a logger. | |
void | lock (bool recursive=true) |
Function to lock the graph tree object and its children to changes. | |
void | unlock (bool recursive=true) |
Function to unlock the graph tree and its children for changes. | |
bool | locked () |
Function to return whether graph tree object is locked. | |
Public Attributes | |
clockwerk::DataIO< CartesianVector< T, 3 > > | force = clockwerk::DataIO<CartesianVector<T,3>>(nullptr, "force", CartesianVector<T,3>({0.0,0.0,0.0})) |
The force applied at the node. | |
clockwerk::DataIO< Frame< T > * > | force_frame = clockwerk::DataIO<Frame<T>*>(nullptr, "force_frame", nullptr) |
The frame in which the force is applied. Using this utility abstracts away framerotate commands and also allows forces to be applied inertially or frame locally, because rotation will occur every step. | |
clockwerk::DataIO< CartesianVector< T, 3 > > | moment = clockwerk::DataIO<CartesianVector<T,3>>(nullptr, "moment", CartesianVector<T,3>({0.0,0.0,0.0})) |
The moment applied at the node. | |
clockwerk::DataIO< Frame< T > * > | moment_frame = clockwerk::DataIO<Frame<T>*>(nullptr, "moment_frame", nullptr) |
The frame in which the moment is applied Using this utility abstracts away framerotate commands and also allows moments to be applied inertially or frame locally, because rotation will occur every step. | |
clockwerk::DataIO< Node< T > * > | self_id = clockwerk::DataIO<Node<T>*>(nullptr, "self_id", this) |
clockwerk::DataIO< CartesianVector< T, 3 > > | pos_f_p__p |
clockwerk::DataIO< CartesianVector< T, 3 > > | vel_f_p__p |
clockwerk::DataIO< Quaternion< T > > | quat_f_p |
clockwerk::DataIO< CartesianVector< T, 3 > > | ang_vel_f_p__f |
Protected Member Functions | |
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. | |
std::vector< std::string > | decomposeAddress (std::string address) |
Function to decompose a string into a series of substrings via indexing. | |
void | findMatches (const std::vector< std::string > &subaddresses, const unsigned int &num_subaddresses, unsigned int index, bool match_found, std::vector< GraphTreeObject * > &matches) |
Function to find all addresses mathcing the set of substrings @parem subaddresses A vector of subaddresses to match. | |
std::vector< GraphTreeObject * > | searchNodes (const std::string &address) |
Function to search through the graph tree by string address. | |
int | addChild (GraphTreeObject *child) |
Function to add a child to the graph tree object. | |
int | removeChild (GraphTreeObject *child) |
Function to remove a child from the graph node's children. | |
Protected Attributes | |
CartesianVector< T, 3 > | _passthrough_force__b |
Passthrough force on the node – force not applied here but passed on to parent body All forces and moments should be passed through for nodes. | |
CartesianVector< T, 3 > | _passthrough_moment__b |
CartesianVector< T, 3 > | _acc_f_p__p |
Internal variables to store accelerations applied to this frame. Note: these are not states. They are temporary variables and treated slightly differently. | |
CartesianVector< T, 3 > | _alpha_f_p__f |
Joint< T > | _t_joint |
Translational and rotational joints relating this frame to its parent. Set locked by default. | |
Joint< T > | _r_joint |
Translational. | |
void * | _integrator_ptr = nullptr |
Rotational. | |
Frame< T > * | _parent |
Variable to hold our parent. | |
std::vector< GraphTreeObject * > | _children |
Pointers to the object's children – automatically set to an empty vector, and can be increased to any size. | |
std::string | _name = DEFAULT_NAME |
String name for object. | |
uint16_t | _num_descendants = 0 |
Total number of descendants (includes children of children) of the tree, again not including the tree itself. | |
uint8_t | _num_children = 0 |
Number of direct children of the tree (not including the tree itself) | |
uint8_t | _rank = 0 |
Rank for how far down on the graph tree the object is – starts at zero and maxes out at 256 via variable size. | |
uint8_t | _graph_tree_type = BASE_GRAPH_TREE |
Variable to store graph tree object type. | |
bool | _locked = false |
Variable to lock the graph tree object and prevent structural updates. | |
bool | _loggable = false |
Variable to indicate whether the selected object is loggable. Set to false by default. | |
Node class to apply forces and moments to frames.
This file defines the base node class which is used to apply forces and sense accelerations at fixed locations on bodies.
The node class is a special Frame that is fully fixed to its parent (i.e. cannot be fully free) and has special handles for applying forces and moments. Because it is a simple fixed frame, it is also ideal for sensing accelerations and states, in applications such as an accelerometer.
Applying forces in the node frame is done via the force() and moment() DataIO objects. By default, forces and moments are applied in the node frame. However, passing a frame argument to the force_frame or moment_frame objects causes forces and moments to be applied in that frame – this is particularly useful for cases where the node frame is rotating but the force is not, such as gravity applied to a rotating spacecraft node.
Basic constructor for the node object.
name | The name of the node |
par | The node's parent. Nullptr by default |
|
protectedinherited |
Function to add a child to the graph tree object.
child | A pointer to the graph tree object to add to the tree |
|
inherited |
Getter for object's string address.
|
inherited |
Function to recurse through the body and its children to resolve applied external forces and moments into acceleration and angular acceleration.
|
inherited |
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.
|
protectedinherited |
Function to decompose a string into a series of substrings via indexing.
address | The address to be decomposed |
Function to dump the graph node, optionally including descendents.
recursive | Parameter indicating whether to dump only one node (default/false) or the entire tree (true) |
|
inherited |
Function to find all loggable parameters in this node and its children.
matches | Expandable vector to hold all matches in the tree |
|
protectedinherited |
Function to find all addresses mathcing the set of substrings @parem subaddresses A vector of subaddresses to match.
num_subaddresses | The number of subaddresses to match |
index | The index of subaddresses to search in |
match_found | Variable indicating whether a match was found higher in the tree |
matches | Implicit return of all matches to the specified address |
|
inherited |
Function to get an object from the graph tree by string address.
address | The exact string address to access the variable with |
void clockwerk::Node< T >::getFMPairAtParentOrigin | ( | CartesianVector< T, 3 > & | force_parentcg__p, |
CartesianVector< T, 3 > & | moment_parentcg__p | ||
) |
Function to resolve applied forces/moments into a force/moment pair in parent body frame origin.
force_parentcg__p | Implicit return of force applied to this node in the parent body frame |
moment_parentcg__p | Implicit return of moment applied to this node in the parent body frame, RESOLVED TO A FORCE/MOMENT COUPLE AT THE PARENT FRAME LOCATION |
Function to get a pointer to this frame's root frame.
|
inherited |
Function to return frame state as a NUM_INTEGRATED_STATES-element state vector.
state | Return of NUM_INTEGRATED_STATES-element state vector as [pos][vel][quat][omega] |
|
inherited |
Function to get the rate of change in the frame state vector.
state_dot | Rate of change in each element of the state vector |
Function to pass headers for this object to the logger.
logger | Pointer to logger |
Reimplemented in clockwerk::DataIO< T >, clockwerk::DataIO< bool >, clockwerk::DataIO< clockwerk::Body< double > * >, clockwerk::DataIO< clockwerk::Body< T > * >, clockwerk::DataIO< clockwerk::CartesianVector< double, 2 > >, clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > >, clockwerk::DataIO< clockwerk::CartesianVector< T, 3 > >, clockwerk::DataIO< clockwerk::Euler321< double > >, clockwerk::DataIO< clockwerk::Frame< double > * >, clockwerk::DataIO< clockwerk::Frame< T > * >, clockwerk::DataIO< clockwerk::Matrix< double, 2, 2 > >, clockwerk::DataIO< clockwerk::Matrix< double, 3, 3 > >, clockwerk::DataIO< clockwerk::Matrix< double, 6, 3 > >, clockwerk::DataIO< clockwerk::Matrix< double, 6, 6 > >, clockwerk::DataIO< clockwerk::Matrix< T, 3, 3 > >, clockwerk::DataIO< clockwerk::Node< double > * >, clockwerk::DataIO< clockwerk::Quaternion< double > >, clockwerk::DataIO< clockwerk::Quaternion< T > >, clockwerk::DataIO< clockwerk::Time >, clockwerk::DataIO< double >, clockwerk::DataIO< int >, clockwerk::DataIO< modelspace::integrator_type_e >, clockwerk::DataIO< std::string >, and clockwerk::DataIO< void * >.
|
inlinevirtualinherited |
Reimplemented in clockwerk::Time.
Function to lock the graph tree object and its children to changes.
recursive | Flag to indicate whether lock should be recursive |
Function to log data to a logger.
logger | Pointer to logger |
Reimplemented in clockwerk::Time, clockwerk::DataIO< T >, clockwerk::DataIO< bool >, clockwerk::DataIO< clockwerk::Body< double > * >, clockwerk::DataIO< clockwerk::Body< T > * >, clockwerk::DataIO< clockwerk::CartesianVector< double, 2 > >, clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > >, clockwerk::DataIO< clockwerk::CartesianVector< T, 3 > >, clockwerk::DataIO< clockwerk::Euler321< double > >, clockwerk::DataIO< clockwerk::Frame< double > * >, clockwerk::DataIO< clockwerk::Frame< T > * >, clockwerk::DataIO< clockwerk::Matrix< double, 2, 2 > >, clockwerk::DataIO< clockwerk::Matrix< double, 3, 3 > >, clockwerk::DataIO< clockwerk::Matrix< double, 6, 3 > >, clockwerk::DataIO< clockwerk::Matrix< double, 6, 6 > >, clockwerk::DataIO< clockwerk::Matrix< T, 3, 3 > >, clockwerk::DataIO< clockwerk::Node< double > * >, clockwerk::DataIO< clockwerk::Quaternion< double > >, clockwerk::DataIO< clockwerk::Quaternion< T > >, clockwerk::DataIO< clockwerk::Time >, clockwerk::DataIO< double >, clockwerk::DataIO< int >, clockwerk::DataIO< modelspace::integrator_type_e >, clockwerk::DataIO< std::string >, and clockwerk::DataIO< void * >.
Function to assign the frame's parent via pointer.
new_parent | The new parent to assign the node to |
|
inherited |
Function to assign the node's parent via reference.
new_parent | The new parent to assign the node to |
|
inherited |
Function to assign the node's parent via pointer.
new_parent | The new parent to assign the node to |
|
inlineinherited |
Function to get the acceleration of the frame relative to parent expressed in parent coords.
|
inlineinherited |
Function to get angular acceleration relative to parent in frame coords.
Function to recurse through graph tree and print all node info.
|
protectedinherited |
Function to remove a child from the graph node's children.
child | The child to remove |
|
inline |
Function to get the frame's rotational joint.
|
inherited |
Returns the acceleration of the frame origin wrt the root origin, in root coordinates.
acc_o_root_root | Implicit return of acceleration of origin relative to root, in root |
|
inherited |
Returns the angular acceleration of the frame origin wrt the root, expressed in this frame's coordinates.
alpha_f_root__f | Implicit return of angular acceleration relative to root, expressed in f frame |
|
inherited |
Returns the angular velocity of the frame origin wrt the root, expressed in this frame's coordinates.
w_f_root__f | Implicit return of angular velocity relative to root, expressed in f frame |
Returns the DCM of the frame origin wrt the root frame.
att_f_root | Implicit return of attitude relative to root |
|
inherited |
Returns the position of the frame origin wrt the root origin, in root coordinates.
pos_o_root_root | Implicit return of position of origin relative to root, in root |
|
inherited |
Returns the quaternion representing the frame origin wrt the root frame.
att_f_root | Implicit return of attitude relative to root |
|
inherited |
Returns the velocity of the frame origin wrt the root origin, in root coordinates.
vel_o_root_root | Implicit return of velocity of origin relative to root in root |
|
inherited |
Function to search through the graph tree by string address.
address | `The address or address chunk to search for |
|
protectedinherited |
Function to search through the graph tree by string address.
address | `The address or address chunk to search for |
|
inlineinherited |
Function to set parent relative acceleration of frame.
accel | acceleration of frame relative to parent in parent frame coords |
|
inlineinherited |
Function to set parent relative angular acceleration.
alpha | angular accel of the frame relative to parent in parent frame coords |
|
inherited |
Function to set the frame's position relative to root.
w_f_root__f | Angular velocity of this frame wrt root frame origin, as specified in this frame |
|
inherited |
Function to set the frame's attitude relative to root.
quat_f_root | Attitude of this frame wrt root frame |
|
inherited |
Function to set the frame's position relative to root.
pos_f_root__root | Position of this frame wrt root frame origin, as specified in the root frame |
|
inherited |
Function to set the frame's velocity relative to root.
vel_f_root__root | Velocity of this frame wrt root frame origin, as specified in the root frame |
|
inherited |
Function to set frame state based on NUM_INTEGRATED_STATES-element state vector.
state | NUM_INTEGRATED_STATES-element state vector as [pos][vel][quat][omega] |
|
inline |
Function to get the frame's translational joint.
Function to indicate type – -1 by default unless implemented downstream.
Function to unlock the graph tree and its children for changes.
recursive | Flag to indicate whether unlock should be recursive |
|
protectedinherited |
Rotational.
Pointer to the integrator that is integrating this frame. Nullptr if unused
|
inherited |
Angular velocity of the frame with respect to parent, in frame coordinates
clockwerk::DataIO<Frame<T>*> clockwerk::Node< T >::force_frame = clockwerk::DataIO<Frame<T>*>(nullptr, "force_frame", nullptr) |
The frame in which the force is applied. Using this utility abstracts away framerotate commands and also allows forces to be applied inertially or frame locally, because rotation will occur every step.
clockwerk::DataIO<Frame<T>*> clockwerk::Node< T >::moment_frame = clockwerk::DataIO<Frame<T>*>(nullptr, "moment_frame", nullptr) |
The frame in which the moment is applied Using this utility abstracts away framerotate commands and also allows moments to be applied inertially or frame locally, because rotation will occur every step.
|
inherited |
Position of the frame with respect to parent, in parent coordinates
|
inherited |
Attitude quaternion of the frame with respect to parent
|
inherited |
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.