diff --git a/examples/imu_noise/README.md b/examples/imu_noise/README.md index c5007608..ffb5781a 100644 --- a/examples/imu_noise/README.md +++ b/examples/imu_noise/README.md @@ -12,8 +12,30 @@ To evaluate noise, first build and run. mkdir build cd build cmake .. +``` + +### Ubuntu Or MacOS + +```bash make +``` + +This will generate the `sensor_noise` executable under `build`. + +### Windows + +```bash +cmake --build . --config Release +``` + +This will generate the `sensor_noise.exe` executable under `build\Release`. + +``` +# Ubuntu or MacOS ./sensor_noise + +# Windows +.\Release\sensor_noise.exe ``` This will generate two series of samples, one for accelerometer and another for gyroscope. @@ -21,13 +43,17 @@ This will generate two series of samples, one for accelerometer and another for To use the analysis script, first install Allan Tools: ``` -pip install --user allantools +pip install --user allantools scipy ``` Then execute the script: ``` +# Ubuntu o MacOS ../plot_samples.py + +# Windows +python.exe ..\plot_samples.py ``` This will produce two graphs: the Allan Deviation plots for both the simulated accelerometer and gyroscope. The values on these graphs should correspond closely to the inputs: @@ -39,11 +65,9 @@ This will produce two graphs: the Allan Deviation plots for both the simulated a * sigma_N: Accelerometer Noise Density * sigma_K: Accelerometer Random Walk - While this technique is used here to validate the operation of the algorithm, it could also be used to estimate the noise parameters for a real IMU. - ## References: * Python Allan Tools: https://github.com/aewallin/allantools diff --git a/examples/imu_noise/main.cc b/examples/imu_noise/main.cc index 128f4aca..04b02333 100644 --- a/examples/imu_noise/main.cc +++ b/examples/imu_noise/main.cc @@ -26,7 +26,7 @@ static constexpr double kSampleFrequency = 100.0; // 16-bit ADC -static constexpr double kSamplePrecision = 1.0/pow(2.0, 16.0); +static double kSamplePrecision = 1.0/pow(2.0, 16.0); // Generate 6 hours of data. static constexpr double kNumSamples = 6 * 3600 * kSampleFrequency; @@ -34,13 +34,13 @@ static constexpr double kNumSamples = 6 * 3600 * kSampleFrequency; // These values come from the Rotors default values: // https://github.com/ethz-asl/rotors_simulator/blob/513bb92da0c1a0c968bdc679dffc8fe7d77de918/rotors_gazebo_plugins/include/rotors_gazebo_plugins/gazebo_imu_plugin.h#L40 static constexpr double kDefaultAdisGyroscopeNoiseDensity = - 2.0 * 35.0 / 3600.0 / 180.0 * M_PI; + 2.0 * 35.0 / 3600.0 / 180.0 * IGN_PI; static constexpr double kDefaultAdisGyroscopeRandomWalk = - 2.0 * 4.0 / 3600.0 / 180.0 * M_PI; + 2.0 * 4.0 / 3600.0 / 180.0 * IGN_PI; static constexpr double kDefaultAdisGyroscopeBiasCorrelationTime = 1.0e+3; static constexpr double kDefaultAdisGyroscopeTurnOnBiasSigma = - 0.5 / 180.0 * M_PI; + 0.5 / 180.0 * IGN_PI; static constexpr double kDefaultAdisAccelerometerNoiseDensity = 2.0 * 2.0e-3; static constexpr double kDefaultAdisAccelerometerRandomWalk =