• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nasa / cml / 29777181804

20 Jul 2026 08:41PM UTC coverage: 85.517% (+0.2%) from 85.284%
29777181804

Pull #51

github

web-flow
Merge 9177babb3 into 783b48963
Pull Request #51: Fix all compiler warnings and treat them as errors

7833 of 8923 branches covered (87.78%)

Branch coverage included in aggregate %.

310 of 539 new or added lines in 196 files covered. (57.51%)

6 existing lines in 6 files now uncovered.

17930 of 21203 relevant lines covered (84.56%)

110707.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/models/dynamics/state_initialize/state_initialize/include/state_initialize.hh
1
/*******************************************************************************
2

3
PURPOSE:
4
   (Provide the capability to initialize the state from a number of potential
5
   sources.  This class inherits from the JEOD jeod::BodyAction class and combines
6
   the capabilities of JEOD's DynBodyInitState with CML's ORBITAL_ELEMENTS,
7
   ORB_INIT, and ICOPT models, and CEV's Corr_State_Init_T and
8
   State_Init_Exec_T structures and the state_init_exec method.)
9

10
LIBRARY DEPENDENCIES:
11
   ((../src/state_initialize.cc)
12
   )
13

14
PROGRAMMERS:
15
   (((Gary Turner) (OSR) (September 2014) (New))
16
 ******************************************************************************/
17

18
#ifndef CML_STATE_INITIALIZE_HH
19
#define CML_STATE_INITIALIZE_HH
20

21
#include <string>
22

23
#include "jeod/models/dynamics/body_action/include/dyn_body_init.hh"
24
#include "jeod/models/dynamics/body_action/include/dyn_body_init_trans_state.hh"
25
#include "jeod/models/dynamics/body_action/include/dyn_body_init_rot_state.hh"
26
#include "jeod/models/dynamics/body_action/include/dyn_body_init_orbit.hh"
27
#include "jeod/models/dynamics/body_action/include/dyn_body_init_ned_rot_state.hh"
28
#include "jeod/models/dynamics/dyn_manager/include/dyn_manager.hh"
29
#include "jeod/models/environment/planet/include/planet.hh"
30
#include "jeod/models/utils/planet_fixed/north_east_down/include/north_east_down.hh"
31
#include "jeod/models/utils/orientation/include/orientation.hh"
32
#include "cml/models/utilities/cml_message/include/cml_message.hh"
33

34
#include "cml/models/utilities/math_utils/include/math_utils.hh" // MathUtils::*
35
#include "cml/models/dynamics/state_initialize/correlated_state_dispersion/include/correlated_state_dispersion.hh"
36
#include "cml/models/dynamics/state_initialize/target_relative_parameters/include/TR_state_parameters.hh"
37
#include "cml/models/utilities/cml_message/include/cml_message.hh"
38

39
#include "monte_carlo_state_dispersion.hh"
40

