Skip to content

Commit

Permalink
AP_RangeFinder: use NaN for invalid rangefinder data
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge committed Aug 21, 2023
1 parent e2fbdb8 commit 7469b11
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libraries/AP_RangeFinder/AP_RangeFinder_SITL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7469b11

Please sign in to comment.