-
Notifications
You must be signed in to change notification settings - Fork 21.2k
AP_RangeFinder: support multiple MAVLink rangefinders via RNGFNDn_ADDR #33982
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
Open
tridge
wants to merge
2
commits into
ArduPilot:master
Choose a base branch
from
tridge:pr-mavlink-rangefinder-id
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+72
−3
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -12354,6 +12354,73 @@ def my_message_hook(mav, m): | |||||||
| if len(wanted_distances.keys()) == 0: | ||||||||
| break | ||||||||
|
|
||||||||
| def MAVLinkRangeFinderIDs(self): | ||||||||
| '''test multiple MAVLink rangefinders selected by DISTANCE_SENSOR id''' | ||||||||
| self.context_push() | ||||||||
| try: | ||||||||
| self.set_parameters({ | ||||||||
| "SERIAL5_PROTOCOL": 1, | ||||||||
| "RNGFND1_TYPE": 10, | ||||||||
| "RNGFND1_ADDR": 1, | ||||||||
| "RNGFND2_TYPE": 10, | ||||||||
| "RNGFND2_ADDR": 2, | ||||||||
| }) | ||||||||
| self.reboot_sitl() | ||||||||
|
|
||||||||
| # we are interacting with the autopilot, reduce chance of | ||||||||
| # hitting timeouts on supplied data: | ||||||||
| self.context_set_speedup(1) | ||||||||
|
Comment on lines
+12370
to
+12372
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| self.context_set_message_rate_hz("DISTANCE_SENSOR", 10) | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was leaking into subsequent tests, thus the extra push/pop |
||||||||
|
|
||||||||
| self.context_collect("DISTANCE_SENSOR") | ||||||||
| input_distances = { | ||||||||
| 1: 20, | ||||||||
| 2: 30, | ||||||||
| } | ||||||||
| for _ in range(10): | ||||||||
| for input_id, distance_cm in input_distances.items(): | ||||||||
| self.mav.mav.distance_sensor_send( | ||||||||
| 0, # time_boot_ms | ||||||||
| 10, # min_distance | ||||||||
| 50, # max_distance | ||||||||
| distance_cm, # current_distance | ||||||||
| mavutil.mavlink.MAV_DISTANCE_SENSOR_LASER, # type | ||||||||
| input_id, # id | ||||||||
| mavutil.mavlink.MAV_SENSOR_ROTATION_PITCH_270, # orientation | ||||||||
| 255 # covariance | ||||||||
| ) | ||||||||
| self.delay_sim_time(0.1, reason="collect rangefinder output") | ||||||||
|
|
||||||||
| messages = self.context_collection("DISTANCE_SENSOR") | ||||||||
| self.context_stop_collecting("DISTANCE_SENSOR") | ||||||||
| if not messages: | ||||||||
| raise NotAchievedException("Did not receive DISTANCE_SENSOR output") | ||||||||
|
|
||||||||
| output_distances = { | ||||||||
| 0: input_distances[1], | ||||||||
| 1: input_distances[2], | ||||||||
| } | ||||||||
| seen_ids = set() | ||||||||
| for message in messages: | ||||||||
| if message.id not in output_distances: | ||||||||
| raise NotAchievedException( | ||||||||
| "Unexpected MAVLink rangefinder backend id %u" % message.id) | ||||||||
| distance_cm = output_distances[message.id] | ||||||||
| if abs(message.current_distance - distance_cm) > 1: | ||||||||
| raise NotAchievedException( | ||||||||
| "MAVLink rangefinder distance mismatch " | ||||||||
| "(backend=%u want=%u got=%u)" % | ||||||||
| (message.id, distance_cm, message.current_distance)) | ||||||||
| seen_ids.add(message.id) | ||||||||
|
|
||||||||
| if seen_ids != set(output_distances.keys()): | ||||||||
| raise NotAchievedException( | ||||||||
| "Did not receive output from all MAVLink rangefinder backends " | ||||||||
| "(want=%s got=%s)" % | ||||||||
| (sorted(output_distances.keys()), sorted(seen_ids))) | ||||||||
| finally: | ||||||||
| self.context_pop() | ||||||||
|
|
||||||||
| def fly_rangefinder_mavlink_distance_sensor(self): | ||||||||
| self.start_subtest("Test mavlink rangefinder using DISTANCE_SENSOR messages") | ||||||||
| self.context_push() | ||||||||
|
|
@@ -15776,6 +15843,7 @@ def tests1e(self): | |||||||
| self.ModeFollow, | ||||||||
| self.ModeFollow_with_FOLLOW_TARGET, | ||||||||
| self.RangeFinderDrivers, | ||||||||
| self.MAVLinkRangeFinderIDs, | ||||||||
| self.FlyRangeFinderMAVlink, | ||||||||
| self.FlyRangeFinderSITL, | ||||||||
| self.RangeFinderDriversMaxAlt_LightwareSerial, | ||||||||
|
|
||||||||
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
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
Oops, something went wrong.
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.
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.
Is this needed?!