Position Hold with Optical Flow sensor - done

Waldmensch
Posts: 31
Joined: Sat Dec 31, 2011 12:10 am

Re: Position Hold with Optical Flow sensor - done

Post by Waldmensch »

Important is to know the FOV of lense. This is the distance from lense to Sensor.

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Position Hold with Optical Flow sensor - done

Post by alexmos »

LuFa wrote:Hi ,

Some ADNS5050 are on the way to me :)
But i have some questions :

- which Lens is the best one ?
- How to adjust the Lens ? is there any kind of video quality output in the code ?
- Can you upload the 2.0 with your optical flow ? because i use the MPU6050
- which PID Values are good for the first start ?
- works the calculation of the movement in relation of the altitute only with sonar or also with baro ?


Thanks so mutch !


- I have plastic lense about 6mm focal distance from laser pointer. If you find lense from camera with 5-8mm, it will work better.
- To view row data from sensor, download sketch and java GUI from this post attachement. It will help to fine tune focus.-
- I am going to merge with 2.0 in few weeks..
- Try to start from very low PIDS: P=3, I = 0.010, D=5. (remember tis is VEL section in GUI). I have a very little test data to say the best PIDS
- I think altitude from baro will works, too. In my test on 6 meters only baro was used.
Attachments
ADNS_5050_test.zip
(21.12 KiB) Downloaded 667 times

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Position Hold with Optical Flow sensor - done

Post by alexmos »

copterrichie wrote:I have a question, are there some mouses/mice that also have this chip? If true, will the lens work for this project?


No, I don't know where this sensor was used. I bought it in electronic shop. Mouse lense will not work, it has less focal distance than needed.

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: Position Hold with Optical Flow sensor - done

Post by LuFa »

thanks :)

can you tell me how to run the Java Gui ?

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Position Hold with Optical Flow sensor - done

Post by copterrichie »

alexmos wrote:
copterrichie wrote:I have a question, are there some mouses/mice that also have this chip? If true, will the lens work for this project?


No, I don't know where this sensor was used. I bought it in electronic shop. Mouse lense will not work, it has less focal distance than needed.


Thank you, it was a wild thought. :D

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Position Hold with Optical Flow sensor - done

Post by nhadrian »

My ADNS3080 with lens from DIY Drones is on the way... :D

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Position Hold with Optical Flow sensor - done

Post by alexmos »

LuFa wrote:thanks :)

can you tell me how to run the Java Gui ?


It is quite simply - download and install Java (JRE from Sun.com). And run "mousecam/bin/run.bat" (java.exe must be in the path environment).

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: Position Hold with Optical Flow sensor - done

Post by LuFa »

ok , i have chanche the .bat to this :

Code: Select all

set path=.;C:\Program Files (x86)\Java\jre6\bin
java mousecam/MouseCam


and if i start it i see this :

Image

is that right ? how can i see the camera picture ?

Thanks :)

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Position Hold with Optical Flow sensor - done

Post by alexmos »

I have downloaded mousecam from http://www.bidouille.org/hack/mousecam They says: "You can download the Arduino script and the PC program below. The program is in java and requires the RXTX library to be installed. You need to get the "RXTX 2.1 for use withOUT Sun's CommAPI (namespace gnu.io)" version. No, as of 2008 java still does not natively support the serial port. It should work with Linux, Mac OS X and Windows, but I only tested it under Windows."

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Position Hold with Optical Flow sensor - done

Post by copterrichie »

alexmos wrote:I have downloaded mousecam from http://www.bidouille.org/hack/mousecam They says: "You can download the Arduino script and the PC program below. The program is in java and requires the RXTX library to be installed. You need to get the "RXTX 2.1 for use withOUT Sun's CommAPI (namespace gnu.io)" version. No, as of 2008 java still does not natively support the serial port. It should work with Linux, Mac OS X and Windows, but I only tested it under Windows."


Would you believe I JUST disassembled one of these yesterday? It appears to be the same as the Wireless Microsoft Mouse. It has a A2030 Chip but I was unable to locate the Datasheet for it.

P1110720.JPG

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: Position Hold with Optical Flow sensor - done

Post by LuFa »

i cant find the right download link to the txrx lib :(

is that the only way to setup the lens ?

i´m to stupid to bring the java programm to run :(

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Position Hold with Optical Flow sensor - done

Post by alexmos »

https://www.google.ru/search?hl=ru&q=adns+2030+pdf - the first link is what you need :) But it is much more complicated to connect this sensor to arduino (3.3V, many electronics required)

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: Position Hold with Optical Flow sensor - done

Post by LuFa »

the hardware is allready ready :) (use BSS123 for levelconverter)
are you shure that is it the right link ? its a google search link

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Position Hold with Optical Flow sensor - done

Post by copterrichie »

alexmos wrote:https://www.google.ru/search?hl=ru&q=adns+2030+pdf - the first link is what you need :) But it is much more complicated to connect this sensor to arduino (3.3V, many electronics required)


Awe! Thank you, I have a few more mouses around here, maybe we will hit the jackpot. :)

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: Position Hold with Optical Flow sensor - done

Post by LuFa »

have receive now my adns 5050 sensors :)

can you tell me where is the front of the sensor ? in wich direction should i mount the sensor ?

how did you connect the NRESET Pin from the adns 5050 ? High , Low or NC ? :D

thanks ;)

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Position Hold with Optical Flow sensor - done

Post by alexmos »

Image

Y = PITCH - Forward direction of other sensors, X = ROLL

NRESET should be HIGH. I have connected it to +5V (don't know is it safe, but works)

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Position Hold with Optical Flow sensor - done

Post by copterrichie »

I apologize for being a pain. :D

I just opened a MAC original mouse and found an ADNS-2051, any opinions?

http://www.alldatasheet.com/datasheet-p ... S2051.html


Hmmm: http://www.martijnthe.nl/2009/07/interf ... r-arduino/

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Position Hold with Optical Flow sensor - done

Post by alexmos »

You can connect almoust ANY mice sensor to arduino :) All you need - to add some code into OpticalFlow.pde to read delta_x and delta_y according to the datasheet, and properly convert them to mm. All other mathematics and PID control things are the same for every sensor :) I have selected ADNS-5050 only because it has the most simply connection for me.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Position Hold with Optical Flow sensor - done

Post by copterrichie »

Awesome, I will bench test this and report back. :)

sandmen
Posts: 24
Joined: Mon Feb 21, 2011 3:26 pm

Re: Position Hold with Optical Flow sensor - done

Post by sandmen »

@alexmoos
today I assembled my diy-flow-control :D
I have a lense from a old laser pointer. I can adjust it via a screw.
The Adns-2610 has some different regs on I2C. I will use your script from here,
viewtopic.php?f=7&t=1413&start=30#p11421
and modify the address. Do you think I have to connect the LED_CNTL?
Hope this will work :-)

My question is, about your repository.
- You have integrated into your repo, sonar and flwo control , based 1.9. Is that correct?
- Is your repo working with mega (flyduino) ? or What board/mcu do you use?
- Where is your repo ? :mrgreen:
- Do you plan to merge it with 2.0

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Position Hold with Optical Flow sensor - done

Post by alexmos »

sandmen wrote:My question is, about your repository.
- You have integrated into your repo, sonar and flwo control , based 1.9. Is that correct?
- Is your repo working with mega (flyduino) ? or What board/mcu do you use?
- Where is your repo ? :mrgreen:
- Do you plan to merge it with 2.0


-yes, based on 1.9
-sonar will not work with mega, all other will work as in 1.9.
- repo hosted on code.google.com ;) http://code.google.com/p/multiwii-alexmos/
- Yes, I am going to merge soon - when finished all test of my improvements.

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: Position Hold with Optical Flow sensor - done

Post by LuFa »

today i have finished my test pcb with the adns5050 :)
all works good for the moment ;)

know i waiting for the 2.0 with opticalflow from alexmos :D
when did you plan to release your code with 2.0 ?

thanks sooooo mutch !!!!!

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Position Hold with Optical Flow sensor - done

Post by alexmos »

Good news, LuFa :) Today I have tested my code for position hold and it works fine! So I have finished working on it and now starting merge with 2.0.

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: Position Hold with Optical Flow sensor - done

Post by LuFa »

great :D

cant wait to test it :)

at the moment i try to bring the java programm to run ......

Is your Position hold now better than on your first video ?

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Position Hold with Optical Flow sensor - done

Post by alexmos »

It's more stable, less jerking. And some errors foud and corrected

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: Position Hold with Optical Flow sensor - done

Post by LuFa »

great :)

for which distance should i adjust/fix the position of the lense ?

at the moment i have this method to find the right lens position :

- look to the delta output from the testcode and move the ADNS
- if the delta output move at the same way like the sensor , the lense have the right position

the proplem is , every setup of the lense position are only work at the right distance to the ground with the testprogramm .
i know that the multiwii code does calculate the movement off the adns in relation of the distance , but for the moment i try to find the best position with the testprogramm .

thanks for your help ;)

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Position Hold with Optical Flow sensor - done

Post by alexmos »

What test program do you mean? I have used mousecam util (uploaded few posts above) to see image from sensor. Point lense to bright and contrast object at distance 2-3 m and ajust lense to take sharp picture. It should be all in focus for distance 30cm - infinity. The way you choose is not precise.

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: Position Hold with Optical Flow sensor - done

Post by LuFa »

i know , but its not possible for me to bring mousecam util to run :( have still the proplem from few posts above ....
thatswhy i try it with the x and y move output from the sensor to get the optimal lens position .

did you have a "user manuell" how to bring the mousecam util to run ?

thanks !

Edit :

Now it works :mrgreen: :mrgreen: :mrgreen: :mrgreen:
im so happy !

have use this Manuell how to install rxtx lib :

http://rxtx.qbang.org/wiki/index.php/In ... or_Windows

sandmen
Posts: 24
Joined: Mon Feb 21, 2011 3:26 pm

Re: Position Hold with Optical Flow sensor - done

Post by sandmen »

Here is a script for a adns2610.
I have test it here with a mouse, works fine.
In the next days, I will try to get it working with my lens.
@alexmoos,
this sonar code is working on mega, maybe integrate into your repo :-)

Thanks Peter
Attachments
Adns2610.zip
(1.9 KiB) Downloaded 360 times

Tifani
Posts: 63
Joined: Sun Nov 06, 2011 5:15 pm

Re: Position Hold with Optical Flow sensor - done

Post by Tifani »

Hi !
Idea for lenses+enclosure - some webcams go for $5
Tom

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Position Hold with Optical Flow sensor - done

Post by alexmos »

sandmen wrote:this sonar code is working on mega, maybe integrate into your repo :-)


Where is sonar code?

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Position Hold with Optical Flow sensor - done

Post by alexmos »

Tifani wrote:Hi !
Idea for lenses+enclosure - some webcams go for $5
Tom

Anybody know which lense (focal length) used in webcams?

sandmen
Posts: 24
Joined: Mon Feb 21, 2011 3:26 pm

Re: Position Hold with Optical Flow sensor - done

Post by sandmen »

Where is sonar code?


Sorry,
here
viewtopic.php?f=7&t=1033&start=70#p11659

noobee
Posts: 66
Joined: Fri Feb 25, 2011 2:57 pm

Re: Position Hold with Optical Flow sensor - done

Post by noobee »

what is the ideal lens focal length for these mouse image sensors?

was thinking of using the mtv mount lens.

thanks

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Position Hold with Optical Flow sensor - done

Post by alexmos »

My lense has 8mm from its center to focused plane. I didn't test any other lense, but think 6..10 mm will work, too.

Tifani
Posts: 63
Joined: Sun Nov 06, 2011 5:15 pm

Re: Position Hold with Optical Flow sensor - done

Post by Tifani »

Hi !
I,m going to Microcenter (microcenter.com) to pickup some $5 webcams today. I will post results as soon I be back.
By the way how to attach pictures & videos to post ? I don't have any web storage to post links.
Regards
Tom
P.S. Focal length for webcam by design can be close to what we need ( I assume than webcam sensor is close shape to mouse sensor) anyway we will see in few hours & a few $$$ later. :D

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: Position Hold with Optical Flow sensor - done

Post by LuFa »

alexmos wrote:Good news, LuFa :) Today I have tested my code for position hold and it works fine! So I have finished working on it and now starting merge with 2.0.


maybe can you upload your finaly 1.9 ?
it will be very cool for my first tests on this weekend :mrgreen:

thanks !

Olaf.J
Posts: 16
Joined: Tue Jul 12, 2011 10:10 pm

Re: Position Hold with Optical Flow sensor - done

Post by Olaf.J »

Hi,

has anybode already successfully tried it with an adns 3080? Could be a nice idea to use it with atmega 2560-arduino (flyduino), because the ISP is normally not used, so you need only 1 extra pin, if I understood it right - whatever "NCS" means...

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Position Hold with Optical Flow sensor - done

Post by alexmos »

Olaf.J wrote:Hi,

