ModelSpace
All Classes Namespaces Functions Variables Enumerations Pages
Node.hpp
1/******************************************************************************
2* Copyright (c) ATTX LLC 2024. All Rights Reserved.
3*
4* This software and associated documentation (the "Software") are the
5* proprietary and confidential information of ATTX, LLC. The Software is
6* furnished under a license agreement between ATTX and the user organization
7* and may be used or copied only in accordance with the terms of the agreement.
8* Refer to 'license/attx_license.adoc' for standard license terms.
9*
10* EXPORT CONTROL NOTICE: THIS SOFTWARE MAY INCLUDE CONTENT CONTROLLED UNDER THE
11* INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) OR THE EXPORT ADMINISTRATION
12* REGULATIONS (EAR99). No part of the Software may be used, reproduced, or
13* transmitted in any form or by any means, for any purpose, without the express
14* written permission of ATTX, LLC.
15******************************************************************************/
16/*
17Node header file
18
19Author: Alex Reynolds
20*/
21#ifndef NODE_HPP
22#define NODE_HPP
23
24#include "Frame.hpp"
25#include "data_management/DataIO.hpp"
26#include "core/matrixmath.hpp"
27#include "core/vectormath.hpp"
28#include "utils/frameutils.hpp"
29
30namespace clockwerk {
31
32 /// @brief Node class to apply forces and moments to frames
33 ///
34 /// This file defines the base node class which is used to apply forces and
35 /// sense accelerations at fixed locations on bodies.
36 ///
37 /// The node class is a special Frame that is fully fixed to its parent
38 /// (i.e. cannot be fully free) and has special handles for applying forces
39 /// and moments. Because it is a simple fixed frame, it is also ideal for
40 /// sensing accelerations and states, in applications such as an accelerometer.
41 ///
42 /// Applying forces in the node frame is done via the force() and moment() DataIO
43 /// objects. By default, forces and moments are applied in the node frame. However,
44 /// passing a frame argument to the force_frame or moment_frame objects causes forces
45 /// and moments to be applied in that frame -- this is particularly useful for cases
46 /// where the node frame is rotating but the force is not, such as gravity applied
47 /// to a rotating spacecraft node.
48 template <typename T=double>
49 class Node : public Frame<T> {
50 public:
51 /// @brief Basic constructor for the node object
52 /// @param name The name of the node
53 /// @param par The node's parent. Nullptr by default
54 Node(const std::string &name, Frame<T> *par=nullptr);
55
56 /// @brief Function to get the frame's translational joint
57 /// @return The frame's translational joint
58 clockwerk::Joint<T> tJoint() {return Frame<T>::_t_joint;}
59
60 /// @brief Function to get the frame's rotational joint
61 /// @return The frame's rotational joint
62 clockwerk::Joint<T> rJoint() {return Frame<T>::_r_joint;}
63
64 /// @brief The force applied at the node
65 clockwerk::DataIO<CartesianVector<T,3>> force
66 = clockwerk::DataIO<CartesianVector<T,3>>(nullptr, "force", CartesianVector<T,3>({0.0,0.0,0.0}));
67 /// @brief The frame in which the force is applied.
68 /// Using this utility abstracts away framerotate commands and also allows forces
69 /// to be applied inertially or frame locally, because rotation will occur every step
70 /// @note Our node only rotates from the force frame -- no translation or coupling
71 clockwerk::DataIO<Frame<T>*> force_frame = clockwerk::DataIO<Frame<T>*>(nullptr, "force_frame", nullptr);
72
73 /// @brief The moment applied at the node
74 clockwerk::DataIO<CartesianVector<T,3>> moment = clockwerk::DataIO<CartesianVector<T,3>>(nullptr, "moment", CartesianVector<T,3>({0.0,0.0,0.0}));
75 /// @brief The frame in which the moment is applied
76 /// Using this utility abstracts away framerotate commands and also allows moments
77 /// to be applied inertially or frame locally, because rotation will occur every step
78 /// @note Our node only rotates from the moment frame -- no translation or coupling
79 clockwerk::DataIO<Frame<T>*> moment_frame = clockwerk::DataIO<Frame<T>*>(nullptr, "moment_frame", nullptr);
80
81 /* Nice handle to the node itself for mapping*/
82 clockwerk::DataIO<Node<T>*> self_id = clockwerk::DataIO<Node<T>*>(nullptr, "self_id", this);
83
84 /// @brief Function to resolve applied forces/moments into a force/moment pair in parent body frame origin
85 /// @param force_parentcg__p Implicit return of force applied to this node in the parent body frame
86 /// @param moment_parentcg__p Implicit return of moment applied to this node in the parent body frame,
87 /// RESOLVED TO A FORCE/MOMENT COUPLE AT THE PARENT FRAME LOCATION
88 void getFMPairAtParentOrigin(CartesianVector<T, 3> &force_parentcg__p, CartesianVector<T, 3> &moment_parentcg__p);
89
90 CartesianVector<T, 3> passthroughForce() {return _passthrough_force__b;}
91 CartesianVector<T, 3> passthroughMoment() {return _passthrough_moment__b;}
92 protected:
93 /// Passthrough force on the node -- force not applied here but passed on to parent body
94 /// All forces and moments should be passed through for nodes
96 CartesianVector<T, 3> _passthrough_moment__b;
97 };
98
99 template <typename T>
100 Node<T>::Node(const std::string &name, Frame<T>* par)
101 : Frame<T>(name, par, false) {
102
104 }
105
106 template <typename T>
107 void Node<T>::getFMPairAtParentOrigin(CartesianVector<T, 3> &force_parentcg__p,
108 CartesianVector<T, 3> &moment_parentcg__p) {
109 /// First, we need to get our force and moment as applied in the node frame
110 // std::cout<<Frame<T>::name()<<std::endl;
111 if(force_frame() == nullptr || force_frame() == this) {
113 } else {
114 frameRotate(force(), *force_frame(), *this, _passthrough_force__b);
115 }
116 if(moment_frame() == nullptr || moment_frame() == this) {
117 _passthrough_moment__b = moment();
118 } else {
119 frameRotate(moment(), *moment_frame(), *this, _passthrough_moment__b);
120 }
121
122 // First calculate our passthrough force in parent frame
123 DCM<T> dcm_p_f = Frame<T>::quat_f_p().toDCM().inverse();
124 force_parentcg__p = dcm_p_f*_passthrough_force__b;
125
126 /// Now add our moment couple to our already applied moment
127 moment_parentcg__p = dcm_p_f*_passthrough_moment__b + cross(Frame<T>::pos_f_p__p(), force_parentcg__p);
128 }
129
130}
131
132#endif
Standard vector class derived from Matrix.
Definition CartesianVector.hpp:39
Class defining a direction cosine matrix inherited from Matrix.
Definition DCM.hpp:71
Class for inter-object communication.
Definition DataIO.hpp:46
Frame class definition.
Definition Frame.hpp:92
Base class for object organization.
Definition GraphTreeObject.h:87
uint8_t _graph_tree_type
Variable to store graph tree object type.
Definition GraphTreeObject.h:251
Joint class defining relationship between frames.
Definition Joint.hpp:44
clockwerk::DataIO< CartesianVector< T, 3 > > moment
The moment applied at the node.
Definition Node.hpp:74
CartesianVector< T, 3 > _passthrough_force__b
Passthrough force on the node – force not applied here but passed on to parent body All forces and mo...
Definition Node.hpp:95
clockwerk::Joint< T > rJoint()
Function to get the frame's rotational joint.
Definition Node.hpp:62
clockwerk::DataIO< Frame< T > * > moment_frame
The frame in which the moment is applied Using this utility abstracts away framerotate commands and a...
Definition Node.hpp:79
clockwerk::Joint< T > tJoint()
Function to get the frame's translational joint.
Definition Node.hpp:58
clockwerk::DataIO< Frame< T > * > force_frame
The frame in which the force is applied. Using this utility abstracts away framerotate commands and a...
Definition Node.hpp:71
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.
Definition Node.hpp:107
Node(const std::string &name, Frame< T > *par=nullptr)
Basic constructor for the node object.
Definition Node.hpp:100
clockwerk::DataIO< CartesianVector< T, 3 > > force
The force applied at the node.
Definition Node.hpp:66