Skip to content

Conversation

@HTRamsey
Copy link
Collaborator

Summary

Complete migration of state machines from legacy array-based StateMachine to modern Qt-based QGCStateMachine framework built on QStateMachine.

Framework Enhancements

New State Types:

  • AsyncFunctionState - async operations with timeout support
  • SkippableAsyncState - conditional skip + async operation
  • ConditionalState - branch based on predicate
  • ParallelState - concurrent state execution
  • SubMachineState - nested state machine support
  • WaitForSignalState - wait for Qt signal with timeout

New Transition Types:

  • GuardedTransition - conditional signal transitions
  • InternalTransition - self-transitions without exit/entry
  • SignalDataTransition - type-safe signal argument capture
  • NamedEventTransition - string-based event matching
  • MachineEventTransition - typed event handling

QGCStateMachine Features:

  • Global and local error state handling
  • Property restore on state exit
  • Delayed event posting with cancellation
  • Factory methods for common state types

Migrated State Machines

  • InitialConnectStateMachine - rewritten with proper Qt states, weighted progress tracking, SkippableAsyncState for conditional plan loading
  • ComponentInformationManager - extracted RequestMetaDataTypeStateMachine, proper async FTP/HTTP download handling

Code Organization

  • States moved to src/Utilities/StateMachine/states/
  • Transitions moved to src/Utilities/StateMachine/transitions/
  • Removed legacy StateMachine class
  • Test structure mirrors source organization

Test Plan

  • 18 state machine test classes pass (39 test methods)
  • New VehicleTest for vehicle state machine integration
  • Enhanced InitialConnectTest, ComponentInformationManagerTest
  • Re-enabled RequestMessageTest, SendMavCommandWithHandlerTest, SendMavCommandWithSignallingTest
  • All existing unit tests pass
  • Manual testing with PX4 SITL
  • Manual testing with ArduPilot SITL

Copilot AI review requested due to automatic review settings January 31, 2026 11:26
Copy link
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

This pull request completes a comprehensive migration from a legacy array-based StateMachine implementation to a modern Qt-based QGCStateMachine framework built on QStateMachine. The migration introduces new state types (AsyncFunctionState, SkippableAsyncState, ConditionalState, ParallelState, SubMachineState, WaitForSignalState) and transition types (GuardedTransition, SignalDataTransition, InternalTransition, MachineEventTransition), along with enhanced error handling, progress tracking, and property restoration capabilities.

Changes:

  • Migrated InitialConnectStateMachine and ComponentInformationManager to Qt-based framework with proper async state handling
  • Added comprehensive test suite with 18 test classes covering states, transitions, and integration
  • Removed legacy StateMachine class and reorganized code into states/ and transitions/ subdirectories

Reviewed changes

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

