Line data Source code
1 : #pragma once 2 : 3 : #include "AP_OpticalFlow_config.h" 4 : 5 : #if HAL_MSP_OPTICALFLOW_ENABLED 6 : 7 : #include "AP_OpticalFlow.h" 8 : 9 : class AP_OpticalFlow_MSP : public OpticalFlow_backend 10 : { 11 : public: 12 : /// constructor 13 : using OpticalFlow_backend::OpticalFlow_backend; 14 : 15 : // initialise the sensor 16 0 : void init() override {} 17 : 18 : // read latest values from sensor and fill in x,y and totals. 19 : void update(void) override; 20 : 21 : // get update from msp 22 : void handle_msp(const MSP::msp_opflow_data_message_t &pkt) override; 23 : 24 : // detect if the sensor is available 25 : static AP_OpticalFlow_MSP *detect(AP_OpticalFlow &_frontend); 26 : 27 : private: 28 : 29 : uint64_t prev_frame_us; // system time of last message when update was last called 30 : uint64_t latest_frame_us; // system time of most recent messages processed 31 : Vector2l flow_sum; // sum of sensor's flow_x and flow_y values since last call to update 32 : uint16_t quality_sum; // sum of sensor's quality values since last call to update 33 : uint16_t count; // number of sensor readings since last call to update 34 : Vector2f gyro_sum; // sum of gyro sensor values since last frame from flow sensor 35 : uint16_t gyro_sum_count; // number of gyro sensor values in sum 36 : }; 37 : 38 : #endif // HAL_MSP_OPTICALFLOW_ENABLED