Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions models/fhw/effectors/rcs_generic/include/rcs_build_trail.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,31 @@ PROGRAMMERS:
#ifndef CML_RCS_BUILD_TRAIL_HH
#define CML_RCS_BUILD_TRAIL_HH

#include "rcs_scale_factor_interface.hh"

/*****************************************************************************
RcsBuildUpTrailOffJetData
Purpose:(Jet-specific data for RcsBuildUpTrailOff)
*****************************************************************************/
class RcsBuildUpTrailOffJetData
{
public:
double rise_time{0.0}; /* (s) Rise time */
double decay_time{0.0}; /* (s) Decay time */
double decay_time_abort{0.0}; /* (s) Decay time when post LAS abort */
double tf_build_up{1.0}; /* (--) Thrust factor from the build-up model */
double tf_trail_off{1.0}; /* (--) Thrust factor from the trail-off model */
double rise_time; /* (s) Rise time */
double decay_time; /* (s) Decay time */
double decay_time_abort; /* (s) Decay time when post LAS abort */
double tf_build_up; /* (--) Thrust factor from the build-up model */
double tf_trail_off; /* (--) Thrust factor from the trail-off model */

RcsBuildUpTrailOffJetData() = default;
RcsBuildUpTrailOffJetData()
:
rise_time(0.0),
decay_time(0.0),
decay_time_abort(0.0),
tf_build_up(1.0),
tf_trail_off(1.0)
{}
};

#include "rcs_scale_factor_interface.hh"

/*****************************************************************************
RcsBuildUpTrailOff
Purpose:(Models RCS jets' build-up to full thrust and trail-off to zero thrust)
Expand All @@ -48,14 +55,16 @@ class RcsBuildUpTrailOff
const double & current_time; /* (s) Current time */

public:
bool active{false}; /* (--) Flag to enable the build-up/trail-off model */
bool active; /* (--) Flag to enable the build-up/trail-off model */

RcsBuildUpTrailOff( RcsScaleFactorInterface& interface_,
RcsBuildUpTrailOffJetData * const jet_,
const double& time);
RcsBuildUpTrailOff & operator = ( const RcsBuildUpTrailOff &) = delete;
RcsBuildUpTrailOff( const RcsBuildUpTrailOff &) = delete;
virtual ~RcsBuildUpTrailOff() = default;
virtual void build_up_trail_off_effects();

private:
RcsBuildUpTrailOff & operator = ( const RcsBuildUpTrailOff &);
RcsBuildUpTrailOff( const RcsBuildUpTrailOff &);
};
#endif
#endif
60 changes: 32 additions & 28 deletions models/fhw/effectors/rcs_generic/include/rcs_generic.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ PROGRAMMERS:
#ifndef CML_RCS_GENERIC_HH
#define CML_RCS_GENERIC_HH

#include <cstddef>
#include <vector>
#include <random>
#include "cml/models/utilities/cml_message/include/cml_message.hh"
#include "jeod/models/utils/math/include/vector3.hh"
#include "cml/models/utilities/subscriptions/include/subscriptions.hh"

