Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
0d2f3312
Commit
0d2f3312
authored
Oct 12, 2015
by
Lorenz Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix noise generation. Thanks to @kd0aij and @scott-eddy for the good discussions
parent
224a04c9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
12 deletions
+23
-12
UAS.cc
src/uas/UAS.cc
+23
-12
No files found.
src/uas/UAS.cc
View file @
0d2f3312
...
...
@@ -132,10 +132,8 @@ UAS::UAS(MAVLinkProtocol* protocol, Vehicle* vehicle) : UASInterface(),
blockHomePositionChanges
(
false
),
receivedMode
(
false
),
// 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
(
0.6457
f
),
yacc_var
(
0.7048
f
),
zacc_var
(
0.97885
f
),
...
...
@@ -149,7 +147,7 @@ UAS::UAS(MAVLinkProtocol* protocol, Vehicle* vehicle) : UASInterface(),
diff_pressure_var
(
0.5802
f
),
pressure_alt_var
(
0.5802
f
),
temperature_var
(
0.7145
f
),
*/
/*
xacc_var(0.0f),
yacc_var(0.0f),
zacc_var(0.0f),
...
...
@@ -163,7 +161,7 @@ UAS::UAS(MAVLinkProtocol* protocol, Vehicle* vehicle) : UASInterface(),
diff_pressure_var(0.0f),
pressure_alt_var(0.0f),
temperature_var(0.0f),
*/
#ifndef __mobile__
simulation
(
0
),
...
...
@@ -1960,6 +1958,22 @@ void UAS::enableHilFlightGear(bool enable, QString options, bool sensorHil, QObj
}
simulation
=
new
QGCFlightGearLink
(
this
,
options
);
}
float
noise_scaler
=
0.05
f
;
xacc_var
=
noise_scaler
*
1.2914
f
;
yacc_var
=
noise_scaler
*
0.7048
f
;
zacc_var
=
noise_scaler
*
1.9577
f
;
rollspeed_var
=
noise_scaler
*
0.8126
f
;
pitchspeed_var
=
noise_scaler
*
0.6145
f
;
yawspeed_var
=
noise_scaler
*
0.5852
f
;
xmag_var
=
noise_scaler
*
0.4786
f
;
ymag_var
=
noise_scaler
*
0.4566
f
;
zmag_var
=
noise_scaler
*
0.3333
f
;
abs_pressure_var
=
noise_scaler
*
1.1604
f
;
diff_pressure_var
=
noise_scaler
*
0.6604
f
;
pressure_alt_var
=
noise_scaler
*
1.1604
f
;
temperature_var
=
noise_scaler
*
2.4290
f
;
// Connect Flight Gear Link
link
=
dynamic_cast
<
QGCFlightGearLink
*>
(
simulation
);
link
->
setStartupArguments
(
options
);
...
...
@@ -2018,10 +2032,9 @@ void UAS::enableHilXPlane(bool enable)
stopHil
();
delete
simulation
;
}
qDebug
()
<<
"CREATED NEW XPLANE LINK"
;
simulation
=
new
QGCXPlaneLink
(
this
);
float
noise_scaler
=
0.
1
f
;
float
noise_scaler
=
0.
05
f
;
xacc_var
=
noise_scaler
*
1.2914
f
;
yacc_var
=
noise_scaler
*
0.7048
f
;
zacc_var
=
noise_scaler
*
1.9577
f
;
...
...
@@ -2165,7 +2178,6 @@ float UAS::addZeroMeanNoise(float truth_meas, float noise_var)
/* Calculate normally distributed variable noise with mean = 0 and variance = noise_var. Calculated according to
Box-Muller transform */
static
const
float
epsilon
=
std
::
numeric_limits
<
float
>::
min
();
//used to ensure non-zero uniform numbers
static
const
float
two_pi
=
2.0
f
*
3.14159265358979323846
f
;
// 2*pi
static
float
z0
;
//calculated normal distribution random variables with mu = 0, var = 1;
float
u1
,
u2
;
//random variables generated from c++ rand();
...
...
@@ -2179,17 +2191,16 @@ float UAS::addZeroMeanNoise(float truth_meas, float noise_var)
}
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
z0
=
sqrt
(
-
2.0
*
log
(
u1
))
*
cos
(
2.0
f
*
M_PI
*
u2
);
//calculate normally distributed variable with mu = 0, var = 1
//TODO add bias term that changes randomly to simulate accelerometer and gyro bias the exf should handle these
//as well
float
noise
=
z0
*
(
noise_var
*
noise_var
);
//calculate normally distributed variable with mu = 0, std = var^2
float
noise
=
z0
*
sqrt
(
noise_var
);
//calculate normally distributed variable with mu = 0, std = var^2
//Finally gaurd against any case where the noise is not real
if
(
std
::
isfinite
(
noise
)){
if
(
std
::
isfinite
(
noise
))
{
return
truth_meas
+
noise
;
}
else
{
}
else
{
return
truth_meas
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment