Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
06c36b8b
Commit
06c36b8b
authored
Jan 07, 2014
by
Don Gagne
Browse files
ind_airspeed used uninitialized when _sensorHilEnabled == false
Fixing -Wuninitialized
parent
e547004f
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/comm/QGCFlightGearLink.cc
View file @
06c36b8b
...
...
@@ -281,31 +281,31 @@ void QGCFlightGearLink::readBytes()
temperature
=
values
.
at
(
19
).
toFloat
();
abs_pressure
=
values
.
at
(
20
).
toFloat
()
*
1e2
;
//convert to Pa from hPa
//calculate differential pressure
const
float
air_gas_constant
=
287.1
f
;
// J/(kg * K)
const
float
absolute_null_celsius
=
-
273.15
f
;
// °C
float
density
=
abs_pressure
/
(
air_gas_constant
*
(
temperature
-
absolute_null_celsius
));
diff_pressure
=
true_airspeed
*
true_airspeed
*
density
/
2.0
f
;
//qDebug() << "diff_pressure: " << diff_pressure << "abs_pressure: " << abs_pressure;
/* Calculate indicated airspeed */
const
float
air_density_sea_level_15C
=
1.225
f
;
//kg/m^3
if
(
diff_pressure
>
0
)
{
ind_airspeed
=
sqrtf
((
2.0
f
*
diff_pressure
)
/
air_density_sea_level_15C
);
}
else
{
ind_airspeed
=
-
sqrtf
((
2.0
f
*
fabsf
(
diff_pressure
))
/
air_density_sea_level_15C
);
}
//qDebug() << "ind_airspeed: " << ind_airspeed << "true_airspeed: " << true_airspeed;
// Send updated state
//qDebug() << "sensorHilEnabled: " << sensorHilEnabled;
if
(
_sensorHilEnabled
)
{
quint16
fields_changed
=
0xFFF
;
//set all 12 used bits
//calculate differential pressure
const
float
air_gas_constant
=
287.1
f
;
// J/(kg * K)
const
float
absolute_null_celsius
=
-
273.15
f
;
// °C
float
density
=
abs_pressure
/
(
air_gas_constant
*
(
temperature
-
absolute_null_celsius
));
diff_pressure
=
true_airspeed
*
true_airspeed
*
density
/
2.0
f
;
//qDebug() << "diff_pressure: " << diff_pressure << "abs_pressure: " << abs_pressure;
/* Calculate indicated airspeed */
const
float
air_density_sea_level_15C
=
1.225
f
;
//kg/m^3
if
(
diff_pressure
>
0
)
{
ind_airspeed
=
sqrtf
((
2.0
f
*
diff_pressure
)
/
air_density_sea_level_15C
);
}
else
{
ind_airspeed
=
-
sqrtf
((
2.0
f
*
fabsf
(
diff_pressure
))
/
air_density_sea_level_15C
);
}
//qDebug() << "ind_airspeed: " << ind_airspeed << "true_airspeed: " << true_airspeed;
float
pressure_alt
=
alt
;
xmag_ned
=
cosf
(
mag_variation
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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