AP_RangeFinder: use NaN for invalid rangefinder data

This commit is contained in:
Andrew Tridgell 2023-08-21 10:51:28 +10:00 committed by Peter Barker
parent 1b6c329de5
commit 5f47a94e2b
1 changed files with 3 additions and 3 deletions

View File

@ -34,13 +34,13 @@ void AP_RangeFinder_SITL::update(void)
{
const float dist = AP::sitl()->get_rangefinder(_instance);
// negative distance means nothing is connected
if (is_negative(dist)) {
// nan distance means nothing is connected
if (isnan(dist)) {
state.status = RangeFinder::Status::NoData;
return;
}
state.distance_m = dist;
state.distance_m = MAX(0, dist);
state.last_reading_ms = AP_HAL::millis();
// update range_valid state based on distance measured