intraw_dx,raw_dy;// raw sensor change in x and y position (i.e. unrotated)
intsurface_quality;// image quality (below 15 you really can't trust the x,y values returned)
intx,y;// total x,y position
intdx,dy;// rotated change in x and y position
floatvlon,vlat;// position as offsets from original position
unsignedlonglast_update;// millis() time of last update
floatfield_of_view;// field of view in Radians
floatscaler;// number returned from sensor when moved one pixel
intnum_pixels;// number of pixels of resolution in the sensor
// temp variables - delete me!
floatexp_change_x,exp_change_y;
floatchange_x,change_y;
floatx_cm,y_cm;
AP_OpticalFlow(){_sensor=this;};
~AP_OpticalFlow(){_sensor=NULL;};
virtualboolinit(boolinitCommAPI=true);// parameter controls whether I2C/SPI interface is initialised (set to false if other devices are on the I2C/SPI bus and have already initialised the interface)
virtualvoidset_field_of_view(constfloatfov){field_of_view=fov;update_conversion_factors();};// sets field of view of sensor
staticvoidread(uint32_t){if(_sensor!=NULL)_sensor->update();};// call to update all attached sensors
virtualboolupdate();// read latest values from sensor and fill in x,y and totals. returns true on success
virtualvoidupdate_position(floatroll,floatpitch,floatcos_yaw_x,floatsin_yaw_y,floataltitude);// updates internal lon and lat with estimation based on optical flow
protected:
staticAP_OpticalFlow*_sensor;// pointer to the last instantiated optical flow sensor. Will be turned into a table if we ever add support for more than one sensor