Python script to output MAVLink

First off, thanks very much to @iabdalkader for writing the script to output MAVLink!

I’m one of the ArduPilot developers (www.ardupilot.org) and I would like to help integrate the OpenMV camera for use as an optical flow sensor (and later as a precision landing camera) so I have written a new AP Optical Flow driver which accepts the OPTICAL_FLOW messages that this example script sends.

I’ve found a couple of problems with the script which I’ve corrected in this modified version of the script:

  • the y-axis output seems to be reversed (assuming the camera is meant to be orientated so that it’s facing downwards with the camera lens towards the front of the vehicle)
  • the output values seem to be too low for both x and y axis. I scaled up the X output 3.5 times and the Y output 5.3 times

Even with these changes though I’m finding that my quadcopter is not holding position well. I have not narrowed down the exact cause yet but I think it could be:

  • the OPTICAL_FLOW messages may not be sent if the “displacement.response < 0.1”. It would be best to send the flow rates as quickly as possible and as regularly as possible even if the camera does not see any movement
  • I’m occasionally seeing large spikes in the flow data. This seems to happen when the attitude of the vehicle is far off from level but of course the camera doesn’t know it’s orientation so I’m unsure what’s happening

Anyway, thanks very much and I hope we can get this working. I’m keen to help

EDIT: here is a graph of the vehicle’s gyro values (i.e. rotation rates) and the output from the flow sensor which shows the large spikes mentioned above.