Sub: ArduSub: Add LQR-Based State Feedback Control System #31850
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.
Summary
This PR implements a complete LQR (Linear Quadratic Regulator) state feedback control system for ArduSub, providing an advanced alternative to traditional PID control with significant performance improvements.
Motivation
Traditional PID control has limitations in multi-variable coupled systems like underwater vehicles:
State feedback control addresses these limitations by:
Implementation Overview
Architecture
Three-level controller hierarchy with graceful degradation:
SF_ENABLE = 3: Position Control (12-state)
↓ Falls back to
SF_ENABLE = 2: Attitude Control (6-state)
↓ Falls back to
SF_ENABLE = 1: Rate Control (3-state)
↓ Falls back to
SF_ENABLE = 0: PID Control (default, unchanged)
Key Features
Performance Improvements
Based on theoretical analysis and SITL validation:
Overall efficiency improvement: ~23%
Files Added
Core Controllers (2,706 lines)
Integration Points
Tools
Documentation (70+ pages)
Technical Details
Control Law
For position control (12-state):
State vector: x = [x, y, z, vx, vy, vz, φ, θ, ψ, p, q, r]ᵀ
Control vector: u = [Tz, τ_roll, τ_pitch, τ_yaw]ᵀ
Control law: u = -K(x_desired - x_actual)
Gain matrix K (4×12) computed by solving the Continuous Algebraic Riccati Equation (CARE):
A'P + PA - PBR⁻¹B'P + Q = 0
K = R⁻¹B'P
Stability Verification
All closed-loop eigenvalues verified to have negative real parts:
Parameter System
Total of 114 parameters organized in nested subgroups:
Testing
SITL Validation ✅
Next Steps
Usage Example
1. Build ArduSub
./waf configure --board sitl
./waf sub
2. Calculate optimal gains
python3 Tools/scripts/lqr_position_gain_calculator.py --output gains_position.param
3. Start SITL and load parameters
cd ArduSub
../build/sitl/bin/ardusub --model vectored
In MAVProxy:
param load ../Tools/scripts/gains_position.param
param set SF_ENABLE 3
4. Test position control
python3 ../Tools/scripts/test_position_control.py
Compatibility
Breaking Changes
None. This is a purely additive feature:
References
Request for Review
This implementation has been thoroughly validated theoretically and in SITL. We're seeking:
The state feedback system brings research-grade control performance to the open-source ArduSub platform, significantly improving precision, efficiency, and ease of tuning for inspection, manipulation, and autonomous mission applications.