WowWee's BladeStar indoor flying machine is advertised as the first toy with an autopilot. From its description: "The exclusive Autopilot Mode with sensor-based navigation enables it to glide through the air, avoiding ceilings and flying away from obstacles."
Basically, it's got three IR sensors, two on the side and one on top. The lower sensor on the side is just to communicate with the controller. The one on the top just spots the ceiling and keeps the BladeStar away from it. The one on the side does all the clever work of staying away from walls. Here's a close-up (the sensor is circled):
That's a IR sensor shielded along the rotational axis. The way the Bladestar flies is that two props (tilted slightly up) on stalks spin the body, and the passive rotors are spun along with it, generating lift. Because the entire body is spinning, there's no "front" or "back" of the aircraft. Instead, all controls are relative to the absolute frame of reference (push left and it goes to your left). I presume the way the "autopilot" works is that it has an internal sense of its rotation speed within the absolute frame of reference (it sees the transmitter's signal most strongly once every 60th of second, say, so it must be spinning at 60Hz). So it times its motor controllers to slightly increases the speed of the motors when they're on the side opposite the desired direction of travel, which tilts the Bladestar slightly in the direction of desired travel.
As for the obstacle avoidance, it must work the same way: when the IR sensor is showing higher readings (indicating that some warm object, like a wall, is near), the motor speed is slightly increased on that side. Then, as the IR sensor spins away from the wall, motor speed is reduced, and so on, with every rotation. Since the IR sensor is spinning the whole time with the aircraft, the motor speed controller and IR sensor must be tightly linked and pretty much instantaneous, with the speed gradient changing at the rotation speed of the aircraft. (I imagine the really advanced technology in this is the high-speed motor controller).
So how well does it work? Pretty well. It does seem to want to stay away from walls, but the ceiling sensor is over sensitive (maybe the problem is that we've got a wood ceiling and it prefers white) and it sometimes plummets almost to the ground after sensing something above it. You can manually fly while it's autopilot mode, but the controls are very insensitive and it's at best a gentle hint of directional control. It's actually most fun to put it in a relatively small room and watch it hover, swinging gently away from the walls and otherwise seeking equilibrium. If you have two, they can also "dogfight", which actually just means that you point your controller at the other Bladestar while yours is in autonomous mode and try to get off three shots before your opponent can do the same to yours.
If you're interested in indoor autonomy and optical-flow autopilots, this is worth checking out. It's also a neat toy and an impressive bit of sensor integration.
You can buy them at Amazon. I got two for $18 each in a post-Christmas sale, but I see they're now $37, which seems to be the standard price.