41
class StateInitialize : public jeod::DynBodyInit
42
{
43
 public:
44
  enum InputDataType {
45
    Unspecified,
46
    Inertial,
47
    Pfix,
48
    ICOPT_R_INERTIAL,
49
    ICOPT_V_INERTIAL,
50
    NED_Geodetic,
51
    GEOD_LAT_LON_ALT,        // deprecated
52
    NED_Geocentric,
53
    InertialSpeedGammaAzimuth,
54
    ICOPT_INERT_VEL_GAM_AZ,  // deprecated
55
    PfixSpeedGammaAzimuth,
56
    ICOPT_REL_VEL_GAM_AZ,    // deprecated
57
    OrbitalElements,
58
    EulerInertialVelvec_YPR,
59
    EulerPfixVelvec_YPR,     // deprecated
60
    SunPointing_YPR,
61
    SunPointingEcliptic_PYR,
62
    PfixUpCompAzimuth,       // deprecated
63
    PfixUpCompAzimuth_YPR,
64
    EulerNED_YPR,
65
    EulerBoostRef_YPR,
66
    ICOPT_EUL_YPR_BR,        // deprecated
67
    EulerPlumbline_PYR,
68
    ICOPT_EUL_PYR_PL,        // deprecated
69
    EulerFreestream_RYP,
70
    ICOPT_EUL_RYP_FS,        // deprecated
71
    MatrixInertialBody,
72
    ICOPT_INERT_BODY_ROTMAT, // deprecated
73
    EulerInertial_YPR,
74
    ICOPT_EUL_YPR_INERT_BODY,// deprecated
75
    BodyInertialRate,
76
    BodyPfixRate,
77
    Random,
78
    Off,
79
    TransInit,
80
    RotInit,
81
    RotInit_NED,
82
    TR_GeodAlt_RngAng_RotAng,
83
    TR_GeodAlt_RngAng_CrossAng_AbsRotAng_LT_90,
84
    TR_GeodAlt_RngAng_CrossAng_AbsRotAng_GT_90,
85
    TR_InertialSpeedGammaLatang
86
  };
87

88
  enum RotInitTransformSource {
89
    // RITS is an abbreviation of RotInitTransformSource
90
    RITS_None,
91
    RITS_Inertial,
92
    RITS_VelPos,
93
    RITS_PfixRef,
94
    RITS_SolarPosPos,
95
    RITS_SolarPosEclipticPole
96
  };
97

98
  InputDataType position_input_data_type; /* (--) enumeration for position */
99
  InputDataType velocity_input_data_type; /* (--) enumeration for velocity */
100
  InputDataType attitude_input_data_type; /* (--) enumeration for attitude */
101
  InputDataType att_rate_input_data_type; /* (--) enumeration for att rate */
102

103
  jeod::DynBodyInitOrbit         orb_elem_init; /* (--) orbital element initializer */
104
  jeod::DynBodyInitTransState    trans_init; /* (--) translational state initializer */
105
  jeod::DynBodyInitRotState      rot_init;   /* (--) rotational state initializer */
106
  jeod::DynBodyInitNedRotState   ned_rot_init; /* (--) rot state off trans state */
107

108
  CorrelatedStateDispersion  correlation; /* (--) correlated state disperser */
109
  MonteCarloStateDispersion  monte_carlo_dispersion; /* (--)
110
        random state disperser */
111

112
  // Input / Output
113
  TargetRelative_StateParameter TR_param; /* (--)
114
         Instance of model responsible for  converting between position/velocity
115
         and the TargetRelative parameter set.  Included as a class instance
116
         to facilitate population of target location parameters, which are
117
         class members.*/
118

119
  // Input values:
120
  std::string planet_name; /* (--) Name of the planet (typically "Earth") */
121

122
  // Reference point definition for translational state initialization
123
  double ref_point_altitude;  /* (m) The altitude of the reference point. */
124
  double ref_point_latitude;  /* (rad) The latitude of the reference point. */
125
  double ref_point_longitude; /* (rad) The longitude of the reference point. */
126

127
  // Target relative parameters for position initialization */
128
  double TR_geodetic_altitude;/* (m)  Geodetic altitude of target relative
129
                                      position */
130
  double TR_theta_Rng; /* (rad)  Position range angle from target             */
131
  double TR_theta_Rot; /* (rad)  Position rotation angle about target vector  */
132
  double TR_phi_Cross; /* (rad)  Position cross angle                         */
133

134
  // Reference point definition for rotational state initialization
135
  double rot_ref_latitude; /* (rad) latitude for rotational state initialization*/
136
  double rot_ref_longitude;/* (rad) longitude for rotational state
137
                                  initialization */
138
  double rot_ref_azimuth;  /* (rad) azimuth for rotational state initialization */
139

140
  // Velocity definition for speed / flight-path / azimuth option
141
  double speed;          /* (m/s) for speed/flight-path/azimuth
142
                                  and speed/flight-path/lateral-angle
143
                                  velocity options */
144
  double flight_path_angle;/* (rad) for speed/flight-path/azimuth
145
                                  and speed/flight-path/lateral-angle
146
                                  velocity options */
147
  double azimuth;          /* (rad) for speed/flight-path/azimuth
148
                                  velocity options */
149
  double TR_Lambda;        /* (rad) for speed/flight-path/lateral angle
150
                                  velocity option */
151

152
  // Attitude definition for yaw / pitch / roll option
153
  double yaw;    /* (rad) for yaw / pitch / roll attitude init option */
154
  double roll;   /* (rad) for yaw / pitch / roll attitude init option */
155
  double pitch;  /* (rad) for yaw / pitch / roll attitude init option */
156

157
  // Attitude defintion for bank / sideslip / attack option
158
  double angle_of_bank;     /* (rad) bank angle     for EulerFreestream_RYP attitude option */
159
  double angle_of_sideslip; /* (rad) sideslip angle for EulerFreestream_RYP attitude option */
160
  double angle_of_attack;   /* (rad) attack angle   for EulerFreestream_RYP attitude option */
161

162
  // Attitude defintion for matrix option
163
  double T_inrtl_body[3][3]; /* (--) Direct transform inertial to body. */
164

165
  // Euler sequence override
166
  jeod::Orientation::EulerSequence ref_body_sequence_override; /* (--)
167
         The RPY/PRY etc sequence IF it is desirable to override the
168
         default settings for the specified attitude type.*/
169

170
  // Attitude rate defintion for roll / pitch / yaw option
171
  double roll_rate_body;  /* (rad/s)
172
         used for roll/pitch/yaw attitude rate init option */
173
  double pitch_rate_body; /* (rad/s)
174
         used for roll/pitch/yaw attitude rate init option */
175
  double yaw_rate_body;   /* (rad/s)
176
         used for roll/pitch/yaw attitude rate init option */
177

178
  // Attitude rate specifications for random state
179
  double max_rate_random;  /* (rad/s) Max attitude rate for random rate option */
180
  int att_random_seed;     /* (--) seed for the random attitude generator */
181
  int att_rate_random_seed;/* (--) seed for the random attitude-rate generator */
182

183

184
  // Computed values that may be set or need to be accessed from outside:
185
  double free_stream_velocity[3]; /* (m/s)
186
         The velocity of the vehicle relative to the free stream, expressed in
187
         the inertial frame.*/
188

189

190
 protected:
191
  bool initialized; /* (--) Model is initialized, planet is non-NULL. */
192
  jeod::Planet * planet; /* (--) Pointer to the planet that defines the pfix frame. */
193

194
  // Reference frame names
195
  std::string reference_ref_frame_name_inertial; /* (--)
196
      Inertial reference frame name. */
197
  std::string reference_ref_frame_name_pfix; /* (--)
198
      Planet-fixed reference frame name. */
199

200
  // Flags to indicate which state initializers are defined and to be used.
201
  bool use_orbital_init; /* (--) flag to use orb_elem_init */
202
  bool use_trans_init; /* (--) flag to use trans_init */
203
  bool use_rot_init; /* (--) flag to use rot_init */
204
  bool use_ned_rot_init; /* (--) flag to use ned_rot_init */
205
  bool use_trans_init_passthrough; /* (--)
206
               flag to use trans_init without input from this model.*/
207
  bool use_rot_init_passthrough; /* (--)
208
               flag to use rot_init without input from this model.*/
209
  bool use_pfix_frame_trans; /* (--)
210
               flag to use initialize trans state using pfix frame instead of inertial.*/
211

212
  // Flags to indicate procedural completions
213
  bool pfix_ref_point_state_generated; /* (--)
214
          The pfix-cartesian representation of the reference point is
215
          available. */
216

217
  bool use_veh_position_as_reference; /* (--)
218
          For cases in which the velocity is defined relative to the NED frame
219
          associated with the vehicle position.*/
220

221
  bool populate_trans_init_pos_from_pfix; /* (--)
222
          The position may be initialized relative to some position that is
223
          defined in pfix.  pfix must be defined and computed in order to get
224
          the position in inertial, which is needed before the body action
225
          can be applied. So wait for the apply() method before populating
226
          trans)_init.position*/
227

228
  bool populate_trans_init_vel_from_pfix; /* (--)
229
          The velocity is initialized in pfix but pfix must be defined and
230
          computed in order to get the velocity in inertial, which is needed
231
          before the body action can be applied.*/
232

233
  bool velocity_is_relative_to_inertial; /* (--)
234
         Some init options provide an inertial-referenced velocity, and some
235
         provide a pfix/ned-referenced velocity.  This flag distinguishes the
236
         cases. */
237

238
  bool requires_free_stream_velocity; /* (--)
239
         For initializing the attitude relative to the free-stream.*/
240

241
  RotInitTransformSource populate_rot_init_transform_source; /* (--)
242
    Options set internally allowing apply() to branch appropriately to set the
243
    T_inertial->body transformation matrix.*/
244

245
  bool z_axis_points_up; /* (--) Used with VelPos and SolarPosPos to orient z */
246

247
  bool increment_rot_rate_init_with_pfix; /* (--)
248
         When attitude rate is specified wrt a pfix frame, the rate of the
249
         pfix frame needs adding.  Must be transformed to body frame first.*/
250

251

252
  // Derived states
253
  double pfix_position[3]; /* (m)
254
     Position vector expressed relative to the pfix frame. */
255
  double pfix_velocity[3]; /* (m/s)
256
     Velocity expressed in pfix frame.  May or may not be wrt pfix frame;
257
     see "velocity_is_relative_to_inertial" for associated specification
258
     of which frame the velocity is with respect to. */
259

260
  double omega_cross_r[3]; /* (m/s)
261
         difference between pfix-expressed and inertial-expressed velocity.
262
         May be expressed in either inertial or pfix depending on context.*/
263

264
  double T_pfix_reference[3][3]; /* (--)
265
         transform from pfix to some user-defined reference frame.*/
266
  double T_inrtl_reference[3][3]; /* (--)
267
         transform from inertial to some user-defined reference frame.*/
268
  double T_reference_body[3][3]; /* (--)
269
         transform from some user-defined reference frame to vehicle body
270
         frame.*/
271

272
  double E_pfix_reference[3]; /* (rad) Euler angles from pfix to reference frame */
273
  double E_reference_body[3]; /* (rad) Euler angles from reference frame to body */
274

275
  jeod::Orientation::EulerSequence ref_body_sequence; /* (--)
276
         The RPY/PRY etc sequence. */
277

278
  jeod::AltLatLongState pfix_ref_point; /* (--)
279
       the alt/lat/long of the reference point. */
280
  jeod::NorthEastDown   pfix_ref_point_state; /* (--)
281
       The NED state of the reference point */
282

283

284
  // Other useful values
285
  double random_value; /* (--)
286
       Simple random number. Class element for debugging */
287
  double random_unit_vector[3]; /* (--) a random unit vector */
288

289
  bool force_match_trans;   /* (--)
290
       The 0th and 1st derivative (pos/vel) are grouped together.
291
       Some initialization options require that companion state-set
292
       be initialized using the same option.*/
293
  bool force_match_rot;   /* (--)
294
       The 0th and 1st derivative (att/att-rate) are grouped together.
295
       Some initialization options require that companion state-set
296
       be initialized using the same option.*/
297

298
 public:
299
  StateInitialize();
NEW
300
  ~StateInitialize() override = default;
×
301

302
  void initialize(  jeod::DynManager & dyn_manager ) override;
303
  void apply(  jeod::DynManager & dyn_manager ) override;
304
  void overwrite_attitude_from_free_stream( double rel_wind_inrtl[3]);
305

306
 protected:
307
  void select_position_initializer();
308
  void select_velocity_initializer();
309
  void select_attitude_initializer();
310
  void select_att_rate_initializer();
311

312
  void generate_pfix_ref_point_state();
313
  void generate_pfix_position();
314
  void generate_pfix_velocity();
315
  void generate_pfix_velocity_from_veh_pos();
316
  void generate_rot_init_transform();
317
  void generate_inertial_velocity();
318
  void generate_random(int seed);
319
  void verify_compatibility();
320

321
  void generate_free_stream_velocity( double rel_wind_inrtl[3]);
322
  void remove_from_trans_init(  jeod::DynBodyInitTransState::StateItems item);
323
  void remove_from_rot_init(  jeod::DynBodyInitRotState::StateItems item);
324

325
  void generate_orbital_init_values(jeod::DynManager & dyn_manager);
326
  void generate_trans_init_values();
327
  void generate_rot_init_values(jeod::DynManager & dyn_manager);
328
  void apply_internal(jeod::DynManager & dyn_manager);
329

330
 private:
331
  // private and unimplemented makes this non-copyable
332
  StateInitialize (const StateInitialize &);
333
  StateInitialize & operator = (const StateInitialize &);
334
};
335
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc