-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Whether increasing uncertainty when clamping occurs is a good practice depends on the specific context and system requirements. Here's a balanced analysis:
When It's Good Practice ✅
-
Safety-Critical Systems
- Clamping indicates the filter is operating at its limits
- Increasing uncertainty properly reflects reduced confidence in the estimate
- Prevents the filter from being overconfident in an artificial boundary
-
Physical Systems with Known Limits
- For wave height estimation, if you hit the ±10m clamp:
if (x(1) == -MAX_HEAVE || x(1) == MAX_HEAVE) { P(1,1) = std::max(P(1,1), MAX_HEAVE); // Reflect heave uncertainty }
- Mathematically represents: "We're at a physical limit, so our estimate is less certain"
- For wave height estimation, if you hit the ±10m clamp:
-
Fault Detection
- A sudden covariance increase can trigger maintenance alerts
- Useful for diagnostics (e.g., "System has been at max heave for 10 cycles")
When It's Problematic ❌
-
Overly Conservative Systems
- May cause unnecessary rejection of good measurements
- Example issue:
// Bad - blindly increasing covariance P *= 2.0; // Overly aggressive
-
Oscillation Risk
- If the covariance grows too much → Kalman gain decreases → system stops correcting → remains clamped
-
Masking Real Errors
- Could hide sensor faults by always blaming "uncertainty"
Recommended Implementation
For your wave estimation filter, a balanced approach would be:
void enforceStateBounds() {
constexpr float MAX_HEAVE = 10.0f;
constexpr float COVARIANCE_PENALTY = 2.0f; // 2x uncertainty
if (x(1) != std::clamp(x(1), -MAX_HEAVE, MAX_HEAVE)) {
// Only increase uncertainty if clamping was actually needed
x(1) = std::clamp(x(1), -MAX_HEAVE, MAX_HEAVE);
// Gradual covariance increase (avoids oscillations)
P(1,1) = std::max(P(1,1), metrics.position_std_dev * COVARIANCE_PENALTY);
// Optional: Log this event for diagnostics
metrics.bounds_clamped = true;
}
// Repeat for other states...
}
Alternatives to Consider
-
Soft Constraints (Better for many cases):
// Add penalty term to measurement update when near bounds if (std::abs(x(1)) > 0.9 * MAX_HEAVE) { R(0,0) *= 1.5f; // Decrease trust in position measurements }
-
Projection-Based Methods:
$$P_{clamped} = P - K(HPH^T)K^T$$ Where ( K ) is a projection matrix that enforces constraints while preserving consistency.
Best Practice for Your Use Case
For wave estimation:
✅ Do increase uncertainty when clamping (but moderately) because:
- Waves have physical limits
- Prevents filter overconfidence at boundaries
- Matches real-world behavior (extreme waves are harder to model)
❌ Don't use aggressive covariance inflation (e.g., 10x) as it could destabilize the bias estimation.
Would you like me to show how to implement the soft constraints approach as an alternative?