Skip to content

fix(ManualAltitudeSmoothVel): respect terrain lock when smoothing#27270

Closed
julianoes wants to merge 1 commit into
mainfrom
pr-terrain-follow-fix
Closed

fix(ManualAltitudeSmoothVel): respect terrain lock when smoothing#27270
julianoes wants to merge 1 commit into
mainfrom
pr-terrain-follow-fix

Conversation

@julianoes
Copy link
Copy Markdown
Contributor

@julianoes julianoes commented May 4, 2026

Solved Problem

_setOutputState only skipped overwriting _position_setpoint(2) when _terrain_hold was true, which is exclusively a MPC_ALT_MODE 2 (terrain hold) signal.

In MPC_ALT_MODE 1 (terrain following) the climb/descend target computed by _terrainFollowing in the parent class was therefore stomped every cycle with the velocity-integrated smoother position, so the controller never saw the AGL-maintaining setpoint and the vehicle flew at fixed Z across terrain when it should do continuous terrain following.

Solution

Switch the gate to a combined signal that also covers an active _dist_to_ground_lock, which mode 1 _terrainFollowing leaves finite whenever it is updating the position setpoint. Move the lock member to protected so the smoother subclass can read it.

Changelog Entry

For release notes:

Bugfix for terrain following (MPC_ALT_MODE 1) when smoothing is enabled.

FYI @reedev

_setOutputState only skipped overwriting _position_setpoint(2) when
_terrain_hold was true, which is exclusively a MPC_ALT_MODE 2 (terrain
hold) signal.

In MPC_ALT_MODE 1 (terrain following) the climb/descend target computed
by _terrainFollowing in the parent class was therefore stomped every
cycle with the velocity-integrated smoother position, so the controller
never saw the AGL-maintaining setpoint and the vehicle flew at fixed Z
across terrain when it should do continuous terrain following.

Switch the gate to a combined signal that also covers an active
_dist_to_ground_lock, which mode 1 _terrainFollowing leaves finite
whenever it is updating the position setpoint. Move the lock member to
protected so the smoother subclass can read it.

Signed-off-by: Julian Oes <julian@oes.ch>
@julianoes julianoes requested review from AlexKlimaj and dakejahl May 4, 2026 02:19
@github-actions github-actions Bot added kind:bug Something is broken or behaving incorrectly. risk:safety-critical May affect arming, failsafe, control, navigation, or flight safety. scope:control Rate, attitude, position, allocation, or actuator control. labels May 4, 2026
@julianoes
Copy link
Copy Markdown
Contributor Author

@dakejahl looks like that's similar to #26975.

@julianoes
Copy link
Copy Markdown
Contributor Author

#26975 is better.

@julianoes julianoes closed this May 4, 2026
@julianoes julianoes deleted the pr-terrain-follow-fix branch May 4, 2026 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:bug Something is broken or behaving incorrectly. risk:safety-critical May affect arming, failsafe, control, navigation, or flight safety. scope:control Rate, attitude, position, allocation, or actuator control.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant