New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AP_RangeFinder: Benewake sends max-range+1m when out of range #9727
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second part is OK.
First part I would prefer to see it use the signal_ok
, after all, that's precisely why it was there. It seems it was misused in the update
method; in my opinion we only to change:
get_reading
to initializesignal_ok
to falseupdate
to:bool signal_ok = false; if (get_reading(state.distance_cm, signal_ok)) { state.last_reading_ms = AP_HAL::millis(); update_status(); } else if (signal_ok) { set_status(RangeFinder::RangeFinder_OutOfRangeHigh); } else if (AP_HAL::millis() - state.last_reading_ms > 200) { set_status(RangeFinder::RangeFinder_NoData); }
@OXINARF, thanks very much for the review! |
@OXINARF, thinking about this a bit more.. the proposed code won't quite work because last_reading_ms won't be updated so the sensor's health will go bad. I.e. it's status will soon be set to NoData.. So I'm still thinking about how to handle this.. |
@OXINARF, how do you feel about this change? Instead of making more use of "signal_ok" I've removed it and in cases where we were using it, we now just set the distance to out-of-range. I also made a couple of other minor simplifications. Here's a graph of the RFND.Dist1 during a test after making this change. |
@rmackay9 How does it set the out-of-range status? It looks like the value would be used as valid, unless the user explicitly sets the max range which triggers the out-of-range status; we rely on that on some drivers, but I think that in drivers where we know it is out-of-range we shouldn't require it. |
@OXINARF, once the update_status() call is made it will check that the new distance reading vs the "max_distance_cm" (aka RNGFND_MAX_CM) and because the distance was set to "max_distance_cm + 1m" it will set the status to OutOfRangeHigh. The max distance is defaulted to 700cm and it always needs to be defined. It's not one of those parameters where setting it to zero removes the limit. |
Ok, makes sense. Can we add the following in the constructor?
This way if the user doesn't set it, we set the default to a more sane value. By the way, squashing third commit with first might be a good idea. |
…able This means the sensor is healthy even if it is out of range. This is a partial revert of commit ArduPilot@724f34c#diff-577a72d2550199fabbdfd77fa5890368R408
also returns out-of-range when signal is weak
this should be a non-functional change
677e1d0
to
f17e669
Compare
Thanks I've squashed and created an issue to better default the max range for all lidar. I'll merge this when travis and semaphore say it's OK. |
This PR corrects two issues discovered during Copter-3.6.1-rc1 testing (see discussion here):