ModelSpace
All Classes Namespaces Functions Variables Enumerations Pages
SimpleSpacecraft.h
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/*
17Spacecraft model header file
18
19Author: Alex Reynolds
20*/
21
22#ifndef MODELS_ASSEMBLIES_SPACECRAFT_H
23#define MODELS_ASSEMBLIES_SPACECRAFT_H
24
25#include "core/macros.h"
26#include "core/CartesianVector.hpp"
27#include "six_dof_dynamics/Body.hpp"
28#include "six_dof_dynamics/Node.hpp"
29#include "models/states/FrameStateSensorModel.h"
30#include "models/environment/AsphericalGravityModel.h"
31#include "models/assemblies/SimplePlanet.h"
32#include "models/assemblies/SpicePlanet.h"
33#include "models/states/PlanetRelativeStatesModel.h"
34#include "models/environment/GravityGradientModel.h"
35#include "models/support/LvlhFrameManagerModel.h"
36#include "models/actuators/TimedImpulsiveBurnModel.h"
37
38namespace modelspace {
39
40 /**
41 * @brief Simple Spacecraft Model
42 *
43 * The simple spacecraft model is a convenient wrapper around a simple model of a
44 * spacecraft acting under the force of gravity. It includes a gravity model
45 * with J2 and J3 effects as well as gravity gradient moments and sensors to
46 * determine spacecraft state relative to its central planet.
47 *
48 * To configure spacecraft, users have two options:
49 * - They may call configFromPlanet to simply and quickly configure spacecraft
50 * from the planet model
51 * - They may manually configure each model in spacecraft by accessing them
52 * individually, e.g. spacecraft.gravityModel().params.mu(<value>)
53 */
54 class SimpleSpacecraft : public Model {
55 public:
56 // Model params
57 // NAME TYPE DEFAULT VALUE
59 /** The position of the spacecraft in the initialization frame, expressed in init frame */
61 /** The velocity of the spacecraft in the initialization frame, expressed in init frame */
63 /** The frame in which position and velocity are initialized. */
65 /** The attitude of the spacecraft relative to the initialization frame. */
67 /** The angular velocity of the spacecraft relative to the initialization frame, expressed
68 * in spacecraft body frame.*/
70 /** The frame in which attitude and angular velocity are initialized. */
72 /** The angular velocity of the planet rotating frame relative to the inertial frame.
73 * Defaults to Earth's rotation rate */
74 SIGNAL(planet_configuration, void*, nullptr)
75 /** Inertial frame of planet spacecraft is orbiting */
77 /** Rotating frame of planet spacecraft is orbiting */
80
81 // Model inputs
82 // NAME TYPE DEFAULT VALUE
84
86
87 // Model outputs
88 // NAME TYPE DEFAULT VALUE
90 /** Accessor to the inertial frame of the planet. Set to point to _planet_inertial in constructor. */
91 SIGNAL(body, FrameD*, nullptr)
92 /** Accessor to the rotating frame of the planet. Set to point to _planet_inertial in constructor. */
93 SIGNAL(lvlh, FrameD*, nullptr)
94 /** Position wrt planet centered inertial frame */
96 /** Velocity wrt planet centered inertial fraame */
98 /** Attitude quaternion wrt planet inertial frame */
99 SIGNAL(quat_sc_pci, QuaternionD, QuaternionD({1.0, 0.0, 0.0, 0.0}))
100 /** Angular velocity of the spacecraft wrt planet, output in body frame */
102 /** The latitude of the spacecraft wrt planet rotating frame, in radians */
103 SIGNAL(latitude_detic, double, 0.0)
104 /** The longitude of the spacecraft wrt the planet rotating frame, in radians */
105 SIGNAL(longitude, double, 0.0)
106 /** The altitude of the spacecraft wrt planet ellipsoid */
107 SIGNAL(altitude_detic, double, 0.0)
109
110 SimpleSpacecraft(Model &pnt, const std::string &m_name="spacecraft");
111 SimpleSpacecraft(SimulationExecutive &e, const std::string &m_name="spacecraft");
112 ~SimpleSpacecraft();
113
114 /// @brief Function to get a handle to the frame state sensor relative to the planet inertial frame
115 /// @return Pointer to the planet inertial frame state sensor
116 modelspace::FrameStateSensorModel* planetInertialStateSensor() {return &_planet_inertial_state_sensor;}
117 /// @brief Function to get a handle to the frame state sensor relative to the planet rotating frame
118 /// @return Pointer to the planet rotating frame state sensor
119 modelspace::FrameStateSensorModel* planetRotatingStateSensor() {return &_planet_rotating_state_sensor;}
120 /// @brief Function to get a handle to the aspherical gravity model contained within this model
121 /// @return Pointer to the aspherical gravity model
122 modelspace::AsphericalGravityModel* gravityModel() {return &_gravity;}
123 /// @brief Function to get a handle to the planet relative state model contained within this model
124 /// @return Pointer to the planet relative state sensor model
125 modelspace::PlanetRelativeStatesModel* planetRelativeModel() {return &_planet_relative;}
126 /// @brief Function to get a handle to the gravity gradient model contained within this model
127 /// @return Pointer to the gravity gradient model
128 modelspace::GravityGradientModel* gravityGradientModel() {return &_gravity_gradient;}
129 protected:
130 int start();
131
132 /// @brief Function to internally map relationships between sensors
133 void _mapInternal();
134
135 /// @brief Initialize position and velocity of the spacecraft body frame
136 /// @param position_sc_frame__frame The desired position of the spacecraft body wrt frame_ptr
137 /// @param velocity_sc_frame__frame The desired velocity of the spacecraft body represented in frame frame_ptr
138 /// @param frame_ptr The frame relative to which state is initialized. Default (nullptr) will init wrt sim root frame
139 /// @return Error code corresponding to success/failure
140 /// @note Overloaded to init via string or frame
141 int _initializePositionVelocity(CartesianVector3D position_sc_frame__frame,
142 CartesianVector3D velocity_sc_frame__frame,
143 FrameD* frame_ptr=nullptr);
144
145 /// @brief Initialize attitude and angular velocity of the spacecraft body frame
146 /// @param quat_sc_frame__frame The desired attitude of the spacecraft body wrt frame_ptr
147 /// @param ang_vel_sc_frame__sc The desired angular velocity of the spacecraft body wrt frame_ptr in the sc body frame
148 /// @param frame_ptr The frame relative to which state is initialized. Default (nullptr) will init wrt sim root frame
149 /// @return Error code corresponding to success/failure
150 /// @note Overloaded to init via string or frame
151 int _initializeAttitude(QuaternionD quat_sc_frame__frame,
152 CartesianVector3D ang_vel_sc_frame__sc,
153 FrameD* frame_ptr=nullptr);
154
155 // Spacecraft body and node for gravity application
156 BodyD _body;
157 NodeD _gravity_node;
158
159 // Models included within the Spacecraft class
160 FrameStateSensorModel _planet_inertial_state_sensor;
161 FrameStateSensorModel _planet_rotating_state_sensor;
162 LvlhFrameManagerModel _lvlh_frame_manager;
163 AsphericalGravityModel _gravity;
164 GravityGradientModel _gravity_gradient;
165 PlanetRelativeStatesModel _planet_relative;
166 };
167
168}
169
170#endif
DataIO(GraphTreeObject *data_parent, std::string data_name, T initial_value)
Constructor for the DataIO object.
Definition DataIO.hpp:134
Aspherical gravity model with J2 and J3 effects.
Definition AsphericalGravityModel.h:45
Frame state sensor model.
Definition FrameStateSensorModel.h:45
Gravity Gradient Model.
Definition GravityGradientModel.h:49
LVLV Frame Manager Model.
Definition LvlhFrameManagerModel.h:51
Base model class for derived implementation.
Definition Model.h:56
Planet relative states model.
Definition PlanetRelativeStatesModel.h:52
Simple Spacecraft Model.
Definition SimpleSpacecraft.h:54
void _mapInternal()
Function to internally map relationships between sensors.
Definition SimpleSpacecraft.cpp:64
int _initializePositionVelocity(clockwerk::CartesianVector< double, 3 > position_sc_frame__frame, clockwerk::CartesianVector< double, 3 > velocity_sc_frame__frame, clockwerk::Frame< double > *frame_ptr=nullptr)
Initialize position and velocity of the spacecraft body frame.
Definition SimpleSpacecraft.cpp:126
int start()
Function to perform task startup activities (step once after creation)
Definition SimpleSpacecraft.cpp:196
modelspace::GravityGradientModel * gravityGradientModel()
Function to get a handle to the gravity gradient model contained within this model.
Definition SimpleSpacecraft.h:128
modelspace::AsphericalGravityModel * gravityModel()
Function to get a handle to the aspherical gravity model contained within this model.
Definition SimpleSpacecraft.h:122
modelspace::FrameStateSensorModel * planetInertialStateSensor()
Function to get a handle to the frame state sensor relative to the planet inertial frame.
Definition SimpleSpacecraft.h:116
modelspace::PlanetRelativeStatesModel * planetRelativeModel()
Function to get a handle to the planet relative state model contained within this model.
Definition SimpleSpacecraft.h:125
modelspace::FrameStateSensorModel * planetRotatingStateSensor()
Function to get a handle to the frame state sensor relative to the planet rotating frame.
Definition SimpleSpacecraft.h:119
int _initializeAttitude(clockwerk::Quaternion< double > quat_sc_frame__frame, clockwerk::CartesianVector< double, 3 > ang_vel_sc_frame__sc, clockwerk::Frame< double > *frame_ptr=nullptr)
Initialize attitude and angular velocity of the spacecraft body frame.
Definition SimpleSpacecraft.cpp:167
Implementation of the executive class for simulation.
Definition SimulationExecutive.h:63
#define SIGNAL(NAME, TYPE, INITIAL_VALUE)
Definition macros.h:87
#define BodyD
Definition macros.h:66
#define START_PARAMS
Definition macros.h:96
#define CartesianVector3D
Definition macros.h:54
#define END_OUTPUTS
Definition macros.h:90
#define END_PARAMS
Definition macros.h:98
#define NodeD
Definition macros.h:68
#define QuaternionD
Definition macros.h:78
#define START_OUTPUTS
Definition macros.h:88
#define FrameD
Definition macros.h:64
#define END_INPUTS
Definition macros.h:94
#define START_INPUTS
Definition macros.h:92
Class to propagate CR3BP dynamics in characteristic units.
Definition ConfigurationWriter.cpp:18
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > vel_sc_pci
Definition SimpleSpacecraft.h:97
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > pos_sc_pci
Definition SimpleSpacecraft.h:95
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > ang_vel_sc_pci__body
Definition SimpleSpacecraft.h:101
clockwerk::DataIO< double > altitude_detic
Definition SimpleSpacecraft.h:107
clockwerk::DataIO< clockwerk::Quaternion< double > > quat_sc_pci
Definition SimpleSpacecraft.h:99
clockwerk::DataIO< clockwerk::Frame< double > * > lvlh
Definition SimpleSpacecraft.h:93
clockwerk::DataIO< double > longitude
Definition SimpleSpacecraft.h:105
clockwerk::DataIO< double > latitude_detic
Definition SimpleSpacecraft.h:103
clockwerk::DataIO< clockwerk::Frame< double > * > body
Definition SimpleSpacecraft.h:91
clockwerk::DataIO< void * > planet_configuration
Definition SimpleSpacecraft.h:74
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > initial_velocity
Definition SimpleSpacecraft.h:62
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > initial_position
Definition SimpleSpacecraft.h:60
clockwerk::DataIO< clockwerk::Frame< double > * > pos_vel_init_frame
Definition SimpleSpacecraft.h:64
clockwerk::DataIO< clockwerk::Quaternion< double > > initial_attitude
Definition SimpleSpacecraft.h:66
clockwerk::DataIO< clockwerk::Frame< double > * > planet_inertial_frame
Definition SimpleSpacecraft.h:76
clockwerk::DataIO< clockwerk::Frame< double > * > att_init_frame
Definition SimpleSpacecraft.h:71
clockwerk::DataIO< clockwerk::Frame< double > * > planet_rotating_frame
Definition SimpleSpacecraft.h:78
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > initial_ang_vel
Definition SimpleSpacecraft.h:69