mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-04-22 23:06:37 +00:00
1.5 KiB
1.5 KiB
Robust Kernels Helper
Interface Definition
Interface Name: IRobustKernels
Interface Methods
class IRobustKernels(ABC):
@abstractmethod
def huber_loss(self, error: float, threshold: float) -> float:
pass
@abstractmethod
def cauchy_loss(self, error: float, k: float) -> float:
pass
@abstractmethod
def compute_weight(self, error: float, kernel_type: str, params: Dict[str, float]) -> float:
pass
Component Description
Huber/Cauchy loss functions for outlier rejection in optimization.
API Methods
huber_loss(error: float, threshold: float) -> float
Description: Huber robust loss function.
Formula:
if |error| <= threshold:
loss = 0.5 * error^2
else:
loss = threshold * (|error| - 0.5 * threshold)
Purpose: Quadratic for small errors, linear for large errors (outliers).
cauchy_loss(error: float, k: float) -> float
Description: Cauchy robust loss function.
Formula:
loss = (k^2 / 2) * log(1 + (error/k)^2)
Purpose: More aggressive outlier rejection than Huber.
compute_weight(error: float, kernel_type: str, params: Dict[str, float]) -> float
Description: Computes robust weight for error.
Usage: Factor Graph applies weights to downweight outliers.
Dependencies
External: numpy
Test Cases
- Small error → weight ≈ 1.0
- Large error (350m outlier) → weight ≈ 0.1 (downweighted)
- Huber vs Cauchy → Cauchy more aggressive