In case you're looking for an optical flow sensor, there is now one available in the DIYDrones store for a penny under $40.
This sensor is based on the ADNS3080 mouse sensor which is a good choice for optical flow because:
high resolution: 30 x 30 pixel frames meaning it can see features that lesser mice cannot
high speed: 2000 to 6400 frames per second update rate which contributes to better low light performance than other mouse sensors
SPI interface meaning it can be interfaced to many micro controllers and co-exist with other sensors
Other features:
- Intended to interface with a 5v microcontroller.
- 8mm lens with 11 deg FOV
- Standard M12x0.5 lens mount meaning you can replace the lense easily if required
Instructions for connecting the sensor to your APM/Oilpan are here.
Things to be careful of:
- Performs best outdoors in well lit environments
- Does not play well with Fluorescent lights (the blinking throws off the sensor)
- Needs a somewhat varied surface to see movement (plain carpets are not it's friend)
Uses including odometry and obstacle avoidance but I've used it mostly for horizontal position hold.
Note: integration with ACM and the existing GPS pos hold is a work-in-progress but should hopefully be completed in a few weeks. Here is a video of a slightly modified version of the ACM code using only optical flow (and sonar for altitude hold).
Inspiration and some technical help especially early on came from Marko Klein Berkenbusch and his blog on position hold with mouse sensor.
Hope you like it, all comments welcome!
Comments
Sorry, the following item is currently out of stock: Optical Flow Sensor?????
Hello! I always get the same error:
Failed to initialise ADNS3080
I use the apm 2.5. What is wrong? I did the wirering like on the wiki page.
Please helpe me!
I have been trying to get the optical flow sensor to work with my APM 2.5 board and getting some strange flakey results. The sensor will capture images and output them to the Arduino Serial Monitor or Python image grabber for 2 - 5 frames and then cut off midway through outputting a frame. Here's what it looks like on the serial monitor:
-------------------------
image data --------------
8,4,8,8,12,16,16,20,20,20,24,20,16,24,28,28,24,28,28,36,80,92,92,88,80,64,20,44,28,40
16,16,16,8,12,24,24,28,24,24,32,28,28,32,40,36,32,36,36,44,100,116,116,112,104,80,32,60,40,52
12,16,16,4,4,20,24,24,24,24,28,28,24,32,40,36,36,36,40,48,96,128,132,124,116,80,32,60,52,64
12,16,20,8,16,24,28,28,28,28,28,28,24,36,40,40,40,40,44,56,104,144,148,144,132,88,44,64,64,76
16,20,20,20,24,28,28,28,28,28,32,32,32,44,44,44,40,44,44,60,152,124,164,160,148,84,56,64,80,88
20,20,24,24,28,28,32,32,32,32,36,32,32,48,48,48,48,52,48,72,168,156,156,172,164,84,72,68,96,96
20,24,24,28,28,28,32,32,32,32,36,32,36,52,52,52,48,56,52,80,188,192,164,160,152,72,88,64,108,96
20,24,28,28,28,32,32,36,36,36,40,36,36,56,56,56,40,48,60,104,204,204,216,176,128,64,108,64,112,120
20,24,28,28,32,32,32,36,36,36,40,36,40,60,56,48,52,64,56,124,220,228,232,212,172,56,124,52,20,76
24,24,28,28,32,36,36,36,40,40,40,36,36,60,60,52,56,68,68,128,100,168,248,68,180,60,144,48,20,84
24,28,28,32,32,36,36,40,40,40,44,36,48,64,56,52,48,68,68,156,248,104,252,140,196,60,116,72,108,124
24,28,28,32,32,36,40,40,40,40,44,40,48,72,64,64,52,60,88,72,136,228,252,248,228,60,60,60,168,148
24,28,28,32,36,36,40,40,40,40,40,40,52,76,68,68,52,52,76,192,252,252,252,252,224,60,20,32,164,152
24,28,28,32,36,36,40,40,40,44,44,40,56,76,72,72,64,52,48,132,196,248,252,252,216,64,120,100,172,156
24,28,32,32,36,36,40,44,44,44,44,44,56,84,72,68,64,44,84,164,140,212,252,252,200,72,156,128,176,156
16,20,32,32,36,36,40,44,44,44,48,44,60,80,72,72,72,72,92,208,232,252,220,252,180,84,144,140,176,160
8,8,24,32,36,36,40,40,40,44,48,44,60,76,68,72,76,76,104,244,252,252,252,252,164,96,124,148,172,156
16,24,28,32,36,36,40,40,40,44,24,32,60,72,68,68,72,68,108,252,252,252,252,252,136,108,108,152,168,156
24,28,28,32,32,36,40,40,40,28,20,20,36,72,64,68,64,72,112,244,252,252,252,240,116,124,92,156,164,152
24,24,28,28,32,32,36,36,28,20,20,20,44,60,64,64,68,68,116,236,240,252,244,228,96,128,80,160,152,144
24,24,28,28,32,36,36,36,32,32,40,36,12,20,60,64,64,64,116,224,224,236,228,216,76,136,72,156,144,132
20,24,24,28,28,32,32,32,36,40,40,40,8,12,52,56,52,60,124,208,220,228,216,200,64,140,64,152,136,124
20,24,24,28,28,32,32,32,32,36,36,40,40,56,52,52,56,60,124,192,200,212,200,180,56,140,68,144,128,116
20,20,24,24,28,28,32,32,32,32,36,36,52,52,52,48,56,68,112,176,184,188,180,168,32,44,68,132,116,108
20,20,24,24,24,28,28,28,28,32,32,36,48,48,44,44,52,64,80,120,168,172,164,144,36,72,72,92,108,96
16,20,20,24,24,28,28,28,28,28,28,32,48,36,32,44,48,48,60,84,100,152,144,124,44,100,72,104,100,84
16,16,20,20,24,24,24,28,24,28,28,32,44,16,20,40,44,52,76,56,76,84,124,96,44,80,72,92,84,72
12,16,16,20,20,24,24,24,24,24,24,32,40,24,12,36,44,48,104,92,48,64,60,76,44,64,68,80,72,60
12,12,16,16,20,20,20,20,20,20,24,28,36,36,28,36,36,48,96,104,88,40,56,36,44,48,60,68,56,48
8,8,12,8,16,20,20,20,20,20,20,24,32,28,28,32,32,44,84,92,96,76,32,32,28,32,52,52,48,36
-------------------------
image data --------------
8,4,8,8,12,16,16,20,20,20,24,20,16,24,28,28,28,28,32,36,80,96,96,92,84,72,20,52,28,40
16,16,16,4,12,24,24,28,24,24,32,32,28,32,40,36,32,36,36,44,100,120,120,116,104,88,32,64,40,56
12,16,16,4,4,24,24,24,24,28,28,28,24,36,40,40,36,36,40,48,92,132,136,132,116,92,32,68,48,64
12,16,20,8,16,28,28,28,28,28,32,32,28,36,44,44,44,44,44,56,108,148,152,148,136,96,40,72,64,76
16,20,24,20,24,28,28,32,28,28,32,32,32,44,48,44,44,44,48,60,156,128,172,164,156,96,52,76,76,88
20,20,24,24,28,28,32,32,32,36,36,32,32,48,52,48,48,52,52,72,168,172,156,180,172,96,68,76,96,104
20,24,24,28,28,32,32,32,32,36,40,36,36,52,52,52,52,56,52,80,192,196,180,164,164,84,80,72,108,100
20,24,28,28,32,32,36,36,36,36,40,36,40,56,56,56,40,48,64,100,208,212,228,196,128,80,104,72,116,124
24,24,28,28,32,32,36,36,36,36,44,36,40,60,60,48,52,68,56,120,228,232,240,220,192,60,120,60,16,84
24,28,28,32,32,36,36,40,40,40,44,40,36,64,64,52,60,72,72,128,104,176,252,72,188,72,140,52,20,88
24,28,28,32,32,36,40,40,40,40,44,40,48,68,60,52,52,76,68,152,252,108,252,148,204,64,112,68,116,128
24,28,28,32,36,36,40,40,44,44,44,40,52,76,68,68,52,60,88,72,140,240,252,252,244,64,56,56,176,152
28,28,32,32,36,40,44,44,44,40,44,44,56,80,72,72,56,56,76,188,252,252,252,252,244,60,20,32,172,160
28,28,32,32,36,40,40,44,44,44,48,44,56,76,72,76,64,56,48,128,204,252,252,252,236,68,
If I reboot the board, I can repeat this over an over. I have followed the instructions closely and I don't think I left off any steps (like modifying the code and board jumper). Anyone having the same problem? Any ideas on how to fix it? The sensor never worked terribly well for position hold on the APM 1.0 board either, but it was not showing the same problem.
Hi,
I am getting some mixed results with OF_loiter. It has been really overcast when I have flown, but the surface quality has been well above 20 (60 - 100 range). Today I had a couple of rock solid OF_loiters, but most of the time, my arducopter would drift in one direction. I normally get some drift in stabilize mode. This was over grass and at about 20' ft altitude. My best loiter of the day was at about 3 ft altitude over a rough patch of grass with a bunch of dirt spots and divets. I was able to properly focus my camera, but I focused it on something only a couple of feet away from the sensor. I am confused as to whether the cause of the problem: the regular grass is not textured enough, there isn't enough light, I need to focus the sensor on something further away, need to tune OF PIDs, or if this is caused by something else. Any help would be greatly appreciated!
Jan,
The optical flow sensor really only helps with horizontal position hold so it won't help with altitude hold. For that the baro or sonar is better. catch you later.
Randy,
The idea of the "complementary filters" implementation and how it would be used sounds very nice.
I will give do some PID tuning in the weekend.
Something that crossed my mind yesterday was:
Can the OPTFLOW be used to land the quad or does one require a sonar?
Regards,
Ah, much, much better! That's what it should look like.
Yes the OF_LOITER pids will need some tuning. It's a fairly simple control method..just a single PID controller for roll and another for pitch. In the regular Loiter we use a pair of controllers (distance + speed) for each axis.
Recently I've discovered the wonders of "complementary filters" so this may be the way that we can combine the optical flow speed with the gps position to make regular loiter better. That's not a super simple task but that's really where we need to get to. So you attach your optical flow and it just uses it when it can to make your loiter performance better..no special OF_LOITER mode required.
Randy,
Got the sketch uploaded and lens focused. It's a bit fiddly but it works (just made sure I saved all my parameters before loading the sketch).
Here are the results:
Before (good surface qual value when using the CLI, however bad focus)
and after (loading the test sketch and focus the lens)
This looks far better.
Loiter was not bad but then again it was quite windy today.
May need some playing around with the OF_LOITER PIDs.
As a recap, turning the lens until you get a good surface qual. value through the CLI is not enough.
One must load the test sketch and focus the lens (I used a lipo bag and turned the lens until I could read the print on the bag).
As you also mention, add some tape to secure the position of the lens.
Hope this blog helps some other OF enthusiasts.
Randy, thanks again for your feedback.
Jan,
Ok 6:30pm is probably too late in the day. The mouse sensor it's built with does require a lot of light...that's it's main weakness actually.
Randy,
I will go through the python sketch this evening.
Do you have a recommendation to what distance I need to focus?
I already taped the lense as it seemed to have the tendency to move a little.
I was flying around 6:30pm and the light conditions were still ok.
Indeed there were some good samples but now I need to get some consistency in it.
Thanks again for the support.