AP_RangeFinder: TeraRangerI2C redefining the output distance logic with OutOfRange cases #17050
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is intended to correct the output distances and status that the TeraRanger sensor should return when used under the I2C protocol.
It is related to this previous PR: #13376
To add to what @rmackay9 said in the above issue, the way this is currently implemented triggers the sensor as being "unhealthy" whenever the sensor is unable to measure. And this, whether it is "too close" OR "too far" OR "not seeing anything".
The main reason for this PR is that the TeraRangerI2C driver cannot be used as a simple proximity sensor, and it is expected to use the auxiliary module TeraRangerTower Hub (UART) when one wants to use a single rangefinder as a proximity sensor. Because the sensor is considered "unhealthy", the proximity library blocks (actually, it's more the rangefinder library here) the sensor from being read. Since being out of range is actually quite common when a rangefinder is used as a proximity sensor, the rangefinder constantly triggers the proximity failsafe... (The vehicle even refuses to arm when there is no obstacle seen by the sensor)
I consider that for the function "process_raw_measure()", each error code should output a value. Whether the sensor is "healthy" or not should be checked in the above function "collect_raw()" but not when processing the value itself. I originally only wanted to modify the 0x0001 error code, but having found the previous mentioned PR, I decided to modify the whole function, which is probably contraindicated..