mirror of https://github.com/ArduPilot/ardupilot
AP_RangeFinder: use NaN for invalid rangefinder data
This commit is contained in:
parent
1b6c329de5
commit
5f47a94e2b
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue