Commit 2f3d27bd authored by Don Gagne's avatar Don Gagne

Change priority of messages from which altitude comes from

Also changed GPS FactGroup values to use NaN appropriately to show
unavailable values.
parent 23eb60d3
...@@ -94,9 +94,8 @@ Vehicle::Vehicle(LinkInterface* link, ...@@ -94,9 +94,8 @@ Vehicle::Vehicle(LinkInterface* link,
, _onboardControlSensorsEnabled(0) , _onboardControlSensorsEnabled(0)
, _onboardControlSensorsHealth(0) , _onboardControlSensorsHealth(0)
, _onboardControlSensorsUnhealthy(0) , _onboardControlSensorsUnhealthy(0)
, _useGpsRawIntForPosition(true) , _gpsRawIntMessageAvailable(false)
, _useGpsRawIntForAltitude(true) , _globalPositionIntMessageAvailable(false)
, _useAltitudeForAltitude(false)
, _connectionLost(false) , _connectionLost(false)
, _connectionLostEnabled(true) , _connectionLostEnabled(true)
, _missionManager(NULL) , _missionManager(NULL)
...@@ -275,9 +274,8 @@ Vehicle::Vehicle(MAV_AUTOPILOT firmwareType, ...@@ -275,9 +274,8 @@ Vehicle::Vehicle(MAV_AUTOPILOT firmwareType,
, _onboardControlSensorsEnabled(0) , _onboardControlSensorsEnabled(0)
, _onboardControlSensorsHealth(0) , _onboardControlSensorsHealth(0)
, _onboardControlSensorsUnhealthy(0) , _onboardControlSensorsUnhealthy(0)
, _useGpsRawIntForPosition(true) , _gpsRawIntMessageAvailable(false)
, _useGpsRawIntForAltitude(true) , _globalPositionIntMessageAvailable(false)
, _useAltitudeForAltitude(false)
, _connectionLost(false) , _connectionLost(false)
, _connectionLostEnabled(true) , _connectionLostEnabled(true)
, _missionManager(NULL) , _missionManager(NULL)
...@@ -516,20 +514,20 @@ void Vehicle::_handleGpsRawInt(mavlink_message_t& message) ...@@ -516,20 +514,20 @@ void Vehicle::_handleGpsRawInt(mavlink_message_t& message)
mavlink_gps_raw_int_t gpsRawInt; mavlink_gps_raw_int_t gpsRawInt;
mavlink_msg_gps_raw_int_decode(&message, &gpsRawInt); mavlink_msg_gps_raw_int_decode(&message, &gpsRawInt);
_gpsRawIntMessageAvailable = true;
if (gpsRawInt.fix_type >= GPS_FIX_TYPE_3D_FIX) { if (gpsRawInt.fix_type >= GPS_FIX_TYPE_3D_FIX) {
if (_useGpsRawIntForPosition) { if (!_globalPositionIntMessageAvailable) {
setLatitude(gpsRawInt.lat / (double)1E7); setLatitude(gpsRawInt.lat / (double)1E7);
setLongitude(gpsRawInt.lon / (double)1E7); setLongitude(gpsRawInt.lon / (double)1E7);
} _altitudeAMSLFact.setRawValue(gpsRawInt.alt / 1000.0);
if (_useGpsRawIntForAltitude) {
_altitudeRelativeFact.setRawValue(gpsRawInt.alt / 1000.0);
} }
} }
_gpsFactGroup.count()->setRawValue(gpsRawInt.satellites_visible == 255 ? 0 : gpsRawInt.satellites_visible); _gpsFactGroup.count()->setRawValue(gpsRawInt.satellites_visible == 255 ? 0 : gpsRawInt.satellites_visible);
_gpsFactGroup.hdop()->setRawValue(gpsRawInt.eph == UINT16_MAX ? 1e10f : gpsRawInt.eph / 100.0); _gpsFactGroup.hdop()->setRawValue(gpsRawInt.eph == UINT16_MAX ? std::numeric_limits<double>::quiet_NaN() : gpsRawInt.eph / 100.0);
_gpsFactGroup.vdop()->setRawValue(gpsRawInt.epv == UINT16_MAX ? 1e10f : gpsRawInt.epv / 100.0); _gpsFactGroup.vdop()->setRawValue(gpsRawInt.epv == UINT16_MAX ? std::numeric_limits<double>::quiet_NaN() : gpsRawInt.epv / 100.0);
_gpsFactGroup.courseOverGround()->setRawValue(gpsRawInt.cog == UINT16_MAX ? 0.0 : gpsRawInt.cog / 100.0); _gpsFactGroup.courseOverGround()->setRawValue(gpsRawInt.cog == UINT16_MAX ? std::numeric_limits<double>::quiet_NaN() : gpsRawInt.cog / 100.0);
_gpsFactGroup.lock()->setRawValue(gpsRawInt.fix_type); _gpsFactGroup.lock()->setRawValue(gpsRawInt.fix_type);
if (gpsRawInt.fix_type >= GPS_FIX_TYPE_3D_FIX) { if (gpsRawInt.fix_type >= GPS_FIX_TYPE_3D_FIX) {
...@@ -542,15 +540,12 @@ void Vehicle::_handleGlobalPositionInt(mavlink_message_t& message) ...@@ -542,15 +540,12 @@ void Vehicle::_handleGlobalPositionInt(mavlink_message_t& message)
mavlink_global_position_int_t globalPositionInt; mavlink_global_position_int_t globalPositionInt;
mavlink_msg_global_position_int_decode(&message, &globalPositionInt); mavlink_msg_global_position_int_decode(&message, &globalPositionInt);
_useGpsRawIntForPosition = false; _globalPositionIntMessageAvailable = true;
_useGpsRawIntForAltitude = false;
setLatitude(globalPositionInt.lat / (double)1E7); setLatitude(globalPositionInt.lat / (double)1E7);
setLongitude(globalPositionInt.lon / (double)1E7); setLongitude(globalPositionInt.lon / (double)1E7);
if (!_useAltitudeForAltitude) { _altitudeRelativeFact.setRawValue(globalPositionInt.relative_alt / 1000.0);
_altitudeRelativeFact.setRawValue(globalPositionInt.relative_alt / 1000.0); _altitudeAMSLFact.setRawValue(globalPositionInt.alt / 1000.0);
_altitudeAMSLFact.setRawValue(globalPositionInt.alt / 1000.0);
}
} }
void Vehicle::_handleAltitude(mavlink_message_t& message) void Vehicle::_handleAltitude(mavlink_message_t& message)
...@@ -558,11 +553,13 @@ void Vehicle::_handleAltitude(mavlink_message_t& message) ...@@ -558,11 +553,13 @@ void Vehicle::_handleAltitude(mavlink_message_t& message)
mavlink_altitude_t altitude; mavlink_altitude_t altitude;
mavlink_msg_altitude_decode(&message, &altitude); mavlink_msg_altitude_decode(&message, &altitude);
_useAltitudeForAltitude = true; // If data from GPS is available it takes precedence over ALTITUDE message
_useGpsRawIntForAltitude = false; if (!_globalPositionIntMessageAvailable) {
_altitudeRelativeFact.setRawValue(altitude.altitude_relative); _altitudeRelativeFact.setRawValue(altitude.altitude_relative);
_altitudeAMSLFact.setRawValue(altitude.altitude_amsl); if (!_gpsRawIntMessageAvailable) {
_altitudeAMSLFact.setRawValue(altitude.altitude_amsl);
}
}
} }
void Vehicle::_handleAutopilotVersion(LinkInterface *link, mavlink_message_t& message) void Vehicle::_handleAutopilotVersion(LinkInterface *link, mavlink_message_t& message)
......
...@@ -766,9 +766,8 @@ private: ...@@ -766,9 +766,8 @@ private:
uint32_t _onboardControlSensorsEnabled; uint32_t _onboardControlSensorsEnabled;
uint32_t _onboardControlSensorsHealth; uint32_t _onboardControlSensorsHealth;
uint32_t _onboardControlSensorsUnhealthy; uint32_t _onboardControlSensorsUnhealthy;
bool _useGpsRawIntForPosition; bool _gpsRawIntMessageAvailable;
bool _useGpsRawIntForAltitude; bool _globalPositionIntMessageAvailable;
bool _useAltitudeForAltitude;
typedef struct { typedef struct {
int component; int component;
......
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