AP_Follow: remove auto sysid - #33937
Merged
rmackay9 merged 2 commits intoAug 11, 2026
Merged
Conversation
A FOLL_SYSID of zero meant "follow the first vehicle we hear from". The library wrote that vehicle's system id into the FOLL_SYSID parameter, and cleared the parameter back to zero if the vehicle went quiet for ten seconds. This made the library mutate a user facing parameter on its own, and left the choice of target to message arrival order rather than to configuration. With more than one vehicle in range the target was whichever one happened to be heard first. A FOLL_SYSID of zero now means that no target has been selected. No target message is accepted and the parameter is never written by the library. Following starts once the user sets a system id.
The constant no longer has anything to do with the target system id. Its only remaining job is to discard a stale target estimate. Value and behaviour are unchanged.
Contributor
|
I like this, I never liked the magic behavior, so I never used it. If anyone really wants it they can write it in Lua. Also - the arming checks lua already (configurable) raises an warning or error if follow is enabled but FOLL_SYSID is not set to a value > 0. |
peterbarker
approved these changes
Aug 11, 2026
rmackay9
approved these changes
Aug 11, 2026
88 tasks
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
Removes the behaviour where
FOLL_SYSID = 0causes AP_Follow to latch onto thefirst vehicle it hears from. Zero now means no target has been selected.
Classification & Testing (check all that apply and add your own)
SITL Copter and Plane.
ModeFollow_with_FOLLOW_TARGETandModeFollowboth pass;the latter is flaky on my machine for unrelated reasons (harness timeout waiting to
receive
GLOBAL_POSITION_INTfrom the vehicle). Both commits build standalone. Notflown on hardware.
Description
FOLL_SYSID = 0meant "follow the first vehicle we hear from": AP_Follow wrote thefirst sender's system id into the parameter, and cleared it back to zero if that
vehicle went quiet for ten seconds. So the library mutated a user facing parameter
on its own, and the target was chosen by message arrival order rather than by
configuration.
MAV_CMD_DO_FOLLOWalready rejects a target id of zero, so thismakes the parameter agree with the command interface.
Zero now means no target is selected: no target message is accepted and the library
never writes
FOLL_SYSID. The second commit is a rename only, sinceAP_FOLLOW_SYSID_TIMEOUT_MSno longer has anything to do with the system id.Behaviour change. Anyone relying on the default of zero to follow a single lead
vehicle must now set
FOLL_SYSID. In Copter, FOLLOW mode holds position instead.Worth a release note.