Fix: Stop gimbal from spinning when an angular velocity setpoint stream times out #23825
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.
Solved Problem
When an angular velocity setpoint (
gimbal_manager_set_manual_control
) stops streaming while still commanding non-zero velocity, the gimbal continues turning indefinitely.Context:
I found this when working with a gimbal that can be steered by a lever but also a "level out" button it's crucial to not constantly send the lever-based angular velocity setpoint (
gimbal_manager_set_manual_control
) because that overrides any button-based attitude setpoint (gimbal_manager_set_attitude
) immediately again. Solution: only send angular velocity setpoints when the lever is actually deflected and stop sending them when they are zero. But what happens if you lose connection?Solution
Changelog Entry
Alternatives
@julianoes I'm eager to find out if you have any better idea or implementation architecture in mind to solve this problem.
Test coverage
I tested using MAVLink gimbal V2 as in- and output. I mapped a lever to gimbal pitch-rate and shut the input MAVLink connection while the lever was deflected and gimbal moving. Before the change it would continue spinning indefinitely, with my pr there is no update anymore for 2 seconds and then there is one single update that commands the gimbal to 0 pitch-rate and it stops. Note: When I tried NAN that caused the gimbal to reset its orientation which I consider undesired e.g. during connection dropouts.