Adding Custom Optical Flow Code

Here is my situation. I have my own camera setup and code that I have written to proform optical flow on a ATMEGA 2560 and now I need to incorporate this onto the ARDUPILOT 2.5. 

Question:

Where header file should I be modifying to ad my code in. I know that the ADNS 3080 would output 2 numbers from the chip (X and Y change). My situation is similar. Where are the x and y displacements used in the code to do position hold.

Thank you in advance! 

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • I'd recommend going about things in a slightly different way. From your post it sounds like you're not terribly familiar with device drivers and how ardupilot interfaces with hardware. 

    First, get GREP for your system and use it to search the code for optflow (that's the name of the object used to interface with the optical flow sensor). This should give you a pretty good idea of how it's initialized and where it's used. My grep search of arducopter 2.8 had interesting results in ArduCopter.pde, Attitude,pde, and sensors.pde.

    Second, look at the libraries\AP_OpticalFlow\examples directory. You'll find some code in there that the developers have written to test their driver. Play around with it and get comfortable with object oriented programming and the function calls provided by their driver.

    Then look at the files in  libraries\AP_OpticalFlow. The .cpp and .h files in there actually define how the optical flow sensor works. For your sensor, you'll want to have the exact same methods, just filled in with what's needed to interface with your sensor.

    Once you have your files written (say they're called Brandons_Opt_Flow.cpp and .h), put them in /libraries/Brandons_Opt_Flow. At the top of the arducopter code, add an #include <Brandons_Opt_flow.h>. Where the optical flow sensor is declared, use Brandons_Opt_Flow optflow(args) in place of AP_OpticalFlow_ADNS3080 optflow(args). If you've done the driver correctly, no further modifications to the code should be necessary.

    Good luck,

    Nate

This reply was deleted.