AP_OpticalFlow_PX4Flow.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #pragma once
  2. #include "OpticalFlow.h"
  3. #include <AP_HAL/utility/OwnPtr.h>
  4. class AP_OpticalFlow_PX4Flow : public OpticalFlow_backend
  5. {
  6. public:
  7. /// constructor
  8. AP_OpticalFlow_PX4Flow(OpticalFlow &_frontend);
  9. // init - initialise the sensor
  10. void init() override {}
  11. // update - read latest values from sensor and fill in x,y and totals.
  12. void update(void) override;
  13. // detect if the sensor is available
  14. static AP_OpticalFlow_PX4Flow *detect(OpticalFlow &_frontend);
  15. private:
  16. AP_HAL::OwnPtr<AP_HAL::Device> dev;
  17. static const uint8_t REG_INTEGRAL_FRAME = 0x16;
  18. // I2C data on register REG_INTEGRAL_FRAME
  19. struct PACKED i2c_integral_frame {
  20. uint16_t frame_count_since_last_readout;
  21. int16_t pixel_flow_x_integral;
  22. int16_t pixel_flow_y_integral;
  23. int16_t gyro_x_rate_integral;
  24. int16_t gyro_y_rate_integral;
  25. int16_t gyro_z_rate_integral;
  26. uint32_t integration_timespan;
  27. uint32_t sonar_timestamp;
  28. uint16_t ground_distance;
  29. int16_t gyro_temperature;
  30. uint8_t qual;
  31. };
  32. // scan I2C bus addresses and buses
  33. bool scan_buses(void);
  34. // setup sensor
  35. bool setup_sensor(void);
  36. void timer(void);
  37. };