ModelSpace
All Classes Namespaces Functions Variables Enumerations Pages
SimpleThrusterModel.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/*
17Simple thruster model header file
18
19Author: Alex Reynolds
20*/
21
22#ifndef MODELS_ACTUATORS_SIMPLE_THRUSTER_MODEL_H
23#define MODELS_ACTUATORS_SIMPLE_THRUSTER_MODEL_H
24
25#include "core/macros.h"
26#include "simulation/Model.h"
27#include "core/CartesianVector.hpp"
28#include "six_dof_dynamics/Body.hpp"
29#include "six_dof_dynamics/Node.hpp"
30#include "models/support/BiasNoiseModel.h"
31#include "utils/planetdefaults.h"
32
33namespace modelspace {
34
35 const double ON_STATE = 1e-15; // Mdot threshold below which thruster is considered "off"
36
37 enum cmds_e {
38 OFF,
39 ON
40 };
41
42 /**
43 * @brief Simple thruster model
44 *
45 * This is a simple model of a thruster which applies a thrust force according
46 * to mass flow and the specific impulse of the thruster. Force is applied to
47 * a node attached to the referenced body frame. The force applied by the
48 * thruster will produce a force and moment to the body as determined by the
49 * ModelSpace dynamics.
50 *
51 * Noise is applied as a gaussian noise which is updated every time the thruster
52 * command toggles from off to on.
53 *
54 * @author Alex Reynolds <alex.reynolds@attx.tech>
55 */
56 class SimpleThrusterModel : public Model {
57 public:
58 // Model params
59 // NAME TYPE DEFAULT VALUE
61 /** The body which will be controlled by this model. The thruster force will be applied to a
62 * node aligned to this body, and ModelSpace will translate to force and torque at the body */
63 SIGNAL(control_body, BodyD*, nullptr)
64 /** The thruster location relative to the provided body in the body frame*/
66 /** The thruster pointing vector in the body frame. This vector is the PLUME DIRECTION, so
67 * the actual force applied by the thruster is in the opposite direction of this vector. */
69 /** The bias in the thruster which is applied to every firing. */
70 SIGNAL(thrust_bias, double, 0.0)
71 /** The standard deviation of thruster noise which is applied firing to firing. A new noise
72 * draw is taken every time command toggles off to on. */
73 SIGNAL(thrust_noise_std, double, 0.0)
74 /** The Earth gravity in the units system of choice for the thruster (used in Isp calculation). Default is Metric.*/
75 SIGNAL(g, double, clockwerk::earth_wgs84.mean_gravity)
76 /** Value to seed the internal RNG for this model. */
77 SIGNAL(seed_value, int, 0)
79
80 // Model inputs
81 // NAME TYPE DEFAULT VALUE
83 /** The mass flow rate through the thruster at the current time. */
84 SIGNAL(mdot, double, 0.0)
85 /** The specific impulse of the thruster at the current time. */
86 SIGNAL(Isp, double, 0.0)
88
89 // Model outputs
90 // NAME TYPE DEFAULT VALUE
92 /** The thrust applied by the thruster at its location on the spacecraft body */
93 SIGNAL(applied_thrust, double, 0.0)
94 /** The force applied by the thruster as a vector value in the body frame.
95 * This is an informational output. Force is automatically applied to the node. */
98
99 // Model-specific implementations of startup and derivative
100 SimpleThrusterModel();
101 SimpleThrusterModel(Model &pnt, const std::string &m_name="simple_thruster");
102 SimpleThrusterModel(SimulationExecutive &e, const std::string &m_name="simple_thruster");
103 SimpleThrusterModel(Model &pnt, int schedule_slot, const std::string &m_name="simple_thruster");
104 SimpleThrusterModel(SimulationExecutive &e, int schedule_slot, const std::string &m_name="simple_thruster");
105 ~SimpleThrusterModel() {}
106
107 // Getters for handles to respective frames
108 // TODO: Fix this to not be needed because these can all be public. Until then it's here
109 clockwerk::DataIO<NodeD*> thrusterNode = clockwerk::DataIO<NodeD*>(this, "thrusterNode", &_thruster_node);
110 protected:
111 int start();
112 int execute();
113
114 /// @brief The bias and noise model for thrust output.
116
117 /// @brief The node at which thrust is applied.
119
120 /// @brief Our nominal thrust calculation from Isp and the like.
121 double _nominal_thrust = 0.0;
122
123 /// @brief Value to hold perturbation to thrust
124 double _thrust_perturbation = 0.0;
125
126 /// @brief Value to hold total thrust calculation
127 double _total_thrust = 0.0;
128
129 /// @brief Value to hold last thrust command
130 int _cmd_state = OFF;
131 int _prev_cmd = OFF;
132 };
133
134}
135
136#endif
Class for inter-object communication.
Definition DataIO.hpp:46
DataIO(GraphTreeObject *data_parent, std::string data_name, T initial_value)
Constructor for the DataIO object.
Definition DataIO.hpp:134
Bias and noise model.
Definition BiasNoiseModel.h:39
Base model class for derived implementation.
Definition Model.h:56
Simple thruster model.
Definition SimpleThrusterModel.h:56
double _thrust_perturbation
Value to hold perturbation to thrust.
Definition SimpleThrusterModel.h:124
int start()
Function to perform task startup activities (step once after creation)
Definition SimpleThrusterModel.cpp:46
BiasNoiseModel _thruster_bias_noise
The bias and noise model for thrust output.
Definition SimpleThrusterModel.h:115
double _nominal_thrust
Our nominal thrust calculation from Isp and the like.
Definition SimpleThrusterModel.h:121
int _cmd_state
Value to hold last thrust command.
Definition SimpleThrusterModel.h:130
int execute()
Function to execute the task. All math and calculations should be here.
Definition SimpleThrusterModel.cpp:73
double _total_thrust
Value to hold total thrust calculation.
Definition SimpleThrusterModel.h:127
clockwerk::Node< double > _thruster_node
The node at which thrust is applied.
Definition SimpleThrusterModel.h:118
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 START_OUTPUTS
Definition macros.h:88
#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< double > Isp
Definition SimpleThrusterModel.h:86
clockwerk::DataIO< double > mdot
Definition SimpleThrusterModel.h:84
clockwerk::DataIO< double > applied_thrust
Definition SimpleThrusterModel.h:93
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > applied_force__body
Definition SimpleThrusterModel.h:96
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > thruster_location__body
Definition SimpleThrusterModel.h:65
clockwerk::DataIO< double > thrust_noise_std
Definition SimpleThrusterModel.h:73
clockwerk::DataIO< clockwerk::Body< double > * > control_body
Definition SimpleThrusterModel.h:63
clockwerk::DataIO< double > g
Definition SimpleThrusterModel.h:75
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > thruster_pointing__body
Definition SimpleThrusterModel.h:68
clockwerk::DataIO< double > thrust_bias
Definition SimpleThrusterModel.h:70
clockwerk::DataIO< int > seed_value
Definition SimpleThrusterModel.h:77