After some more PID tuning, here is another video of my quadcopter trying to hold its position via the hacked mouse sensor (plus an ultrasound range finder for altitude control).
This was shot about 2 hours before sunset and the sensor already started having some trouble on my dark and fairly featureless driveway in the shadow - that's why I tried to make it hover over a sandy spot that stuck out...
E-mail me when people leave their comments –

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

Join diydrones


  • Thats really amazing with such a common and easily available sensor. You said the software is coded in C; have you/do you plan to publish sourcecode? Given your impressive results, I think not only this community, but the people at aeroquad and many other projects would benefit greatly from this example. Im sure if you wanted to, you could also commercialize such a "product". That could mean selling modules yourself or letting DIYdrones store sell them for you or if you dont have interest in that, you could do what I did and host the sourcecode on your own website. I have made ~$500 by putting my code describing how to use the wii motionplus as a I2C gyro just by putting google ads (Google adsense) on my poorly constructed blog.
  • Geoffrey: Non-systematically, I had it hover succesfully between 5 and 10 feet. I scale out the altitude (as it is measured via the ultrasound range finder), so the inputs to the PID are actual distance traveled over ground, independent of altitude.
    That being said, the resolution of the mouse sensor is finite, so going higher it might not be able to detect small movements. The sensor measures roughly 1500 'clicks' per meter at a height of 1m, so at 100m altitude a lateral movement of 1m would register as only '15' raw mouse sensor clicks, which might be starting to be swamped by noise...
    I don't have barometric altittude on the quadcopter at the moment, so I can't go higher than ~20 feet right now. I believe in that range there should be no noticeable effect at all.
  • Nice job! Out of curiosity, have you tried different altitudes with the same PID constants? It would be interesting to see how much you can vary the height with the same constants.
  • NS Rana: Its my homebrew platform described in an earlier blog post here.
  • Position hold without GPS, in the video looks perfectly fine !
    Which hardware platform you are using ?
  • Correct, position hold is accomplished by using the mouse sensor and sonar. There also is the usual IMU using 3 gyros + 3 axis acceleometer + magnemeter, but that is for attitude control, not position hold.
    Two reasons for the mouse sensor: first, it is not trivial to interface a cheap camera (or any 'proprer' camera for that matter) to a microcontroller - at best, they usually speak USB for which you would have to implement a host protocoll. Second, the mouse sensor already implements the optical flow algorithm that allows you to detect motion - all I have to do is periodically read two bytes from the mouse sensor.
  • Nice. This is accomplished with only the mouse sensor and sonar?

    Is there a specific reason for using an optical mouse sensor as opposed to a cheap camera?
  • Developer
    very very impressive.
  • Good question. The sonar only goes up to 20 feet. Obviously the quad can (and has done so) go higher than that, but the position hold with the mouse sensor as it is currently implemented would not work above 20 feet. That being said the optics of the mouse sensor should do fine, it is just a matter of adding a different means of measuring altitude, such as a pressure sensor, which I have not done yet.
  • wow how high can you go??
This reply was deleted.