AP_Nav_Common.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. AP_Nav_Common holds definitions shared by inertial and ekf nav filters
  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. union nav_filter_status {
  17. struct {
  18. bool attitude : 1; // 0 - true if attitude estimate is valid
  19. bool horiz_vel : 1; // 1 - true if horizontal velocity estimate is valid
  20. bool vert_vel : 1; // 2 - true if the vertical velocity estimate is valid
  21. bool horiz_pos_rel : 1; // 3 - true if the relative horizontal position estimate is valid
  22. bool horiz_pos_abs : 1; // 4 - true if the absolute horizontal position estimate is valid
  23. bool vert_pos : 1; // 5 - true if the vertical position estimate is valid
  24. bool terrain_alt : 1; // 6 - true if the terrain height estimate is valid
  25. bool const_pos_mode : 1; // 7 - true if we are in const position mode
  26. bool pred_horiz_pos_rel : 1; // 8 - true if filter expects it can produce a good relative horizontal position estimate - used before takeoff
  27. bool pred_horiz_pos_abs : 1; // 9 - true if filter expects it can produce a good absolute horizontal position estimate - used before takeoff
  28. bool takeoff_detected : 1; // 10 - true if optical flow takeoff has been detected
  29. bool takeoff : 1; // 11 - true if filter is compensating for baro errors during takeoff
  30. bool touchdown : 1; // 12 - true if filter is compensating for baro errors during touchdown
  31. bool using_gps : 1; // 13 - true if we are using GPS position
  32. bool gps_glitching : 1; // 14 - true if GPS glitching is affecting navigation accuracy
  33. bool gps_quality_good : 1; // 15 - true if we can use GPS for navigation
  34. } flags;
  35. uint16_t value;
  36. };
  37. static_assert(sizeof(uint16_t) == sizeof(nav_filter_status), "nav_filter_status must be uint16_t");
  38. union nav_gps_status {
  39. struct {
  40. bool bad_sAcc : 1; // 0 - true if reported gps speed accuracy is insufficient to start using GPS
  41. bool bad_hAcc : 1; // 1 - true if reported gps horizontal position accuracy is insufficient to start using GPS
  42. bool bad_yaw : 1; // 2 - true if EKF yaw errors are too large to start using GPS
  43. bool bad_sats : 1; // 3 - true if the number of satellites is insufficient to start using GPS
  44. bool bad_VZ : 1; // 4 - true if the vertical velocity is inconsistent with the inertial/baro
  45. bool bad_horiz_drift : 1; // 5 - true if the GPS horizontal position is drifting (this check assumes vehicle is static)
  46. bool bad_hdop : 1; // 6 - true if the reported HDoP is insufficient to start using GPS
  47. bool bad_vert_vel : 1; // 7 - true if the GPS vertical speed is too large to start using GPS (this check assumes vehicle is static)
  48. bool bad_fix : 1; // 8 - true if the GPS is not providing a 3D fix
  49. bool bad_horiz_vel : 1; // 9 - true if the GPS horizontal speed is excessive (this check assumes the vehicle is static)
  50. bool bad_vAcc : 1; // 10 - true if reported gps vertical position accuracy is insufficient to start using GPS
  51. } flags;
  52. uint16_t value;
  53. };
  54. static_assert(sizeof(uint16_t) == sizeof(nav_gps_status), "nav_gps_status must be uint16_t");
  55. /*
  56. structure to hold EKF timing statistics
  57. */
  58. struct ekf_timing {
  59. uint32_t count;
  60. float dtIMUavg_min;
  61. float dtIMUavg_max;
  62. float dtEKFavg_min;
  63. float dtEKFavg_max;
  64. float delAngDT_max;
  65. float delAngDT_min;
  66. float delVelDT_max;
  67. float delVelDT_min;
  68. };
  69. void Log_EKF_Timing(const char *name, uint64_t time_us, const struct ekf_timing &timing);