Skip to content
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

Better filtering of MAVLink components #1116

Merged
merged 2 commits into from
Jan 19, 2024

Conversation

stephendade
Copy link
Contributor

@stephendade stephendade commented Oct 31, 2022

This adds the appropriate filters so that MAV_COMP_ID_PERIPHERAL devices can be used without confusing MAVProxy.

EDIT:
This PR now allows any MAVLink accessories (same sysid as flight controller, different component id) to:
a) Not confuse MAVProxy if the accessory is sending a heartbeat
b) Selecting the accessory in the console->vehicle->select menu correctly filters packets from the accessory to non-multi-vehicle-aware modules.

@stephendade stephendade changed the title All Periph components to be used Allow Periph components to be used Oct 31, 2022
@stephendade stephendade changed the title Allow Periph components to be used Better filtering of MAVLink components Nov 13, 2022
@stephendade
Copy link
Contributor Author

PR has now been re-engineered for the general case:

  • self.is_primary_vehicle(m) now checks for component id matching, instead of using a hardcoded component id blacklist.

@stephendade
Copy link
Contributor Author

It has been tested on SITL with the ADSB simulator, and a CubeOrange with custom MAVLink peripheral. Messages are still routed correctly.

MAVProxy/modules/lib/mp_module.py Outdated Show resolved Hide resolved

if getattr(m, 'time_boot_ms', None) is not None and self.settings.target_system == m.get_srcSystem():
if getattr(m, 'time_boot_ms', None) is not None and self.is_primary_vehicle(m):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good change - components won't necessarily have the same timestamp as the parent vehicle.

@@ -893,6 +882,9 @@ def master_callback(self, m, master):
for (mod,pm) in self.mpstate.modules:
if not hasattr(mod, 'mavlink_packet'):
continue
# Do not send other-system-or-component heartbeat packets to non-multi-vehicle modules
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this break mavproxy_gimbal.py? That's the first module I thought of...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked - gimbal still works. I'm only not sending heartbeats here

MAVProxy/modules/mavproxy_link.py Outdated Show resolved Hide resolved
@stephendade
Copy link
Contributor Author

stephendade commented Nov 27, 2022

Using sim_vehicle.py --vehicle=Copter --console --map --count=10 --auto-sysid works fine

The changes in master_callback() still allow packets from the non-target vehicle to be passed through to multi-vehicle-aware modules (line 886 of mavproxy_link), as the check is for multi-vehicle aware modules.

Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fence module still says "fence removed" / "fence present" when moving between vehicles

Testing went well.

@peterbarker peterbarker merged commit 232eede into ArduPilot:master Jan 19, 2024
2 checks passed
@peterbarker
Copy link
Contributor

Merged, thanks!

@stephendade stephendade deleted the mavperiph branch October 21, 2024 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants