From 2eeb79f3f710dee1870402f80b2a6a080a81dc8a Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 7 Sep 2012 12:01:31 +0200 Subject: [PATCH] Catching NaNs and Inf in HUD --- src/ui/HUD.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ui/HUD.cc b/src/ui/HUD.cc index f2167567c6..6234f89900 100644 --- a/src/ui/HUD.cc +++ b/src/ui/HUD.cc @@ -314,16 +314,22 @@ void HUD::updateAttitude(UASInterface* uas, double roll, double pitch, double ya { Q_UNUSED(uas); Q_UNUSED(timestamp); - this->roll = roll; - this->pitch = pitch*3.35f; // Constant here is the 'focal length' of the projection onto the plane - this->yaw = yaw; + if (!isnan(roll) && !isinf(roll) && !isnan(pitch) && !isinf(pitch) && !isnan(yaw) && !isinf(yaw)) + { + this->roll = roll; + this->pitch = pitch*3.35f; // Constant here is the 'focal length' of the projection onto the plane + this->yaw = yaw; + } } void HUD::updateAttitude(UASInterface* uas, int component, double roll, double pitch, double yaw, quint64 timestamp) { Q_UNUSED(uas); Q_UNUSED(timestamp); - attitudes.insert(component, QVector3D(roll, pitch*3.35f, yaw)); // Constant here is the 'focal length' of the projection onto the plane + if (!isnan(roll) && !isinf(roll) && !isnan(pitch) && !isinf(pitch) && !isnan(yaw) && !isinf(yaw)) + { + attitudes.insert(component, QVector3D(roll, pitch*3.35f, yaw)); // Constant here is the 'focal length' of the projection onto the plane + } } void HUD::updateBattery(UASInterface* uas, double voltage, double percent, int seconds) -- GitLab