AP_OpticalFlow_test.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Example of AP_OpticalFlow library.
  3. * Code by Randy Mackay. DIYDrones.com
  4. */
  5. #include <AP_AHRS/AP_AHRS.h>
  6. #include <AP_Baro/AP_Baro.h>
  7. #include <AP_Compass/AP_Compass.h>
  8. #include <AP_GPS/AP_GPS.h>
  9. #include <AP_HAL/AP_HAL.h>
  10. #include <AP_InertialSensor/AP_InertialSensor.h>
  11. #include <AP_NavEKF2/AP_NavEKF2.h>
  12. #include <AP_NavEKF3/AP_NavEKF3.h>
  13. #include <AP_OpticalFlow/AP_OpticalFlow.h>
  14. #include <AP_RangeFinder/AP_RangeFinder.h>
  15. void setup();
  16. void loop();
  17. const AP_HAL::HAL& hal = AP_HAL::get_HAL();
  18. class DummyVehicle {
  19. public:
  20. AP_GPS gps;
  21. AP_Baro barometer;
  22. Compass compass;
  23. AP_InertialSensor ins;
  24. AP_SerialManager serial_manager;
  25. RangeFinder sonar;
  26. AP_AHRS_NavEKF ahrs{EKF2, EKF3, AP_AHRS_NavEKF::FLAG_ALWAYS_USE_EKF};
  27. NavEKF2 EKF2{&ahrs, sonar};
  28. NavEKF3 EKF3{&ahrs, sonar};
  29. };
  30. static DummyVehicle vehicle;
  31. static OpticalFlow optflow;
  32. void setup()
  33. {
  34. hal.console->printf("OpticalFlow library test ver 1.6\n");
  35. hal.scheduler->delay(1000);
  36. // flowSensor initialization
  37. optflow.init(-1);
  38. if (!optflow.healthy()) {
  39. hal.console->printf("Failed to initialise PX4Flow ");
  40. }
  41. hal.scheduler->delay(1000);
  42. }
  43. void loop()
  44. {
  45. hal.console->printf("this only tests compilation succeeds\n");
  46. hal.scheduler->delay(5000);
  47. }
  48. AP_HAL_MAIN();