ardupilot/libraries/AP_OpticalFlow/AP_OpticalFlow_UPFLOW.h

43 lines
1.5 KiB
C
Raw Normal View History

2021-03-12 07:56:34 -04:00
#pragma once
#include "AP_OpticalFlow_config.h"
#if AP_OPTICALFLOW_UPFLOW_ENABLED
#include "AP_OpticalFlow_Backend.h"
2021-03-12 07:56:34 -04:00
#include <AP_HAL/utility/OwnPtr.h>
class AP_OpticalFlow_UPFLOW : public OpticalFlow_backend
{
public:
/// constructor
AP_OpticalFlow_UPFLOW(AP_OpticalFlow &_frontend, AP_HAL::UARTDriver *uart);
2021-03-12 07:56:34 -04:00
// initialise the sensor
void init() override;
// read latest values from sensor and fill in x,y and totals.
void update(void) override;
// detect if the sensor is available
static AP_OpticalFlow_UPFLOW *detect(AP_OpticalFlow &_frontend);
2021-03-12 07:56:34 -04:00
private:
struct PACKED UpixelsOpticalFlow {
int16_t flow_x_integral; //unit:10^-4 radians multiply by 10^-4 to get radians
int16_t flow_y_integral; //unit:10^-4 radians multiply by 10^-4 to get radians
uint16_t integration_timespan; //dt in us
uint16_t ground_distance; //reserved, always 999
uint8_t quality; //0 for not valid, 245 for valid.
uint8_t version;
};
AP_HAL::UARTDriver *uart; // uart connected to flow sensor
struct UpixelsOpticalFlow updata; // struct for received data
uint16_t recv_count; // amount of bytes received
uint8_t sum; //checksum
Vector2f gyro_sum; // sum of gyro sensor values since last frame from flow sensor
uint16_t gyro_sum_count; // number of gyro sensor values in sum
};
#endif // AP_OPTICALFLOW_UPFLOW_ENABLED