// convert raw change to horizontal movement in cm
x_cm=change_x*avg_altitude*conv_factor;
y_cm=change_y*avg_altitude*conv_factor;
x_cm=-change_x*avg_altitude*conv_factor;// perhaps this altitude should actually be the distance to the ground? i.e. if we are very rolled over it should be longer?
y_cm=-change_y*avg_altitude*conv_factor;// for example if you are leaned over at 45 deg the ground will appear farther away and motion from opt flow sensor will be less
@ -42,11 +42,15 @@ class AP_OpticalFlow
@@ -42,11 +42,15 @@ class AP_OpticalFlow
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
unsignedlonglng,lat;// position
floatlng,lat;// 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;
public:
AP_OpticalFlow();// Constructor
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)
@ -57,7 +61,7 @@ class AP_OpticalFlow
@@ -57,7 +61,7 @@ class AP_OpticalFlow
virtualintread();// read latest values from sensor and fill in x,y and totals
virtualvoidget_position(floatroll,floatpitch,floatyaw,floataltitude);// updates internal lon and lat with estimation based on optical flow
protected:
//protected:
Matrix3f_orientation_matrix;
floatconv_factor;// multiply this number by altitude and pixel change to get horizontal move (in same units as altitude)