45 }
else if (u1 > 0.0) {
50 }
else if (d == 0.0) {
52 }
else if (d == 1.0) {
58 }
else if (u1 == 2.0) {
60 }
else if ((u1 == 0.5) && (u0 >= 0.0)) {
62 }
else if ((u0 < 0.0) && (u1 > floor(u1))) {
106 double pressure_current;
107 double temperature_current;
110 double x_dot_predicted;
112 double y_dot_current;
113 test_delta = (dep_max + dep_min) / 2.0;
116 temperature_current = temperature;
117 pressure_current = pressure;
122 while (y_dot_current > 0.0) {
123 double speed_of_sound;
126 if (elapsed_time > 0.1) {
127 opt_dep = test_delta - delta;
128 if (fabs(opt_dep) > max_change) {
131 }
else if (opt_dep < 0.0) {
134 opt_dep = (opt_dep > 0.0);
136 delta += opt_dep * max_change;
141 speed_of_sound = sqrt(401.79999999999995 * temperature_current);
142 pressure_current = 0.5 *
143 (pressure_current / (287.0 * temperature_current)) *
144 0.014102609421964583;
147 v_current / speed_of_sound);
148 x_dotdot = -opt_dep * x_dot_predicted * v_current / 23.458000008756152;
150 -opt_dep * y_dot_current * v_current / 23.458000008756152 - 9.81;
152 temperature_current = y_dot_current + y_dotdot *
sim_time_step;
154 sqrt(opt_dep * opt_dep + temperature_current * temperature_current);
157 v_current / speed_of_sound);
158 x_dot_predicted += 0.5 *
159 (x_dotdot + -opt_dep * x_dot_predicted * v_current /
160 23.458000008756152) *
163 y_dot_current + 0.5 *
164 (y_dotdot + (-opt_dep * y_dot_current *
165 v_current / 23.458000008756152 -
168 y_current += 0.5 * (y_dot_current + opt_dep) *
sim_time_step;
169 y_dot_current = opt_dep;
170 v_current = sqrt(x_dot_predicted * x_dot_predicted + opt_dep * opt_dep);
171 temperature_current = temperature - 0.00649 * (y_current -
altitude);
173 pressure *
rt_powd_snf(temperature_current / temperature, 5.2561);
177 dep_min = test_delta;
179 dep_max = test_delta;
182 return 180 - ((dep_min + dep_max) / 2.0);
double cdEvaluation(const double dep_states[6], const double mach_states[5], const double cd_table[30], double dep, double mach)
Estimates the coefficient of drag (Cd) via 2D bilinear interpolation.
Performs 2D bilinear interpolation to estimate the coefficient of drag (Cd).
boolean_T rtIsInf(real_T value)
Checks if a double-precision value is positive or negative infinity.
boolean_T rtIsNaN(real_T value)
Checks if a double-precision value is Not-a-Number (NaN).
real_T rtInf
Global constant for positive infinity (double precision).
real_T rtNaN
Global constant for Not-a-Number (double precision).
const double mach_states[]
const double deployment_states[]
double optimalAngle(double sim_time_step, double altitude, double temperature, double velocity, double pressure, double current_delta, double tilt_angle, double target_apogee, double tolerance, const double mach_states[5], const double deployment_states[6], const double cd_table[30])
Calculates the optimal constant airbrake angle to reach a target apogee.
static double rt_powd_snf(double u0, double u1)
Model Predictive Controller (MPC) to determine the optimal airbrake angle.
Provides definitions and utility functions for non-finite floating-point values.