mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-07 00:53:41 +08:00
[nps] add turbulence
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
<dl_setting var="nps_electrical.supply_voltage" min="0" step="0.1" max="24" module="nps/nps_electrical" shortname="bat_voltage" unit="V"/>
|
||||
<dl_setting var="nps_atmosphere.wind_speed" min="0" step="0.1" max="25" module="nps/nps_atmosphere" shortname="wind_speed" unit="m/s"/>
|
||||
<dl_setting var="nps_atmosphere.wind_dir" min="0" step="1" max="360" module="nps/nps_atmosphere" shortname="wind_dir" unit="rad" alt_unit="deg"/>
|
||||
<dl_setting var="nps_atmosphere.turbulence_severity" min="0" step="1" max="7" module="nps/nps_atmosphere" shortname="turbulence"/>
|
||||
</dl_settings>
|
||||
|
||||
</dl_settings>
|
||||
|
||||
@@ -39,6 +39,10 @@
|
||||
#define NPS_WIND_DIR 0
|
||||
#endif
|
||||
|
||||
#ifndef NPS_TURBULENCE_SEVERITY
|
||||
#define NPS_TURBULENCE_SEVERITY 0
|
||||
#endif
|
||||
|
||||
struct NpsAtmosphere nps_atmosphere;
|
||||
|
||||
void nps_atmosphere_init(void) {
|
||||
@@ -46,10 +50,12 @@ void nps_atmosphere_init(void) {
|
||||
nps_atmosphere.qnh = NPS_QNH;
|
||||
nps_atmosphere.wind_speed = NPS_WIND_SPEED;
|
||||
nps_atmosphere.wind_dir = NPS_WIND_DIR;
|
||||
nps_atmosphere.turbulence_severity = NPS_TURBULENCE_SEVERITY;
|
||||
|
||||
}
|
||||
|
||||
void nps_atmosphere_update(double dt __attribute__((unused))) {
|
||||
nps_fdm_set_wind(nps_atmosphere.wind_speed, nps_atmosphere.wind_dir);
|
||||
nps_fdm_set_wind(nps_atmosphere.wind_speed, nps_atmosphere.wind_dir,
|
||||
nps_atmosphere.turbulence_severity);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ struct NpsAtmosphere {
|
||||
double qnh; ///< barometric pressure at sea level in Pascal
|
||||
double wind_speed; ///< wind magnitude in m/s
|
||||
double wind_dir; ///< wind direction in radians north=0, increasing CCW
|
||||
int turbulence_severity; ///< turbulence severity from 0-7
|
||||
};
|
||||
|
||||
extern struct NpsAtmosphere nps_atmosphere;
|
||||
|
||||
@@ -94,6 +94,6 @@ extern struct NpsFdm fdm;
|
||||
|
||||
extern void nps_fdm_init(double dt);
|
||||
extern void nps_fdm_run_step(double* commands);
|
||||
extern void nps_fdm_set_wind(double speed, double dir);
|
||||
extern void nps_fdm_set_wind(double speed, double dir, int turbulence_severity);
|
||||
|
||||
#endif /* NPS_FDM */
|
||||
|
||||
@@ -180,10 +180,14 @@ void nps_fdm_run_step(double* commands) {
|
||||
|
||||
}
|
||||
|
||||
void nps_fdm_set_wind(double speed, double dir) {
|
||||
void nps_fdm_set_wind(double speed, double dir, int turbulence_severity) {
|
||||
FGWinds* Winds = FDMExec->GetWinds();
|
||||
Winds->SetWindspeed(FeetOfMeters(speed));
|
||||
Winds->SetWindPsi(dir);
|
||||
|
||||
/* wind speed used for turbulence */
|
||||
Winds->SetWindspeed20ft(FeetOfMeters(speed)/2);
|
||||
Winds->SetProbabilityOfExceedence(turbulence_severity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user