34#include "generated/airframe.h"
35#include "generated/flight_plan.h"
40#ifndef FIXEDWING_FIRMWARE
41#error "The module nps_fdm_fixedwing_sim is a basic flight model for fixedwing only"
44#ifndef ROLL_RESPONSE_FACTOR
45#define ROLL_RESPONSE_FACTOR 15.
48#ifndef PITCH_RESPONSE_FACTOR
49#define PITCH_RESPONSE_FACTOR 1.
52#ifndef YAW_RESPONSE_FACTOR
53#define YAW_RESPONSE_FACTOR 1.
60#ifndef ROLL_MAX_SETPOINT
61#define ROLL_MAX_SETPOINT RadOfDeg(40.)
64#ifndef ROLL_RATE_MAX_SETPOINT
65#define ROLL_RATE_MAX_SETPOINT RadOfDeg(15.)
68#ifndef NOMINAL_AIRSPEED
69#error "Please define NOMINAL_AIRSPEED in your airframe file"
72#ifndef MAXIMUM_AIRSPEED
73#define MAXIMUM_AIRSPEED (NOMINAL_AIRSPEED * 1.5)
77#define MAXIMUM_POWER (5. * MAXIMUM_AIRSPEED * WEIGHT)
80#ifndef AUTO_THROTTLE_NOMINAL_CRUISE_THROTTLE
81#define AUTO_THROTTLE_NOMINAL_CRUISE_THROTTLE 0.45
120 fdm.total_pressure = -1;
121 fdm.dynamic_pressure = -1;
122 fdm.temperature = -1;
124 fdm.ltpprz_to_body_eulers.phi = 0.0;
125 fdm.ltpprz_to_body_eulers.theta = 0.0;
126 fdm.ltpprz_to_body_eulers.psi = 0.0;
169 static bool already_launched =
false;
170 if (launch && !already_launched) {
172 already_launched =
true;
180 double vn2 = NOMINAL_AIRSPEED * NOMINAL_AIRSPEED;
183 double c_l = 4e-5 *
sim_state.delta_roll;
198 double c_m = 5e-7 *
sim_state.delta_pitch;
211 double lift = c_z *
v2;
245 fdm.hmsl = -
fdm.ltpprz_pos.z + NAV_ALT0 / 1000.;
246 fdm.agl = -
fdm.ltpprz_pos.z;
268 llh_nav0.
lat = RadOfDeg((
double)NAV_LAT0 / 1e7);
269 llh_nav0.
lon = RadOfDeg((
double)NAV_LON0 / 1e7);
270 llh_nav0.
alt = (double)(NAV_ALT0) / 1000.0;
277 fdm.ecef_pos = ecef_nav0;
307 int turbulence_severity __attribute__((unused)))
312 double h __attribute__((unused)))
static void h(const real32_T x[7], const real32_T q[4], real32_T y[6])
void double_quat_of_eulers(struct DoubleQuat *q, struct DoubleEulers *e)
#define VECT3_ASSIGN(_a, _x, _y, _z)
#define EULERS_ASSIGN(_e, _phi, _theta, _psi)
double alt
in meters above WGS84 reference ellipsoid
void ltp_def_from_ecef_d(struct LtpDef_d *def, struct EcefCoor_d *ecef)
void ecef_of_enu_vect_d(struct EcefCoor_d *ecef, struct LtpDef_d *def, struct EnuCoor_d *enu)
void ned_of_ecef_vect_d(struct NedCoor_d *ned, struct LtpDef_d *def, struct EcefCoor_d *ecef)
void lla_of_ecef_d(struct LlaCoor_d *lla, struct EcefCoor_d *ecef)
void ned_of_ecef_point_d(struct NedCoor_d *ned, struct LtpDef_d *def, struct EcefCoor_d *ecef)
void ecef_of_lla_d(struct EcefCoor_d *ecef, struct LlaCoor_d *lla)
void ecef_of_enu_point_d(struct EcefCoor_d *ecef, struct LtpDef_d *def, struct EnuCoor_d *enu)
vector in EarthCenteredEarthFixed coordinates
vector in East North Up coordinates Units: meters
vector in Latitude, Longitude and Altitude
definition of the local (flat earth) coordinate system
#define PPRZ_ISA_GRAVITY
earth-surface gravitational acceleration in m/s^2
#define PPRZ_ISA_SEA_LEVEL_PRESSURE
ISA sea level standard atmospheric pressure in Pascal.
struct NpsFdm fdm
Holds all necessary NPS FDM state information.
void nps_fdm_set_wind_ned(double wind_north, double wind_east, double wind_down)
void nps_fdm_init(double dt)
NPS FDM rover init.
static void init_ltp(void)
struct DoubleEulers rates
void nps_fdm_run_step(bool launch, double *commands, int commands_nb)
Minimum complexity flight dynamic model In legacy Paparazzi simulator, was implemented in OCaml and c...
#define ROLL_RATE_MAX_SETPOINT
#define AUTO_THROTTLE_NOMINAL_CRUISE_THROTTLE
static struct fixedwing_sim_state sim_state
void nps_fdm_set_temperature(double temp, double h)
Set temperature in degrees Celcius at given height h above MSL.
#define ROLL_MAX_SETPOINT
struct DoubleEulers attitude
#define ROLL_RESPONSE_FACTOR
void nps_fdm_set_turbulence(double wind_speed, int turbulence_severity)
#define YAW_RESPONSE_FACTOR
void nps_fdm_set_wind(double speed, double dir)
void nps_fdm_run_init_step(void)
#define PITCH_RESPONSE_FACTOR
static struct LtpDef_d ltpdef
Paparazzi generic algebra macros.
Paparazzi floating point algebra.
Paparazzi generic macros for geodetic calculations.
Paparazzi double-precision floating point math for geodetic calculations.
Paparazzi floating point math for geodetic calculations.
Paparazzi atmospheric pressure conversion utilities.
static const ShellCommand commands[]
API to get/set the generic vehicle states.