[nps] add turbulence

This commit is contained in:
Felix Ruess
2013-09-14 19:58:37 +02:00
parent 952530864f
commit bf49a7f1b2
5 changed files with 15 additions and 3 deletions
+1
View File
@@ -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>
+7 -1
View File
@@ -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);
}
+1
View File
@@ -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;
+1 -1
View File
@@ -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 */
+5 -1
View File
@@ -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);
}
/**