AP_OpticalFlow*AP_OpticalFlow::_sensor=NULL;// pointer to the last instantiated optical flow sensor. Will be turned into a table if we ever add support for more than one sensor
// init - initCommAPI 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)
// add rotated values to totals (perhaps this is pointless as we need to take into account yaw, roll, pitch)
x+=dx;
y+=dy;
}
// updatse conversion factors that are dependent upon field_of_view
void
AP_OpticalFlow::update_conversion_factors()
{
conv_factor=(1.0/(float)(num_pixels*scaler))*2.0*tan(field_of_view/2.0);// multiply this number by altitude and pixel change to get horizontal move (in same units as altitude)
// convert raw change to horizontal movement in cm
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