AP_RangeFinder: support multiple MAVLink rangefinders via RNGFNDn_ADDR - #33982
Open
tridge wants to merge 2 commits into
Open
AP_RangeFinder: support multiple MAVLink rangefinders via RNGFNDn_ADDR#33982tridge wants to merge 2 commits into
tridge wants to merge 2 commits into
Conversation
peterbarker
requested changes
Aug 8, 2026
peterbarker
left a comment
Contributor
There was a problem hiding this comment.
Code changes LGTM.
Approved after the test is fixed.
I'd actually prefer a completely new test for this functionality rather than shoving it into the existing test - but I'm not going to insist.
Comment on lines
+12428
to
+12432
| self.context_stop_collecting("DISTANCE_SENSOR") | ||
| self.set_parameters({ | ||
| "RNGFND1_ADDR": 0, | ||
| "RNGFND2_TYPE": 0, | ||
| }) |
Contributor
There was a problem hiding this comment.
Suggested change
| self.context_stop_collecting("DISTANCE_SENSOR") | |
| self.set_parameters({ | |
| "RNGFND1_ADDR": 0, | |
| "RNGFND2_TYPE": 0, | |
| }) | |
| self.context_pop() |
Comment on lines
-12370
to
+12375
| self.set_parameter("RNGFND1_TYPE", 10) | ||
| self.set_parameters({ | ||
| "RNGFND1_TYPE": 10, | ||
| "RNGFND1_ADDR": 1, | ||
| "RNGFND2_TYPE": 10, | ||
| "RNGFND2_ADDR": 2, | ||
| }) |
Contributor
There was a problem hiding this comment.
Suggested change
| self.set_parameter("RNGFND1_TYPE", 10) | |
| self.set_parameters({ | |
| "RNGFND1_TYPE": 10, | |
| "RNGFND1_ADDR": 1, | |
| "RNGFND2_TYPE": 10, | |
| "RNGFND2_ADDR": 2, | |
| }) | |
| # we are interacting with the autopilot, reduce chance of | |
| # hitting timeouts on supplied data: | |
| self.context_set_speedup(1) | |
| self.set_parameter("RNGFND1_TYPE", 10) | |
| self.context_push() | |
| self.set_parameters({ | |
| "RNGFND1_ADDR": 1, | |
| "RNGFND2_TYPE": 10, | |
| "RNGFND2_ADDR": 2, | |
| }) |
| "RNGFND2_TYPE": 10, | ||
| "RNGFND2_ADDR": 2, | ||
| }) | ||
| self.reboot_sitl() |
Comment on lines
+12378
to
+12380
| # we are interacting with the autopilot, reduce chance of | ||
| # hitting timeouts on supplied data: | ||
| self.context_set_speedup(1) |
Contributor
There was a problem hiding this comment.
Suggested change
| # we are interacting with the autopilot, reduce chance of | |
| # hitting timeouts on supplied data: | |
| self.context_set_speedup(1) |
| # we are interacting with the autopilot, reduce chance of | ||
| # hitting timeouts on supplied data: | ||
| self.context_set_speedup(1) | ||
| self.context_set_message_rate_hz("DISTANCE_SENSOR", 10) |
Contributor
There was a problem hiding this comment.
This was leaking into subsequent tests, thus the extra push/pop
tridge
force-pushed
the
pr-mavlink-rangefinder-id
branch
from
August 9, 2026 11:06
f571626 to
0a08fd2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Allow multiple MAVLink rangefinders by using
RNGFNDn_ADDRto select whichDISTANCE_SENSORmessage id each backend accepts.Classification & Testing (check all that apply and add your own)
The existing Copter
RangeFinderautotest is extended to configure two MAVLinkbackends with
RNGFND1_ADDR=1andRNGFND2_ADDR=2, feedDISTANCE_SENSORmessages with each id in turn, and check that the reported distance shows up on
the matching backend only.
Description
Previously the MAVLink rangefinder backend filtered incoming
DISTANCE_SENSORmessages on orientation only, so two MAVLink rangefinders with the same
orientation could not be distinguished and both backends consumed every message.
This adds an id filter based on the existing
RNGFNDn_ADDRparameter:RNGFNDn_ADDRof 0 keeps the old behaviour and accepts anyDISTANCE_SENSORidRNGFNDn_ADDRonly accepts messages whoseidfield matchesThe
ADDRparameter documentation is updated to describe the MAVLink use.