How px4/px4-ecl works
The ECL project is a lightweight library focused on estimation and control algorithms for drones and other robots. It is designed as a static library (with C++ as the primary language) that implements an Extended Kalman Filter (EKF) as its core, along with additional components for filtering (like the AlphaFilter), sensor simulation, and sensor data processing. The README’s notes on sensor fusion, replay tests, and the detailed EKF documentation indicate that the library is meant to be highly modular and integrated within embedded flight software (as evidenced by its close ties with PX4).
Main Components of the System
• EKF Core Module – This is the heart of the project (found in the EKF directory). It includes various files implementing prediction, covariance prediction, sensor fusion (GPS, mag, airspeed, optical flow, etc.), as well as interfaces for reading sensor data.
• Sensor Simulator and Test Harness – Located in the “test” and “test/sensor_simulator” directories, these components help run replay tests, comparing simulation output to expected EKF state outputs.
• Data Processing Modules – Other modules like AlphaFilter, WindEstimator (in the airdata directory), geo, and geo_lookup provide supporting functionalities such as filtering, geographic computations, and magnetic declination look-ups.
• Analysis and Derivation Scripts – In the “EKF/matlab” and “EKF/python” directories you see MATLAB scripts for replaying and analyzing filter performance and Python code that even auto-generates portions of the derivation (intermediate code for fusion logic). They serve as developer utilities for tuning the EKF.
• Build & CI Tooling – The project has CMake files, Travis CI, and GitHub workflows that manage builds, unit tests, formatting, and change indication—which is a specific test mode that verifies functional changes in the EKF output.
• Auxiliary Libraries – The inclusion of directories like “mathlib” (for matrix math) and “geo” provides helper APIs that the EKF uses to perform computations for control and estimation.
Relationships and Interactions
• Pre- and Post-Processing: External modules (like AlphaFilter and WindEstimator) might pre-filter or post-process data before/after the main EKF processing.
• CI/Build System: Represent the build system as an external pipeline component that orchestrates builds (using CMake/Make) and runs tests and format checks via GitHub Actions and Travis.
Architectural Patterns & Design Principles
• Modular Design: Each component (estimation, sensor simulation, utility libraries) is separated into its own directory, indicating a clear separation of concerns.
• Code Reuse via Shared Utilities: Libraries like “matrix”, “geo”, and “AlphaFilter” are shared resources, so denote these as common services that the EKF and other modules depend upon.