Commit e485007a authored by Eddy Scott's avatar Eddy Scott Committed by Lorenz Meier

Fixed problem with defining std as variance^2 instead of variance^(1/2)

parent 93928a62
......@@ -135,19 +135,35 @@ UAS::UAS(MAVLinkProtocol* protocol, Vehicle* vehicle) : UASInterface(),
// Initialize HIL sensor noise variances to 0. If user wants corrupted sensor values they will need to set them
// Note variances calculated from flight case from this log: http://dash.oznet.ch/view/MRjW8NUNYQSuSZkbn8dEjY
// TODO: calibrate stand-still pixhawk variances
xacc_var(1.2914f),
/*
xacc_var(0.6457f),
yacc_var(0.7048f),
zacc_var(1.9577f),
zacc_var(0.97885f),
rollspeed_var(0.8126f),
pitchspeed_var(0.6145f),
yawspeed_var(0.5852f),
xmag_var(0.4786f),
ymag_var(0.4566f),
zmag_var(0.3333f),
abs_pressure_var(1.1604f),
diff_pressure_var(1.1604f),
pressure_alt_var(1.1604f),
temperature_var(1.4290f),
xmag_var(0.2393f),
ymag_var(0.2283f),
zmag_var(0.1665f),
abs_pressure_var(0.5802f),
diff_pressure_var(0.5802f),
pressure_alt_var(0.5802f),
temperature_var(0.7145f),
*/
xacc_var(0.0f),
yacc_var(0.0f),
zacc_var(0.0f),
rollspeed_var(0.0f),
pitchspeed_var(0.0f),
yawspeed_var(0.0f),
xmag_var(0.0f),
ymag_var(0.0f),
zmag_var(0.0f),
abs_pressure_var(0.0f),
diff_pressure_var(0.0f),
pressure_alt_var(0.0f),
temperature_var(0.0f),
#ifndef __mobile__
simulation(0),
......
......@@ -58,8 +58,8 @@ float generateGaussianNoise(float mu, float variance)
while ( u1 <= epsilon ); //Have a catch to ensure non-zero for log()
z0 = sqrt(-2.0 * log(u1)) * cos(two_pi * u2); //calculate normally distributed variable with mu = 0, var = 1
float noise = z0 * (variance*variance) + mu; //calculate normally distributed variable with mu = mu, std = var^2
return noise
float noise = z0 * sqrt(variance) + mu; //calculate normally distributed variable with mu = mu, std = var^2
return noise;
}
int main(int argc, char *argv[])
{
......
......@@ -39,7 +39,7 @@ clc
system('g++ gaussian_noise.cpp -o generate_noise_csv');
mu_des = 0.0;
std_des = 0.02;
var_des = 0.2;%sqrt(std_des);
var_des = std_des^2;
num_samples = 10000;
num_runs = 100;
if exist('generated_noise.csv','file')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment