Developer

BR-0016-01-2.jpg?width=251In 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!

E-mail me when people leave their comments –

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

Join diydrones

Comments

  • Developer

    Jan,

        By the way, grass should be ok.  flat black pavement is not so good, carpet is terrible.

  • Developer

    Jan,

        When focussing the lens have you tried to grab an image with the python sketch?  It's a bit annoying to get it set-up but it is helpful in getting the focus right.  Once you get it right, I'd tape that lense in place so it can't move anymore.

        What time of day were you testing?  you have some good data in there but it's not consistent enough for the sensor to operate properly.

  • Randy,


    I had the optflow test activated through the CLI and turned the lens until I obtained a surface qual of about 30 to 80.

    Next I did a test flight in my garden.
    Here is the result:

    3692521999?profile=original

    I isolated the OF SurfaceQual data which seems not consistent.
    There are quite some peaks in the graph while still a lot of samples are far too low.

    This log was made in my garden over grass at an altitude of about 5 meter (didn't want to scare the neighbors too much...)

    Is there a guideline on where to put the focus of the sensor?

    Could it be that the texture of grass is not ideal for the OF loiter?

    Best regards,

  • Randy,


    Thank you for the quick feedback.

    I already did the check by using the cli and did see some changes in the values when moving over objects.
    However I didn't know what value to look for, as I saw that the values changed I presumed that it was ok and the sensor saw something.

    Now I know in what direction I have to go, I will give it another go and try to improve the sight of my nearsighted quad :-)

  • Developer

    Jan,

         So the problem is that the surface quality is very low.  It's only 1 or 2 in the logs above (it appears as the 3rd item in the "OF" lines).  It really needs to be above 20 for it to try to use the sensor to compensate.  Could you check the sensor using the cli menu's "test", "optflow".  Maybe you need to focus the lens?

  • Randy,

    We had some nice weather last weekend so I was able to collect some data.

    I can't add the complete log file (don't see the attach option here) but here is an extract of the log file in OF_LOITER mode

    MOD:OF_LOITER, 558
    OF, 0, 0, 1, 2, 1, 2.0000000, 0.0000000, 0, 0
    NTUN, 0, 90, 0, 0, -10, -682, 18, -50, 4, -89
    ATT, 421, 317, -425, -368, 0, 29496, 30229
    OF, 0, 0, 0, 2, 1, 2.0000000, 0.0000000, 0, 0
    ATT, 0, 326, 0, -233, 0, 29454, 30243
    OF, 0, 0, 1, 2, 1, 2.0000000, 0.0000000, -29, -1
    GPS, 49555500, 10, 50.7294810, 4.2027180, 6.3100, 52.7300, 7, 14571
    NTUN, 14, 270, 0, 0, -10, -682, 35, -25, 4, -89
    ATT, 0, 175, 0, -82, 0, 29435, 30090
    OF, 0, 0, 1, 2, 1, 2.0000000, 0.0000000, -129, -1
    ATT, 0, 56, 0, 38, 0, 29429, 30026
    OF, 0, 0, 2, 2, 1, 2.0000000, 0.0000000, -229, -1
    ATT, 0, -55, 0, 158, 0, 29434, 30016
    GPS, 49555750, 10, 50.7294800, 4.2027180, 6.5500, 52.7900, 25, 15137
    OF, 0, 0, 1, 2, 1, 2.0000000, 0.0000000, -329, -1
    NTUN, 17, 306, 0, 0, -10, -682, 17, -31, 4, -89
    ATT, 0, -192, 0, 266, 0, 29431, 29771
    OF, 0, 0, 1, 2, 1, 2.0000000, 0.0000000, -429, -1
    ATT, 0, -271, 0, 366, 0, 29452, 30153
    OF, 0, 0, 2, 2, 1, 2.0000000, 0.0000000, -529, -1
    GPS, 49556000, 10, 50.7294800, 4.2027160, 6.0700, 52.8500, 81, 15626
    NTUN, 11, 0, 0, 0, -10, -682, -17, -15, 4, -89
    ATT, 0, -330, 0, 420, 0, 29452, 29649

    Again same behavior good position in stabilize but when switch to OF_LOITER drifts of to the left (always).

    It does not compensate at all.

    Hope you can have a look to this small extract of data.

    Thank you.

  • Randy,


    As soon as I some better weather conditions I will try to make a log.
    Do you know if the behavior in the MP normal when switching on the OF_LOITER mode, being 'Unknown'?

    How can I be sure that the mode is working?
    Regards,

  • Developer

    hmm..ok, i'll have a look at it.  Last time I tried it it worked after a bit of tuning anyway.

    I think I really need to introduce a speed controller into the mix.  At the moment, the speed from the of sensor is integrated to calculate the position..and then this position is fed into a PID controller so the further you are from the target the more it leans...but what's better is to do what we do for regular loiter which is to turn the distance into a desired speed..and then compare the current speed to the desired speed and pass this into another PID controller which will adjust the lean angle to attain that speed.

    I hope to add these changes into an upcoming release.

    until then if you can post a dataflash log with the OPTFLOW log type enabled that'll allow me to check some of the basics..like ensuring that your squal value (surface quality) is sufficient for the sensor to do anything.  Of course, also make sure that the pins are facing forward! :-).

  • I've experienced the exact same behavior Jan. I'll be eager to hear if you find a solution!

  • I tested the OF sensor yesterday on my quad (APM1 with 2.7.3 firmware).
    The result was not what I expected though.
    When switching on the OF_LOITER mode the quad started veering off in one direction. No matter what I tried same behaviour was noticed.
    I also saw when connected to the MP when switching to OF_LOITER mode it was shown as 'Unknown'.
    So I have doubts that the OF_LOITER mode is really working.
    Anyone had same behaviour or hints to get it working?

    Thank you

This reply was deleted.