has anybode already successfully tried it with an adns 3080? Could be a nice idea to use it with atmega 2560-arduino (flyduino), because the ISP is normally not used, so you need only 1 extra pin, if I understood it right - whatever "NCS" means...


Hi! You are right - on Mega ISP is free so can be used with arduino ISP library and only NCS pin needed. (it works in ArduPilot this way). You can get sensor communication from there

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Position Hold with Optical Flow sensor - done

Post by alexmos »

I have uploaded latest version to SVN (r21). Now I am using DigitalWriteFast library for faster SPI communication.
I had some tests today:
- It works without sonar, with baro only
- It works on high altitudes, but weaker
- It well comprensate wind (even strong), but need some time and space to stabilize if wind is choppy.

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: Position Hold with Optical Flow sensor - done

Post by LuFa »

yeah :) great :mrgreen:

is your r21 based on Mwii 2.0 ?
is it possible to use A0 , A1 , A2 or A3 for connection of the ADNS505 or only digitalpins ?

Tifani
Posts: 63
Joined: Sun Nov 06, 2011 5:15 pm

Re: Position Hold with Optical Flow sensor - done

Post by Tifani »

Hi !
Looks like nobody want to help me with attaching pictures - Ok
I have three webcams to test lens+body, first one look promising.

Something came on my mind:
when copter drift, "picture" in the sensor is moving.
But when copter start compensate, frame tilt in opposite direction and "picture" move in the same direction than previously during drift.
Hard to explain without picture.
Image
http://www.snapixel.com/479413/Photo-of-compensate
Just question
Tom

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: Position Hold with Optical Flow sensor - done

Post by LuFa »

only need to install the DigitalWriteFast library ? or must also be changed the digitalWriteFast.h file into the library ?

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Position Hold with Optical Flow sensor - done

Post by alexmos »

Hi, Tifani!

You can upload images to any image or file hosting. It is only way to attach image.
You mind working right - when frame tilt, picture is moving. There is some math in the code to take it into account.

I have added digitalWriteFast.h to code directory so it should compile wuthout extra install

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: Position Hold with Optical Flow sensor - done

Post by LuFa »

mhmm , without lib i get this error :

Code: Select all



In file included from Multiwii_r21.cpp:2371:
/digitalWriteFast.h:1:23: error: WProgram.h: No such file or directory
/digitalWriteFast.h:2:20: error: wiring.h: No such file or directory


with lib and orginal digitalWriteFast file from the lib i get no error .

if i replace the digitalWriteFast file directly in the lib i get the same error



So will it also work if i install the lib and replace the digitalWriteFast.h from the Mwii folder ? i think yes , because i get no error :)

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Position Hold with Optical Flow sensor - done

Post by alexmos »

LuFa,

probably you are using Arduino 1.0 IDE? I have added mod for it, now code compiles in 0022 and in 1.0. Changes on SVN.

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: Position Hold with Optical Flow sensor - done

Post by LuFa »

cool , now it works without proplems :)
tomorrow i will make the first tests :mrgreen:

can you tell me your alt pids for Sonar ? sonar use the same pid like baro , right ?

future question : will your sonar and opticalflow code also work with Mega ?
work your sonar code now also with Hexa or Octocopter ?

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: Position Hold with Optical Flow sensor - done

Post by LuFa »

hi ,

wich pid values are use the Sonar and Optical flow ? full PID controll or only PD ...... ?

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Position Hold with Optical Flow sensor - done

Post by alexmos »

Sonat uses the same Alt-PIDS as baro but it can be increased in config: SONAR_BARO_PID_GAIN Default is 1 (means increase by 2)
Try P=5..10, I=0.010, D=20..30

will your sonar and opticalflow code also work with Mega ?

No, I have not tested with mega. Potentialy it can but need some tuning.
And I don't know if it can work with hexa or octo. Try to configure and test it :)

For Alt Hold all 3 PID used, for optical flow - only P and I.

dfidalgo
Posts: 23
Joined: Fri Sep 09, 2011 2:16 pm

Re: Position Hold with Optical Flow sensor - done

Post by dfidalgo »

Hi!
I remembered that I had lost here at home, a Flymentor, and could use the optical sensor with your code. After opening it to find out which sensor was inside the box, I saw that they removed the references ... :shock:
Can someone tell me what sensor is this? I would like to use it with your code.
Regards,

Daniel
Attachments
IMAGE_121.jpg
IMAGE_119.jpg
Flymentor Optical sensor
Flymentor Optical sensor

Post Reply