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);
|
const float dist = AP::sitl()->get_rangefinder(_instance);
|
||||||
|
|
||||||
// negative distance means nothing is connected
|
// nan distance means nothing is connected
|
||||||
if (is_negative(dist)) {
|
if (isnan(dist)) {
|
||||||
state.status = RangeFinder::Status::NoData;
|
state.status = RangeFinder::Status::NoData;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.distance_m = dist;
|
state.distance_m = MAX(0, dist);
|
||||||
state.last_reading_ms = AP_HAL::millis();
|
state.last_reading_ms = AP_HAL::millis();
|
||||||
|
|
||||||
// update range_valid state based on distance measured
|
// update range_valid state based on distance measured
|
||||||
|
Loading…
Reference in New Issue
Block a user