WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
Frame.h
Go to the documentation of this file.
1/******************************************************************************
2* Copyright (c) ATTX INC 2025. All Rights Reserved.
3*
4* This software and associated documentation (the "Software") are the
5* proprietary and confidential information of ATTX, INC. 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, INC.
15******************************************************************************/
16/*
17Frame header file
18
19Author: Alex Reynolds
20*/
21#ifndef FRAMES_FRAME_H
22#define FRAMES_FRAME_H
23
24#include <string>
25#include <vector>
26
28#include "core/vectormath.hpp"
31#include "Joint.h"
32#include "dynamics/DCM.h"
33#include "dynamics/Quaternion.h"
34#include "dynamics/MRP.h"
35#include "dynamics/Euler321.h"
37#include "core/mathmacros.h"
38
39#define NUM_INTEGRATED_STATES 13
40
41namespace warptwin {
42 constexpr uint32 FRAME_MAXIMUM_NUM_CHILDREN = 100;
43
45 class Body;
46 class Node;
47
97 public:
102 Frame(const std::string &name, Frame* par=nullptr, bool free = false);
103
104 virtual ~Frame() {}
105
108 std::vector<Frame*> frameChildren();
109
114 Frame* getFrameByAddress(const std::string &address);
115
118 Joint& tJoint() {return _t_joint;}
119
122 Joint& rJoint() {return _r_joint;}
123
131 int parent(Frame* new_parent);
132 int parent(Frame& new_parent) {return parent(&new_parent);}
133 Frame* parent() {return _parent;}
134
148
149 /* Nice handle to the frame itself for mapping*/
151
155
159
163
167
172 void rootRelPosition(clockwerk::CartesianVector<3> &pos_o_root__root) const;
174
179 void rootRelVelocity(clockwerk::CartesianVector<3> &vel_o_root__root) const;
181
186 void rootRelAcceleration(clockwerk::CartesianVector<3> &acc_o_root__root) const;
188
193 void rootRelQuaternion(clockwerk::Quaternion &quat_f_root) const;
195
200 void rootRelDCM(clockwerk::DCM &dcm_f_root) const;
202
211
220
225
231
233 void integrator(void* integ_ptr) {_integrator_ptr = integ_ptr;}
234 void* integrator() {return _integrator_ptr;}
235
239 void setStateFromStateVector(const std::array<floating_point, NUM_INTEGRATED_STATES> &state_f_p__f);
240
243 void getStateAsStateVector(std::array<floating_point, NUM_INTEGRATED_STATES> &state_f_p__f);
244
247 void getStateVectorDot(std::array<floating_point, NUM_INTEGRATED_STATES> &state_dot);
248
256 int setRootRelPosition(const clockwerk::CartesianVector<3> &pos_f_root__root);
257
265 int setRootRelVelocity(const clockwerk::CartesianVector<3> &vel_f_root__root);
266
273 int setRootRelAttitude(const clockwerk::Quaternion &quat_f_root);
274
283
287
289 void dump();
290 protected:
295
300
303 void* _integrator_ptr = nullptr;
304
307
308 private:
309 // TODO: Use dynamic storage for frames. This is a temporary solution
310 // to get warptwin building, and thus does not get a cool defined constant.
312 };
313
314}
315
316#endif
Standard vector class derived from Matrix.
Definition CartesianVector.hpp:39
Class defining a direction cosine matrix inherited from Matrix.
Definition DCM.h:69
Class for inter-object communication.
Definition DataIO.hpp:60
Base class for object organization.
Definition GraphTreeObject.h:98
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.
Definition GraphTreeObject.cpp:23
const char * name() const
Getter and setter for object name.
Definition GraphTreeObject.h:135
Quaternion class for attitude representation.
Definition Quaternion.h:68
Class to define a body as a frame with mass and inertia.
Definition Body.h:44
Frame class definition.
Definition Frame.h:96
clockwerk::DataIO< clockwerk::CartesianVector< 3 > > pos_f_p__p
Definition Frame.h:136
virtual ~Frame()
Definition Frame.h:104
clockwerk::CartesianVector< 3 > parentRelAngularAcceleration()
Function to get angular acceleration relative to parent in frame coords.
Definition Frame.h:166
Frame * _parent
Variable to hold our parent.
Definition Frame.h:306
clockwerk::CartesianVector< 3 > parentRelAcceleration()
Function to get the acceleration of the frame relative to parent expressed in parent coords.
Definition Frame.h:162
clockwerk::DataIO< clockwerk::CartesianVector< 3 > > ang_vel_f_p__f
Definition Frame.h:146
void getStateVectorDot(std::array< floating_point, 13 > &state_dot)
Function to get the rate of change in the frame state vector.
Definition Frame.cpp:147
int setRootRelAttitude(const clockwerk::Quaternion &quat_f_root)
Function to set the frame's attitude relative to root.
Definition Frame.cpp:526
int calcFrameTreeExtAcceleration()
Function to recurse through the body and its children to resolve applied external forces and moments ...
Definition Frame.cpp:465
clockwerk::Quaternion rootRelQuaternion() const
Definition Frame.cpp:407
void integrator(void *integ_ptr)
Getter and setter for integrator pointer.
Definition Frame.h:233
clockwerk::DCM rootRelDCM() const
Definition Frame.cpp:426
clockwerk::DataIO< Frame * > self_id
Definition Frame.h:150
int setRootRelAngularVelocity(const clockwerk::CartesianVector< 3 > &w_f_root__f)
Function to set the frame's position relative to root.
Definition Frame.cpp:540
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.
Definition Frame.cpp:219
int parent(Frame &new_parent)
Definition Frame.h:132
clockwerk::CartesianVector< 3 > _acc_f_p__p
Definition Frame.h:293
Frame * getFrameRootPointer()
Function to get a pointer to this frame's root frame.
Definition Frame.cpp:139
void setParentRelAcceleration(clockwerk::CartesianVector< 3 > accel)
Function to set parent relative acceleration of frame.
Definition Frame.h:154
clockwerk::CartesianVector< 3 > rootRelAngularAcceleration() const
Definition Frame.cpp:382
void getStateAsStateVector(std::array< floating_point, 13 > &state_f_p__f)
Function to return frame state as a NUM_INTEGRATED_STATES-element state vector.
Definition Frame.cpp:228
int calcFrameTreeExtForcesMoments()
Function to recurse through the body and its children to apply external forces and moments to the "co...
Definition Frame.cpp:432
clockwerk::DataIO< clockwerk::CartesianVector< 3 > > vel_f_p__p
Definition Frame.h:140
clockwerk::CartesianVector< 3 > rootRelVelocity() const
Definition Frame.cpp:296
clockwerk::CartesianVector< 3 > rootRelAcceleration() const
Definition Frame.cpp:335
void dump()
Dump all information associated with the frame.
Definition Frame.cpp:552
clockwerk::CartesianVector< 3 > rootRelAngularVelocity() const
Definition Frame.cpp:359
void * _integrator_ptr
Rotational.
Definition Frame.h:303
clockwerk::CartesianVector< 3 > rootRelPosition() const
Definition Frame.cpp:267
int setRootRelVelocity(const clockwerk::CartesianVector< 3 > &vel_f_root__root)
Function to set the frame's velocity relative to root.
Definition Frame.cpp:509
Joint _t_joint
Definition Frame.h:298
Joint & rJoint()
Function to get reference to the frame's rotational joint.
Definition Frame.h:122
Frame * parent()
Definition Frame.h:133
Joint _r_joint
Translational.
Definition Frame.h:299
std::vector< Frame * > frameChildren()
Return all children of the frame as a vector of frames.
Definition Frame.cpp:123
void * integrator()
Definition Frame.h:234
Frame(const std::string &name, Frame *par=nullptr, bool free=false)
Constructor for the frame object.
Definition Frame.cpp:23
void setParentRelAngularAcceleration(clockwerk::CartesianVector< 3 > alpha)
Function to set parent relative angular acceleration.
Definition Frame.h:158
int setRootRelPosition(const clockwerk::CartesianVector< 3 > &pos_f_root__root)
Function to set the frame's position relative to root.
Definition Frame.cpp:496
clockwerk::DataIO< clockwerk::Quaternion > quat_f_p
Definition Frame.h:143
Joint & tJoint()
Function to get reference to the frame's translational joint.
Definition Frame.h:118
Frame * getFrameByAddress(const std::string &address)
Function to get an object from the graph tree by string address.
Definition Frame.cpp:135
clockwerk::CartesianVector< 3 > _alpha_f_p__f
Definition Frame.h:294
Joint class defining relationship between frames.
Definition Joint.h:45
Node class to apply forces and moments to frames.
Definition Node.h:44
Class to propagate CR3BP dynamics in characteristic units.
Definition statistics.hpp:22
constexpr uint32 FRAME_MAXIMUM_NUM_CHILDREN
Definition Frame.h:42
double alpha[9]
Definition nrlmsise-00.cpp:77