Skip to content

Feat/state machine callbacks#91

Merged
Elan456 merged 10 commits intomainfrom
feat/state-machine-callbacks
Mar 31, 2026
Merged

Feat/state machine callbacks#91
Elan456 merged 10 commits intomainfrom
feat/state-machine-callbacks

Conversation

@Elan456
Copy link
Copy Markdown
Contributor

@Elan456 Elan456 commented Mar 30, 2026

Description

Adds methods to the BaseStateMachine to allow for registering function to be called on state entry.

Summary of Changes

  • BaseStateMachine stores an array of function ptrs for callbacks
  • Add registerOnStateEntry to add new functions for callbacks
  • Add a changeState method which should now always be used to change states in a state machine because it will check and call the callbacks.
  • Make the state_ variable private, so that you cannot change it unless you use the changeState method.

Motivation


Testing

Check all that apply:

  • I have added or modified unit tests to cover these changes.
  • I have manually tested the changes on the target device(s) or environment(s).
  • Existing tests were reviewed to ensure they still work as expected.
  • If tests were not added or modified, explain why:

    (Provide reasoning here)


Checklist

  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have commented my code where necessary for clarity.
  • I have made corresponding updates to documentation (if applicable).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

I read the AGENTS.md.

Adds shared state ownership and state-entry callback dispatch to the state machine framework, so external components can register hooks that run when a flight state is entered.

Changes:

  • Introduces BaseStateMachine state tracking plus fixed-capacity state-entry callback registration/dispatch.
  • Updates StateMachine and BurnoutStateMachine to transition via changeState() and read state via getFlightState().
  • Makes FlightState explicitly uint8_t with fixed numeric values and updates state-estimation README notes.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/state_estimation/StateMachine.cpp Uses BaseStateMachine state storage and changeState() transitions.
src/state_estimation/BurnoutStateMachine.cpp Migrates transitions/state reads to the new base functionality.
src/state_estimation/BaseStateMachine.cpp Implements callback registration and dispatch on state transitions.
include/state_estimation/States.h Makes FlightState an explicit uint8_t enum with fixed values.
include/state_estimation/StateMachine.h Removes local state_ storage and getState() override.
include/state_estimation/BurnoutStateMachine.h Removes local state_ storage and getState() override.
include/state_estimation/BaseStateMachine.h Defines the callback API, fixed-capacity storage, and state encapsulation.
include/state_estimation/README.md Updates documentation to reflect callback support and capacity/no-allocation design.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

@Elan456 Elan456 requested a review from Jshepherd06 March 31, 2026 16:58
Copy link
Copy Markdown
Contributor

@Jshepherd06 Jshepherd06 left a comment

Choose a reason for hiding this comment

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

Looks good to me

@Elan456 Elan456 merged commit 7a4a582 into main Mar 31, 2026
3 checks passed
@Elan456 Elan456 deleted the feat/state-machine-callbacks branch March 31, 2026 21:51
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.

3 participants