AP_NavEKF_core_common.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. NavEKF_core_common holds scratch data shared by EKF2 and EKF3
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #pragma once
  15. #include <stdint.h>
  16. #include <AP_Math/AP_Math.h>
  17. #include <AP_Math/vectorN.h>
  18. /*
  19. this declares a common parent class for AP_NavEKF2 and
  20. AP_NavEKF3. The purpose of this class is to hold common static
  21. scratch space variables. These variables do not hold anything that
  22. matters between iterations, they are only intermediate variables. By
  23. placing these in a common parent class we save a lot of memory, but
  24. we also save a lot of CPU (approx 10% on STM32F427) as the compiler
  25. is able to resolve the address of these variables at compile time,
  26. which means significantly faster code
  27. */
  28. class NavEKF_core_common {
  29. public:
  30. typedef float ftype;
  31. #if MATH_CHECK_INDEXES
  32. typedef VectorN<ftype,28> Vector28;
  33. typedef VectorN<VectorN<ftype,24>,24> Matrix24;
  34. #else
  35. typedef ftype Vector28[28];
  36. typedef ftype Matrix24[24][24];
  37. #endif
  38. protected:
  39. static Matrix24 KH; // intermediate result used for covariance updates
  40. static Matrix24 KHP; // intermediate result used for covariance updates
  41. static Matrix24 nextP; // Predicted covariance matrix before addition of process noise to diagonals
  42. static Vector28 Kfusion; // intermediate fusion vector
  43. // fill all the common scratch variables with NaN on SITL
  44. void fill_scratch_variables(void);
  45. };