CurrentState: fall back to DISTANCE_SENSOR for sonaralt #3653
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.
The
RANGEFINDERmessage will no longer be sent by default in ArduPilot (and will eventually be removed). ArduPilot/ardupilot#31095This is the message that populates the
sonarrangefield, which is different from therangefinder[N]fields in that it explicitly uses alt units (since it's explicitly known ahead of time that this message is for downfacing rangefinders only). As an asside,sonarrangeshould probably get renamed to something likerangefinderalt, but that would break some setups and is out of scope for this PR. Not sure how we want to approach that.This PR falls back to taking populating the
sonarrangewith the first downward-facing rangefinder in theDISTANCE_SENSORmessage if noRANGEFINDERmessages are coming in (it will continue to preferRANGEFINDERif it's receiving it).There is a subtle difference with using the first downward rangefinder. The value that ArduPilot sends in
RANGEFINDERis actually the first downward facing range finder that is in range, but then if none are in range, it returns the first downward facing one. That would be much messier to implement, and the vast majority of people just have the single downward sensor. I say with go with this implementation for now. This is why I have Planner prefer the deprecated message. If anyone hits an issue, they can work around it temporarily by enabling theRANGEFINDERmessage (which will still be compiled in by default in 4.7, just not sent by default).I've tested this in SITL with both messages, and with each on their own. I tested that the priority between the two messages is working, and I tested with multiple rangefinders in different orientations, and I tested with different unit settings in Planner. All working as expected.