My libraries are in the right place, and I've tried compiling the sketch with both the Arduino 1.0 relaxed as well as the Arduino 0.22 relaxed version. Arduino Mega2560 selected.

Reference from the sketch:

  Example of AP_OpticalFlow library.
  Code by Randy Mackay.

#include <FastSerial.h>
#include <AP_Common.h>
#include <AP_Math.h>        // ArduPilot Mega Vector/Matrix math Library
#include <SPI.h>              // Arduino SPI library
#include <AP_DCM.h>            // ArduCopter DCM Library
#include "AP_OpticalFlow.h" // ArduCopter OpticalFlow Library


I downloaded for the libraries, and got AP_DCM from the repository.

Error messages are all from following libs:




I'd appreciate a pointer to where I'm flying off course!

Views: 2517

Reply to This

Replies to This Discussion

What's the exact text of the errors?

Thanks for responding so quickly.

I attached the dump from the Arduino 0.22relaxed compile attempt.

Arduino1.00relaxed additionally return:

In file included from AP_OpticalFlow_test.cpp:6:
C:\Programming\arduino-0100-relax\libraries\FastSerial/FastSerial.h:105: error: conflicting return type specified for 'virtual void FastSerial::write(uint8_t)'
C:\Programming\arduino-0100-relax\hardware\arduino\cores\arduino/Print.h:48: error:   overriding 'virtual size_t Print::write(uint8_t)'


Wow, lookit all those errors. :)

For giggles can you attach AP_DCM.h as well as AP_OpticalFlow_test.cpp ?  I want to be sure it's not corrupted in some fashion.

All those are pretty weird errors and smells like a file that is somehow corrupted or has extra junk in it or something like that. I need to see the file to get a better idea of what is/isn't going on.

Here's AP_DCM.h

No AP_OpticalFlow_test.cpp! I attached the *.pde.


Ah, just as I suspected.  Ok, look at AP_DCM.h -- that's not C code, it's XML / HTML. Rename it to .html and open in your browser. You'll see what I mean.

When you browse code in Google Code repositories -- and I've done this too -- you click "Save As..." or whatever, expecting to get the raw file. But you get the HTML page for that file.

To get individual files, click the link (e.g. then look for the link "raw file" link under the "File Info" sidebar in blue on the right.

Click that and you should get to the raw file that you can then if it doesn't automatically download, click save-as. E.g.:

You're best to download zip files out of these repositories, though. 

Meanwhile if all you're trying to do is get standalone demo code working for the optical flow sensor just to grab images, I already went through all that hell. :) (download the zip) :)

It was quite a challenge to tear the optical demo code out of APM with all the code tendrils with which it was entwined. :)


Great! Indeed, I wan't to work with the standalone sensor, and what a good thing it is to defer to pre-acquired wisdom =] It's midnight here, so I'll implement your solution tomorrow and report back. Thank you for your - much appreciated - quick help!

WORKS! Fantastic! =D


Also, nice code with error handling and plentiful comments.

The bot-thoughts code for optical flow sensor is not working, can you please help me. The sensor is not able to find the first pixel.

I've updated the wiki page and also added a pre-built hex file that can be uploaded to the APM2 directly using the Mission Planner's INITIAL SETUP > Install Firmware screen's "Load custom firmware" link.

Hi Randy,
I donno whats the problem, I uploaded the pre-built hex file into my APM2.5 and after connecting it to the terminal I pressed i but again it is showing failed to find first pixel.... can you please suggest me good solution for this problem. Thanks in advance.

Reply to Discussion


© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service