Commit 212022fc authored by Thomas Gubler's avatar Thomas Gubler

flightgear: restrict distance sensor to sane values

parent b52e4403
...@@ -432,7 +432,11 @@ void QGCFlightGearLink::readBytes() ...@@ -432,7 +432,11 @@ void QGCFlightGearLink::readBytes()
// qDebug() << "sensorHilGpsChanged " << lat << lon << alt << vel; // qDebug() << "sensorHilGpsChanged " << lat << lon << alt << vel;
// Send Optical Flow message. For now we set the flow quality to 0 and just write the ground_distance field // Send Optical Flow message. For now we set the flow quality to 0 and just write the ground_distance field
float distanceMeasurement = (float)(1.0/cosPhi * 1.0/cosThe * alt_agl); //asuming planar ground float distanceMeasurement = -1.0; // -1 means invalid value
if (fabsf(roll) < 0.87 && fabsf(pitch) < 0.87) // return a valid value only for decent angles
{
distanceMeasurement = fabsf((float)(1.0/cosPhi * 1.0/cosThe * alt_agl)); // assuming planar ground
}
emit sensorHilOpticalFlowChanged(QGC::groundTimeUsecs(), 0, 0, 0.0f, emit sensorHilOpticalFlowChanged(QGC::groundTimeUsecs(), 0, 0, 0.0f,
0.0f, 0.0f, distanceMeasurement); 0.0f, 0.0f, distanceMeasurement);
} else { } else {
......
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