Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
nps_fdm.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009 Antoine Drouin <poinix@gmail.com>
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
22 #ifndef NPS_FDM
23 #define NPS_FDM
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #include "std.h"
30 #include "../flight_gear.h"
33 
34 /*
35  Notations for fdm variables
36  ---------------------------
37  coordinate system [ frame ] name
38 
39  ecef_inertial_vel is the time derivative of position
40  with respect to inertial frame expressed in ECEF ( Earth Centered Earth Fixed)
41  coordinate system.
42 */
43 
44 struct NpsFdm {
45 
46  double time;
47  double init_dt;
48  double curr_dt;
49  bool on_ground;
50  int nan_count;
51 
52  /* position */
56  double hmsl;
57  // for debugging
58  struct LlaCoor_d lla_pos_pprz; //lla converted by pprz from ecef
59  struct LlaCoor_d lla_pos_geod; //geodetic lla from jsbsim
60  struct LlaCoor_d lla_pos_geoc; //geocentric lla from jsbsim
61  double agl; //AGL from jsbsim in m
62 
67 
69  struct DoubleVect3 body_ecef_vel; /* aka UVW */
72 
77 
82 
85 
88 
89  /* attitude */
95 
96  /* angular velocity and acceleration in body frame, wrt ECEF frame */
99 
100  /* angular velocity and acceleration in body frame, wrt inertial ECI frame */
103 
106 
107  struct DoubleVect3 wind;
108 
109  double airspeed;
110  double pressure;
111  double total_pressure;
113  double temperature;
114  double pressure_sl;
115  double aoa;
116  double sideslip;
117 
118  // Control surface positions (normalized values)
119  float elevator;
120  float flap;
123  float rudder;
124 
125  //engine state for first engine
127  uint32_t eng_state[FG_NET_FDM_MAX_ENGINES];// Engine state (off, cranking, running)
128  float rpm[FG_NET_FDM_MAX_ENGINES]; // Engine RPM rev/min
129 
130 };
131 
132 extern struct NpsFdm fdm;
133 
134 extern void nps_fdm_init(double dt);
135 extern void nps_fdm_run_step(bool launch, double *commands, int commands_nb);
136 extern void nps_fdm_set_wind(double speed, double dir);
137 extern void nps_fdm_set_wind_ned(double wind_north, double wind_east, double wind_down);
138 extern void nps_fdm_set_turbulence(double wind_speed, int turbulence_severity);
140 extern void nps_fdm_set_temperature(double temp, double h);
141 
142 #ifdef __cplusplus
143 } /* extern "C" */
144 #endif
145 
146 #endif /* NPS_FDM */
nps_fdm_run_step
void nps_fdm_run_step(bool launch, double *commands, int commands_nb)
Update the simulation state.
Definition: nps_fdm_crrcsim.c:150
DoubleQuat
Roation quaternion.
Definition: pprz_algebra_double.h:55
NpsFdm::ltp_h
struct DoubleVect3 ltp_h
Definition: nps_fdm.h:105
NpsFdm::eng_state
uint32_t eng_state[FG_NET_FDM_MAX_ENGINES]
Definition: nps_fdm.h:127
NpsFdm::left_aileron
float left_aileron
Definition: nps_fdm.h:121
NpsFdm::airspeed
double airspeed
equivalent airspeed in m/s
Definition: nps_fdm.h:109
NpsFdm::elevator
float elevator
Definition: nps_fdm.h:119
NpsFdm::num_engines
uint32_t num_engines
Definition: nps_fdm.h:126
NpsFdm::body_ecef_accel
struct DoubleVect3 body_ecef_accel
acceleration in body frame, wrt ECEF frame
Definition: nps_fdm.h:71
LlaCoor_d
vector in Latitude, Longitude and Altitude
Definition: pprz_geodetic_double.h:58
NpsFdm
Definition: nps_fdm.h:44
NpsFdm::right_aileron
float right_aileron
Definition: nps_fdm.h:122
h
static void h(const real32_T x[7], const real32_T q[4], real32_T y[6])
Definition: UKF_Wind_Estimator.c:821
FG_NET_FDM_MAX_ENGINES
#define FG_NET_FDM_MAX_ENGINES
Definition: flight_gear.h:113
NpsFdm::ltpprz_ecef_vel
struct NedCoor_d ltpprz_ecef_vel
velocity in ltppprz frame, wrt ECEF frame
Definition: nps_fdm.h:79
NpsFdm::wind
struct DoubleVect3 wind
velocity in m/s in NED
Definition: nps_fdm.h:107
NpsFdm::body_accel
struct DoubleVect3 body_accel
acceleration in body frame as measured by an accelerometer (incl.
Definition: nps_fdm.h:87
uint32_t
unsigned long uint32_t
Definition: types.h:18
NpsFdm::lla_pos_pprz
struct LlaCoor_d lla_pos_pprz
Definition: nps_fdm.h:58
NpsFdm::sideslip
double sideslip
sideslip angle in rad
Definition: nps_fdm.h:116
NpsFdm::on_ground
bool on_ground
Definition: nps_fdm.h:49
NpsFdm::ltpprz_ecef_accel
struct NedCoor_d ltpprz_ecef_accel
accel in ltppprz frame, wrt ECEF frame
Definition: nps_fdm.h:81
nps_fdm_init
void nps_fdm_init(double dt)
Initialize actuator dynamics, set unused fields in fdm.
Definition: nps_fdm_crrcsim.c:119
NpsFdm::ltp_to_body_quat
struct DoubleQuat ltp_to_body_quat
Definition: nps_fdm.h:91
nps_fdm_set_wind
void nps_fdm_set_wind(double speed, double dir)
Definition: nps_fdm_crrcsim.c:200
NpsFdm::ltp_ecef_vel
struct NedCoor_d ltp_ecef_vel
velocity in LTP frame, wrt ECEF frame
Definition: nps_fdm.h:74
NpsFdm::ltpprz_to_body_eulers
struct DoubleEulers ltpprz_to_body_eulers
Definition: nps_fdm.h:94
NpsFdm::body_inertial_rotaccel
struct DoubleRates body_inertial_rotaccel
Definition: nps_fdm.h:102
NpsFdm::body_inertial_accel
struct DoubleVect3 body_inertial_accel
acceleration in body frame, wrt ECI inertial frame
Definition: nps_fdm.h:84
fdm
struct NpsFdm fdm
Holds all necessary NPS FDM state information.
Definition: nps_fdm_crrcsim.c:84
NpsFdm::agl
double agl
Definition: nps_fdm.h:61
NpsFdm::body_ecef_rotvel
struct DoubleRates body_ecef_rotvel
Definition: nps_fdm.h:97
NpsFdm::ecef_ecef_vel
struct EcefCoor_d ecef_ecef_vel
velocity in ECEF frame, wrt ECEF frame
Definition: nps_fdm.h:64
std.h
NpsFdm::time
double time
Definition: nps_fdm.h:46
DoubleRates
angular rates
Definition: pprz_algebra_double.h:85
NpsFdm::ltp_g
struct DoubleVect3 ltp_g
Definition: nps_fdm.h:104
NpsFdm::body_ecef_vel
struct DoubleVect3 body_ecef_vel
velocity in body frame, wrt ECEF frame
Definition: nps_fdm.h:69
dir
static const float dir[]
Definition: shift_tracking.c:91
NpsFdm::ltp_ecef_accel
struct NedCoor_d ltp_ecef_accel
acceleration in LTP frame, wrt ECEF frame
Definition: nps_fdm.h:76
NpsFdm::total_pressure
double total_pressure
total atmospheric pressure in Pascal
Definition: nps_fdm.h:111
NpsFdm::lla_pos_geoc
struct LlaCoor_d lla_pos_geoc
Definition: nps_fdm.h:60
nps_fdm_set_turbulence
void nps_fdm_set_turbulence(double wind_speed, int turbulence_severity)
Definition: nps_fdm_crrcsim.c:211
nps_fdm_set_wind_ned
void nps_fdm_set_wind_ned(double wind_north, double wind_east, double wind_down)
Definition: nps_fdm_crrcsim.c:205
NedCoor_d
vector in North East Down coordinates Units: meters
Definition: pprz_geodetic_double.h:67
nps_fdm_set_temperature
void nps_fdm_set_temperature(double temp, double h)
Set temperature in degrees Celcius at given height h above MSL.
Definition: nps_fdm_gazebo.cpp:315
NpsFdm::body_ecef_rotaccel
struct DoubleRates body_ecef_rotaccel
Definition: nps_fdm.h:98
NpsFdm::rudder
float rudder
Definition: nps_fdm.h:123
pprz_geodetic_double.h
Paparazzi double-precision floating point math for geodetic calculations.
NpsFdm::ecef_ecef_accel
struct EcefCoor_d ecef_ecef_accel
acceleration in ECEF frame, wrt ECEF frame
Definition: nps_fdm.h:66
NpsFdm::flap
float flap
Definition: nps_fdm.h:120
commands
static const ShellCommand commands[]
Definition: shell_arch.c:71
NpsFdm::lla_pos
struct LlaCoor_d lla_pos
Definition: nps_fdm.h:55
NpsFdm::aoa
double aoa
angle of attack in rad
Definition: nps_fdm.h:115
pprz_algebra_double.h
Paparazzi double precision floating point algebra.
NpsFdm::hmsl
double hmsl
Definition: nps_fdm.h:56
NpsFdm::ecef_to_body_quat
struct DoubleQuat ecef_to_body_quat
Definition: nps_fdm.h:90
NpsFdm::ltp_to_body_eulers
struct DoubleEulers ltp_to_body_eulers
Definition: nps_fdm.h:92
NpsFdm::init_dt
double init_dt
Definition: nps_fdm.h:47
NpsFdm::ltpprz_pos
struct NedCoor_d ltpprz_pos
Definition: nps_fdm.h:54
NpsFdm::ltpprz_to_body_quat
struct DoubleQuat ltpprz_to_body_quat
Definition: nps_fdm.h:93
EcefCoor_d
vector in EarthCenteredEarthFixed coordinates
Definition: pprz_geodetic_double.h:49
NpsFdm::ecef_pos
struct EcefCoor_d ecef_pos
Definition: nps_fdm.h:53
NpsFdm::temperature
double temperature
current temperature in degrees Celcius
Definition: nps_fdm.h:113
NpsFdm::pressure
double pressure
current (static) atmospheric pressure in Pascal
Definition: nps_fdm.h:110
NpsFdm::dynamic_pressure
double dynamic_pressure
dynamic pressure in Pascal
Definition: nps_fdm.h:112
DoubleVect3
Definition: pprz_algebra_double.h:46
NpsFdm::lla_pos_geod
struct LlaCoor_d lla_pos_geod
Definition: nps_fdm.h:59
NpsFdm::curr_dt
double curr_dt
Definition: nps_fdm.h:48
NpsFdm::nan_count
int nan_count
Definition: nps_fdm.h:50
NpsFdm::rpm
float rpm[FG_NET_FDM_MAX_ENGINES]
Definition: nps_fdm.h:128
NpsFdm::body_inertial_rotvel
struct DoubleRates body_inertial_rotvel
Definition: nps_fdm.h:101
NpsFdm::pressure_sl
double pressure_sl
pressure at sea level in Pascal
Definition: nps_fdm.h:114
DoubleEulers
euler angles
Definition: pprz_algebra_double.h:76