Show a summary per file
File Description
test/Vehicle/VehicleTest.h/cc New integration tests for vehicle state machine coordination
test/Vehicle/InitialConnectTest.cc Enhanced tests with progress tracking and reconnect scenarios
test/Vehicle/ComponentInformation/* New tests for component information state machines
test/Utilities/StateMachine/* Comprehensive test suite for all state and transition types
src/Utilities/StateMachine/QGCStateMachine.h/cc Enhanced state machine with error handling, events, and factory methods
src/Utilities/StateMachine/states/* New state implementations with async, conditional, and wait support
src/Utilities/StateMachine/transitions/* New transition types with guards and signal data capture
src/Vehicle/InitialConnectStateMachine.h/cc Migrated to Qt framework with weighted progress tracking
src/Vehicle/ComponentInformation/* Extracted RequestMetaDataTypeStateMachine with proper async handling
src/Vehicle/Vehicle.cc Removed legacy completion handlers, MAV_CMD_REQUEST_MESSAGE duplicate handling

@HTRamsey HTRamsey force-pushed the feature/statemachine-enhancements branch from 750dfc7 to ca4ec93 Compare January 31, 2026 11:43
@github-actions
Copy link
Contributor

github-actions bot commented Jan 31, 2026

Build Results

Platform Status

Platform Status Details
Linux Failed View
Windows Passed View
MacOS Passed View
Android Passed View

Some builds failed.

Artifact Sizes

Artifact Size
QGroundControl-installer-AMD64-ARM64.exe 74.79 MB
QGroundControl-installer-AMD64.exe 162.67 MB
QGroundControl-installer-ARM64.exe 75.63 MB
QGroundControl-mac.apk 138.69 MB
QGroundControl-windows.apk 138.69 MB
QGroundControl.apk 306.30 MB
QGroundControl.dmg 312.43 MB

No baseline available for comparison

Updated: 2026-02-01 21:20:06 UTC • Triggered by: Android

@HTRamsey HTRamsey force-pushed the feature/statemachine-enhancements branch 3 times, most recently from 63edfe8 to abb5b2e Compare January 31, 2026 12:47
@HTRamsey HTRamsey requested a review from DonLakeFlyer January 31, 2026 17:29
@DonLakeFlyer
Copy link
Collaborator

Ooh, fantastic stuff!

@HTRamsey HTRamsey force-pushed the feature/statemachine-enhancements branch from abb5b2e to 6609449 Compare February 1, 2026 10:16
@HTRamsey HTRamsey force-pushed the feature/statemachine-enhancements branch from 6609449 to 74e9ab4 Compare February 1, 2026 11:15
@github-actions github-actions bot removed the MAVLink label Feb 1, 2026
@HTRamsey HTRamsey force-pushed the feature/statemachine-enhancements branch 10 times, most recently from b40cd46 to a4a43b6 Compare February 1, 2026 19:00
@HTRamsey
Copy link
Collaborator Author

HTRamsey commented Feb 1, 2026

"One significant problem with current code is that the CameraManager doesn't play into Initial Connect when it should. This in turns causes all sorts of overlap happening on initial connect wherer things should be sequenced. Would be awesome if you could clean that up."

@HTRamsey HTRamsey force-pushed the feature/statemachine-enhancements branch from a4a43b6 to 7a0f8d1 Compare February 1, 2026 19:42
Complete migration of state machines from legacy array-based StateMachine
to modern Qt-based QGCStateMachine framework built on QStateMachine.

- AsyncFunctionState: async operations with timeout support
- SkippableAsyncState: conditional skip + async operation
- ConditionalState: branch based on predicate
- ParallelState: concurrent state execution
- SubMachineState: nested state machine support
- WaitForSignalState: wait for Qt signal with timeout

- GuardedTransition: conditional signal transitions
- InternalTransition: self-transitions without exit/entry
- SignalDataTransition: type-safe signal argument capture
- NamedEventTransition: string-based event matching
- MachineEventTransition: typed QGCStateMachineEvent handling

- Global and local error state handling
- Property restore on state exit
- Delayed event posting with cancellation
- Factory methods for common state types
- Progress tracking integration

- Rewritten using QGCStateMachine with proper Qt states
- ProgressTracker for weighted progress calculation
- SkippableAsyncState for conditional plan loading (high latency, etc.)
- Cleaner separation of state logic

- Extracted RequestMetaDataTypeStateMachine for metadata requests
- Uses SkippableAsyncState for deprecated/fallback paths
- Proper async handling for FTP/HTTP downloads

- States moved to src/Utilities/StateMachine/states/
- Transitions moved to src/Utilities/StateMachine/transitions/
- Removed legacy StateMachine class (no longer used)
- Test structure mirrors source organization

- 18 state machine test classes (39 test methods)
- New VehicleTest for vehicle state machine integration
- Enhanced InitialConnectTest, ComponentInformationManagerTest
- Re-enabled RequestMessageTest, SendMavCommandWithHandlerTest,
  SendMavCommandWithSignallingTest

- Added MAV_CMD_REQUEST_MESSAGE to _commandCanBeDuplicated()
- ParameterManager test timeout configuration
@HTRamsey HTRamsey force-pushed the feature/statemachine-enhancements branch from 7a0f8d1 to e5a6eb6 Compare February 1, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants