Skip to content

Conversation

MaEtUgR
Copy link
Member

@MaEtUgR MaEtUgR commented Sep 22, 2025

Solved Problem

I came across #25551 too late, but realized it's the implementation of a hysteresis/delay and there might be an opportunity to simplify the navigator for better readability, so I’m suggesting this follow-up.

Solution

  • Use the existing hysteresis library for the neutral gimbal command delay, it uses a bit more RAM but is well tested and has a simple interface.
  • Unroll tiny functions that are only called once and for which the reader needs to jump to the end of the file and back.
  • Reduce hrt_absolute_time() calls which all have an insignificantly different timestamp as a result and reuse a loop timestamp instead.

Changelog Entry

Navigator: Use hysteresis for neutral gimbal command delay + some refactoring

Test coverage

Not tested, it should be a pure refactor. The thing that would be nicest to verify is that I used the hysteresis correctly.

@MaEtUgR MaEtUgR requested a review from perrrre September 22, 2025 15:08
@MaEtUgR MaEtUgR self-assigned this Sep 22, 2025
acquire_gimbal_control();
set_gimbal_neutral();
release_gimbal_control();
_gimbal_neutral_hysteresis.set_state_and_update(false, now);
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to put a comment that the time from true is 0, or maybe add this?

_gimbal_neutral_hysteresis.set_hysteresis_time_from(true, 0);

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