Thursday, 17 May 2012

Even More Sensors!

I've been pondering how to push forwards with the AI side of this project, and come to the conclusion that I really need a good set of sensors in order to get much success. If I had my Raspberry Pi and a couple of web cams it might be possible to do everything using just vision (although I doubt it), but realistically the more sensors the better. So, with that in mind I set about adding more sensors to MmBot - hurray!

You already heard about the PING ultrasound sensor in earlier posts, but as a recap it's a little device that sends an ultra sound pulse and waits for it to come back (aka sonar) which is one way of measuring distance. Another approach is to use infra red range finders. These devices shine an infra red LED in a fairly tight beam, and measure the strength of the beam that comes back. They each have their own faults and benefits, so I'm gonna use both.

First up, here's my newly soldered and ready to mount set of sensors:

New sensors ready to attach
The ultra sound and motion sensors will be mounted on the head (partly as it's a good place - high up and moveable, but mostly because they're cute and the motion sensor makes a good nose). I'll attach the infra red sensors on the front of the robot on each side so they can detect oncoming obstacles.

After a bit of fiddling and a load of tape, I get the sensors temporarilly attached to MmBot in a layout I'm happy with:

New sensors taped to MmBot
I'm not convinced the ultra sound looks great on top of the head - something I'll need to fix in the final design. However the IR sensors on the sides look fine, and as I said earlier - the motion sensor still makes a good nose. It even glows red when it detects motion!

Once things are wired up I'm not in the mood to start programming much (partly cos I have a cold), so I get my new oscilloscope and attach it to read the output from one of the IR range finders:

Wave being generated by moving my hand in front of the IR range finder
 This video shows the whole thing in motion:

After testing all the sensors it's time to properly attach them. For the IR sensors I simply drill a hole and bolt them to the chassis. Similarly, the motion sensor goes on the front of the head so a bit of wood and a couple of bolts later it's easily attached. However the ultra sound sensor needs to sit on a frame as you can see here:

Ultrasound sensor in a frame on top of the head
There's nothing to bolt it to, and I'm not convinced I can simply glue it to the top of the head. There'll be too much torque when the head turns and the frame will quickly break off. To solve this, I cut 2 grooves into the head frame that the sensor frame can slot into:

Ultra sound sensor frame slotting into the head
Now I can glue it, and with a bit of the old saw dust + super glue = instant hardening mega solid resin trick the bond will be stronger than the wood!

That's the first set of sensors going, but while doing so it occured to me that a key part of knowing where you are is the ability to take a guess at your current location based on your movement since your last known location. For example, if I know there's a bar 10 miles away at 45 degrees north, then I turn to 45 degrees north and walk for 10 miles, I can place a good bet that I'm somewhere near the bar.

The predictive approach detailed above gets less and less accurate over time, however when combined with other senses it is extremely useful and can massively reduce computation time. You can see why by considering a scenario we all know too well - being lost on a long car journey. When this happens I generally try and find a street sign, then try to find that sign on the map. However, as I know roughly where I am, I only have to scan a small section of map (hopefully) to find the street. Without this predictive ability I'd need to scan the entire UK road atlas every time I needed to find a street.

All of MmBot's motion is driven from 2 wheels. If I can measure the speed each wheel is turning, I can derive the speed each side of the robot is moving at, and thus it's path across the floor. So how to measure wheel speed? Well it turns out this is a solved problem and uses a device called an encoder. This device uses infra red reflectivity sensors at it's heart. They're just like the range finders mentioned earlier, but much less accurate and only operate within around 1.5cm. This video shows one attached to an oscilloscope (sorry for rotatedness):

Despite the odd angle, you can hopefully see the signal changing as I move my finger over the sensor.

To make an encoder you take advantage of the fact that black reflects less IR than white. If you attach a disk like this to the face of a wheel or cog:

Disk attached to inside of wheel
Then attach an IR reflectivity sensor opposite it, as you can see in this cross section of MmBot:

Cross section of MmBot, showing IR encoder  and wheel disk

As the wheel turns, the amount of IR reflected back will alternate between low (black strip) and high (white strip). By measuring the speed at which the signal alternates, I can derive the speed at which the wheel is rotating and thus (assuming there's no slip), the speed at which the robot is moving! The alternating signal generates a square wave as this diagram illustrates:

Wave (top) being generated from alternating colour (bottom) as the wheel slows down

And here it is in real life!

Oscilloscope showing signal from rotating wheel
As the wheel turns it generates a signal which you can see displayed on my oscilloscope. This video show it in action, with the wheel turning alternately on/off:

That's where I got to today. Next up I'm going to refine my wheel encoder design and try to get it bidirectional (i.e. it can tell the difference between forwards/backwards).


No comments:

Post a Comment