// Forward declaration
Expand All @@ -42,7 +43,7 @@ Purpose:( The manager-level object for the overall RcsGeneric model)
*****************************************************************************/
class RcsGeneric : public SubscriptionBase {
protected:
const double * cm{nullptr}; /* (--)
const double * cm; /* (--)
pointer to the 3-array representing the position of center of mass
of the vehicle in the structural frame. */
const unsigned int num_propellant_components; /* (--)
Expand All @@ -67,23 +68,23 @@ class RcsGeneric : public SubscriptionBase {
std::vector<RcsJetGroup *> groups; /* (--) RCS jet groups */

/****** Inputs ******/
bool mult_jet_flag{false}; /* (--)
bool mult_jet_flag; /* (--)
Flag if multiple jet effects on thrust and flow rates are to be enabled.
SET AT INITIALIZATION ONLY. */
bool calc_flow_rate{false}; /* (--)
bool calc_flow_rate; /* (--)
Flag indicating whether flow rate should be calculated based on thrust,
specific impulse and mixture ratio. Can only be used with mono or
bi-propellants. Will result in an override of any default settings
for jet component-flow-rates. INITIALIZATION ONLY. */
public:
/****** Inputs ******/
bool self_impingement{false}; /* (--) Flag indicating whether impingement is on.*/
bool self_impingement; /* (--) Flag indicating whether impingement is on.*/

bool apply_thrust_factor_per_jet{false}; /* (--)
bool apply_thrust_factor_per_jet; /* (--)
On = per jet thrust factor is provided by external model or data.
System level setting passed through to all jets.*/

double imp_ref_center[3]{}; /* (m)
double imp_ref_center[3];/* (m)
Point in Vehicle Structural frame about which the impingement torques
are referenced.
Used at runtime and only if self_impingement set. */
Expand All @@ -92,15 +93,15 @@ class RcsGeneric : public SubscriptionBase {
mag_and_uvec = 1, // force magnitude and unit vector
vector = 2 // force vector
};
InputForce input_force{input_force_error}; /* (--)
InputForce input_force; /* (--)
Flag indicating method of user input for jet force */

double time_step{0.0}; /* (s)
double time_step; /* (s)
The cycle rate of the rcs_gen module.
Set here at initialization and subsequently accessed by RcsGroup,
RcsJet and RcsPropPod.*/

unsigned int seed{0}; /* (--) Seed for random number generator */
unsigned int seed; /* (--) Seed for random number generator */
std::mt19937 generator; /* (--)
Random number generator; using mt19937 rather than the default generator
to avoid the problem of correlation with low seeds on uniform
Expand All @@ -111,44 +112,47 @@ class RcsGeneric : public SubscriptionBase {
#endif

/****** Outputs ******/
double force[3]{}; /* (N) sum of the jet forces */
double torque[3]{}; /* (N*m) sum of the jet torques */
double total_imp_force[3]{}; /* (N) sum of the jet self impingement forces */
double total_imp_torque[3]{}; /* (N*m) sum of the self impingement jet torques */
double force[3]; /* (N) sum of the jet forces */
double torque[3]; /* (N*m) sum of the jet torques */
double total_imp_force[3]; /* (N) sum of the jet self impingement forces */
double total_imp_torque[3];/* (N*m) sum of the self impingement jet torques */
std::vector<double> sum_component_consumptions; /* (kg)
sum of the propellant component consumptions.
NOTE - this is public for the purposes of data-logging only.
It is considered read-only. In particular, the size of this vector
must not be changed.*/
double sum_consumption{0.0}; /* (kg) sum of the propellant consumptions */
double sum_time{0.0}; /* (s) sum of the jet on times */
size_t num_jets{0}; /* (count) number of jets at initialization (output only).*/
double sum_consumption; /* (kg) sum of the propellant consumptions */
double sum_time; /* (s) sum of the jet on times */
size_t num_jets; /* (count) number of jets at initialization (output only).*/

explicit RcsGeneric (const unsigned int num_propellant_components_);
~RcsGeneric() override = default;
RcsGeneric (const RcsGeneric& rhs) = delete;
RcsGeneric & operator = (const RcsGeneric& rhs) = delete;

virtual void initialize( double time_step_in,
virtual void initialize( double time_step,
const double * center_of_mass);
void update( const int * rcs_command);
void update( const bool * rcs_command);

const double * get_cm() const {return cm;}
bool get_calc_flow_rate() const {return calc_flow_rate;}
double get_prop_loss_on(unsigned int ii) const {return prop_loss_on.at(ii);}
double get_prop_loss_off(unsigned int ii) const {return prop_loss_off.at(ii);}
const double * get_cm() {return cm;}
bool get_calc_flow_rate() {return calc_flow_rate;}
double get_prop_loss_on(unsigned int ii) {return prop_loss_on.at(ii);}
double get_prop_loss_off(unsigned int ii) {return prop_loss_off.at(ii);}

void set_prop_loss_on( unsigned int ix, double value);
void set_prop_loss_off( unsigned int ix, double value);
void set_mult_jet_flag (bool new_value);
void set_calc_flow_rate(bool new_value);
void set_mult_jet_flag (bool mult_jet_flag);
void set_calc_flow_rate(bool calc_flow_rate);

protected:
void compute_force_and_fuel();
void apply_self_impingement();
bool update_part_I(const void * rcs_command);
bool update_part_I(const void *);
void update_part_II();
void check_mult_jet_flag_init();

private:
// Not implemented:
RcsGeneric (const RcsGeneric& rhs);
RcsGeneric & operator = (const RcsGeneric& rhs);
};
#endif
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef CML_RCS_GENERIC_CLASSES_HH
#define CML_RCS_GENERIC_CLASSES_HH

#include "rcs_generic.hh"
#include "rcs_prop_pod.hh"
#include "rcs_group.hh"
#include "rcs_jet.hh"

#endif
49 changes: 27 additions & 22 deletions models/fhw/effectors/rcs_generic/include/rcs_group.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,47 @@ PROGRAMMERS:
#define CML_RCS_GROUP_HH

#include <vector>
#include "cml/models/utilities/cml_message/include/cml_message.hh"
#include "cml/models/utilities/math_utils/include/math_utils.hh"

/*****************************************************************************
RcsGenericModel
Purpose:(Jet models)
*****************************************************************************/
class RcsJetGroup {
protected:
double consumption_epsilon{1.0e-12}; /* (--)
double consumption_epsilon; /* (--)
value for comparing consumption-ratio sum against the value 1.
The components should sum to 1 +/- consumption_epsilon. */
const unsigned int & num_prop_components; /* (--)
reference to the number of propulsion components as defined in
RcsGeneric.*/

bool blow_down{false} ; /* (--)
bool blow_down ; /* (--)
Flag indicating if the thruster blow down model should be used for
this module, Yes = use model */
public:
/****** Inputs ******/
// Control flags:
bool propc_use_isp{false}; /* (--)
bool propc_use_isp; /* (--)
Determines whether to use Isp or mass-flow for propellant consumption
calculations. */

// General inputs
double signal_delay_time{0.0}; /* (s) Delay time from command to start of actuation */
double on_dead_time{0.0}; /* (s)
double signal_delay_time; /* (s) Delay time from command to start of actuation */
double on_dead_time; /* (s)
Time from when the jet's motor is activated until the thrust is seen.*/
double off_dead_time{0.0}; /* (s)
double off_dead_time; /* (s)
Time from when the jet's motor is activated until the thrust starts
to be reduced. */
double build_up_time{0.0}; /* (s) Time taken to build up to full thrust */
double trail_off_time{0.0}; /* (s) Time taken to trail off from full thrust */
double min_on_time{0.0}; /* (s) Min allowed time between command on and off */
double min_off_time{0.0}; /* (s)
double build_up_time; /* (s) Time taken to build up to full thrust */
double trail_off_time; /* (s) Time taken to trail off from full thrust */
double min_on_time; /* (s) Min allowed time between command on and off */
double min_off_time; /* (s)
Min allowed time between burn completion and new burn start */

// Specialized inputs, not always needed:
double mixture_ratio{0.0} ; /* (--)
double mixture_ratio ; /* (--)
(Ratio) of fuel to oxidizer: fuel/oxidizer.
Used when RcsGeneric::num_prop_comp = 2 AND
RcsGeneric::calc_flow_rate = true AND
Expand All @@ -76,29 +78,32 @@ class RcsJetGroup {
std::vector<double> bd_isp_coef; /* (--)
coefficients for blowdown isp calc.
Used only when blow_down set */
double bd_pressure_limit{0.0}; /* (N/m2)
double bd_pressure_limit; /* (N/m2)
limit below which blowdown jets stop functioning.
Used only when blow_down set */

/****** Work space ******/
bool buffer_flag{false} ; /* (--) Flag if buffering of commands is required */
unsigned int buffer_on_size{0} ; /* (--) buffer size for on commands */
unsigned int buffer_off_size{0}; /* (--) buffer size for off commands */
double delay_time_on{0.0}; /* (s)
bool buffer_flag ; /* (--) Flag if buffering of commands is required */
unsigned int buffer_on_size ; /* (--) buffer size for on commands */
unsigned int buffer_off_size; /* (--) buffer size for off commands */
double delay_time_on; /* (s)
The delay into an rcs cycle before a command is executed = Modulus of
total_on_delay / cycle time, note this is NOT a user input */
double delay_time_off{0.0}; /* (s)
double delay_time_off; /* (s)
The delay into an rcs cycle before a command off is executed = Modulus
of total_off_delay / cycle time, note this is NOT a user input */


explicit RcsJetGroup( const unsigned int & num_prop_components_);
RcsJetGroup (const RcsJetGroup& rhs) = delete;
RcsJetGroup & operator = (const RcsJetGroup& rhs) = delete;
explicit RcsJetGroup( const unsigned int & num_prop_components);
void initialize (double time_step);
void set_blow_down( bool blow_down_);
bool get_blow_down() const {return blow_down;}
unsigned int get_num_prop_components() const {return num_prop_components;}
bool get_blow_down() {return blow_down;}
unsigned int get_num_prop_components() {return num_prop_components;}

private:
// Not implemented:
RcsJetGroup (const RcsJetGroup& rhs);
RcsJetGroup & operator = (const RcsJetGroup& rhs);
};

#endif
Loading
Loading