# Stabilizing a quadcopter with optical flow

My quad copter can balance itself in the air using data collected from mpu6050. With the sonar sensor, it can hover at a specific height, but it moves on the horizontal plane in a random direction. If i put an object below it, it will ascend to keep the distance between the sonar senor and the object.

Now i want to make it have the ability to hover stably. Is it possible to add a downward-facing camera to calculate the speed of optical flow in order to keep it hovering on the same point in the horizontal plane? Could I use a forward-facing camera to stabilize its vertical speed?

• It sounds like you want to use cameras to (1) keep the quadcopter in one place on the X-Y plane, and (2) stabilize the vertical speed. What does it mean to stabilize the vertical speed? Are you trying to avoid the case where the quadcopter ascends in response to an object underneath it, or just smooth that motion?
– Ian
Commented Sep 12, 2013 at 15:39
• If i use two cameras and remove the sonar sensor. Can it work as i think--hover in the air. Or are there any methods to achieve my goal. Commented Sep 13, 2013 at 1:05

The following diagram (1) illustrates a method by which a Lancaster navigator determined airplane height above the water of a lake. Such a method is useful if the ground lacks features needed for other forms of Visual Servoing. A program I saw about mission Chastise showed one spotlight shining green and the other red, to avoid confusion about which way to go to get to correct altitude. Note, the bomb aiming rangefinder used similar geometric principles.

With a quadcopter, you could use red and green lasers, eg from a red laser pointer and a green laser pointer. You could also add servos to rotate one or both of the lasers to adjust the altitude setpoint. A camera or a line sensor would detect the relative positions where the lights hit the ground.

• This is a good idea. Nice trick, loved it! Commented Sep 14, 2013 at 5:19
• cool... but how does that answer the question about stabilising the quad in the x-y plane?
– dm76
Commented Jan 14, 2014 at 15:39
• @dm76, my answer was about holding a given altitude, and I didn't have more to say about Visual Servoing than was in the other answers. (This method, like sonar and VS, could be fooled by an object added below the quadcopter.) Note, range finder sights as mentioned in answer might be usable to hold XY position via a camera looking at distant landmarks. Commented Jan 14, 2014 at 16:52
• @jwpat7, "my answer was about holding a given altitude". Indeed, hence my comment since the question was not about holding altitude...
– dm76
Commented Jan 15, 2014 at 9:39
• I'm glad I read this here along with other answers, so thanks a lot. really appreciate it Commented Feb 19, 2022 at 10:41

Using a so-called optical flow sensor is the best way to help with holding the horizontal (i.e. in X-Y plane) position. I don't see any reason why you couldn't do the same for vertical control, although a sonar is probably easier and cheaper to use for this (likewise, if you are indoors, you could use 2 sonars for the horizontal position as well)

People used to hack the sensors of optical mice to achieve this: