SITL: added a drift_level multiplier

this makes it easier to experiment with different gyro drift levels
This commit is contained in:
Andrew Tridgell 2012-03-03 11:54:19 +11:00
parent 61ebcfe9fe
commit 71d3847bfc
1 changed files with 4 additions and 3 deletions

View File

@ -10,6 +10,7 @@
#include <math.h> #include <math.h>
static const float vibration_level = 2.0; static const float vibration_level = 2.0;
static const float drift_level = 1.0;
// order zgyro, xgyro, ygyro, temp, xacc, yacc, zacc, aspd // order zgyro, xgyro, ygyro, temp, xacc, yacc, zacc, aspd
static const float noise_scale[8] = { 150, 150, 150, 0, 400, 400, 400, 0 }; static const float noise_scale[8] = { 150, 150, 150, 0, 400, 400, 400, 0 };
static const float noise_offset[8]= { 0, 0, 0, 0, 0, 0, 0, 0 }; static const float noise_offset[8]= { 0, 0, 0, 0, 0, 0, 0, 0 };
@ -25,11 +26,11 @@ static double rand_float(void)
static inline float gyro_drift(uint8_t chan) static inline float gyro_drift(uint8_t chan)
{ {
if (drift_rate[chan] == 0) { if (drift_rate[chan] * drift_level == 0.0) {
return 0; return 0;
} }
extern long unsigned int micros(void); extern long unsigned int micros(void);
double period = 10*drift_rate[chan]; double period = 10*drift_rate[chan] * drift_level;
double minutes = fmod(micros() / 60.0e6, period); double minutes = fmod(micros() / 60.0e6, period);
if (minutes < period/2) { if (minutes < period/2) {
return minutes; return minutes;
@ -57,7 +58,7 @@ static inline float noise_generator(uint8_t chan)
} }
} }
if (noise_count == 0) { if (noise_count == 0) {
return rand_float() * base_noise; return rand_float() * base_noise * vibration_level;
} }
return gyro_drift(chan) + noise/noise_count; return gyro_drift(chan) + noise/noise_count;
} }