- Beginner to Advanced
- (A) - Short range Sharp IR ranging sensors
- (B) - Longer range Sharp IR ranging sensors
- (C) - Sonar sensors
- (D) - Bumpers
Proximity sensors are typically the simplest of sensors. A basic bumper, built of switches, will tell you when you have hit something. A bumper is a basic digital switch when using a pull up resistor.
Something more elegant would be a non-contact proximity sensor. These type of sensors use light to detect the presence of an object. Sharp makes some short range proximity sensors that will detect objects less than 4" away and give off a digital pulse (GP2Y0D810). Pololu makes a nice break out board for this sensor. Another popular proximity sensor is the IS471F, although it is more expensive and requires more soldering to assemble. Because these are light sensors, they suffer the same caveats listed below for IR range sensors, however, the IR signal is fairly disperse, so they have a wider cone of detection than the range sensors below. Another issue with light sensors is that different materials return different amount of light, if the sensor triggers at 4" on white walls, it will probably not trigger at the same distance on black ones.
Range sensors are more robust than non-contact bumpers. They are also necessary if the robot intends to do any mapping, as we need to know how far away stuff is.
The Great Debate: IR vs. Sonar
Both sonar and IR sensors will give you distance readings, but there are some differences. The primary difference is that sonar has a wide detection cone - as you get farther away from the sensor it detects things farther from the centerline:
This is especially important for detecting skinny objects, such as chair legs. IR sensors will not see a chair leg unless they are pointed directly at it, or get very close. Further, if your only sensor was a single IR facing forward, you might get hung up on chair legs if your robot does not approach the chair exactly head on. A further caveat is that a short robot may end up with very limited range before the sonar sensors detects the ground below the bot.
However, sometimes that narrow beam is useful - for things such as detecting doors. A cheaper sonar, such as the SRF-05 or SRF-02 will miss doorways because the frame returns the sound. More expensive sonar sensors, such as the SRF-08 let you pick up multiple returns, but you will have to do additional processing to find the door - an IR sensor will always see through an open doorway.
The second major difference is the range. Most sonar sensors can detect between 6" and about 10-15 ft. The GP2D120 can detect in the 1.5" to 12" range. The GP2D12 can do about 4" to 36". Note especially that for either sensor type when an object is too close it may appear to be very far away or not be detected at all.
IR sensors can also be quicker than sonar since you don't have to time a pulse - additionally the max update rate is closer to 30Hz rather than 15-20Hz.
Sharp IR Rangers
The Sharp family of IR ranging sensors (GP2D12, GP2D120, etc..) are quite nice sensors. These IR rangers turn distance readings into an analog voltage. The sensors are fairly easy to use, but there are several key points to get reliable results. The sensors are available in a wide selection of ranges.
The IR sensors work on triangulation, that is, they send out a LED pulse and then see where on the wall it falls, and a small array of receiving pixels decides how far away the object is based on optical calculations:
Triangulation has several implications:
- Resolution is higher up close, and lower farther away
- When moving, the sensor may give spurious readings (especially if improperly mounted)
The mounting of the IR sensor is probably the most important point in getting reliable data. First, make sure that the sensor is firmly mounted, if it is flopping around the triangulation will fail. Orientation is important if the sensor will be used while the robot is moving, or if multiple sensors will be used. Sensors should be mounted as shown below. The triangulation happens along the dotted line, so if multiple sensors are mounted on the bot, you want this line parallel and non-intersecting across each of the sensors.
Electrically, the sensors are very simple. They have a VCC line which should be connected to 5V, a GND line which should be connected to ground, and a SIGNAL line which should be attached to a microcontroller ADC port. A 10uF decoupling capacitor should mounted near the sensor to improve accuracy -- this is primarly to offset the large current draw that the sensor has when it pulses the IR LED (@ about 30Hz).
The hardest part of the software is that the voltage-to-distance conversion, as it is a not linear one. Acroname has created a great excel spread sheet for creating the conversion function (using only integer math, so it runs well on micro controllers) http://www.acroname.com/robotics/inf...arp/sharp.html
There are a variety of sonar sensors on the market today. A sonar sensor operates by sending out a ping of sound at a high frequency so that we cannot hear it (however some animals can). By knowing how fast sound moves in air, we can time how long it takes for the ping to return, and compute distance based on that. There are two main types: single transducer and dual transducer models. The jury is still out on which function best...
Sonar sensors suffer from entirely different problems than IR sensors. Because they use sound, they may miss soft objects, as things like clothing and blankets can absorb the ping sent out by the sensor. Because of the wide cone of detection, sonar sensors need to be mounted quite high on a bot to avoid picking up the floor (which would limit their overall distance). Additionally, because sonar uses the speed of sound to determine distance, and the speed of sound varies with temperature, the sensor has to be somewhat calibrated for large temperature swings.
Unlike IR sensors, sonars are slightly harder to deal with when it comes to multiple sensors. Because of the wide cone, and how sound can reflect, they can interfere with each other quite easily. Typically, you must allow a 50ms ring-down time between each firing of a sonar sensors, to let the ping die off. If you have multiple sensors, you can only ping one at a time, and must still obey this 50ms ring down time. Thus, a single sensors might have an update rate of 20Hz, but if you have 4, you might only be able to run them at 5Hz each (and stagger them). The exception to this rule, is that sensors on opposite sides of the bot could probably be fired at the same time, assuming the environment is fairly wide open.
There are a number of sonar sensors currently on the market. In the early days of robotics, sonar sensors had to be salvaged from Polaroid cameras. You can actually still buy these sensors, however there are quite a few newer, smaller, cheaper, and more reliable ones available. The original robotics sonar sensor is the SRF-04 from Devantech. At under $30 it is a great buy. The SRF-04 required 2 pins from a microcontroller, one to send the ping, the other to read the return -- the microcontroller had to time the ping and compute the distance itself. The SRF-05 is a newer version of the SRF-04, and although it still requires the microcontroller to time the pulse, it only requires on pin for send/receive.
Over the past few years, sonar sensors have been given all sorts of other interfaces: I2C, serial, RS-485:
- SRF-02, SRF-08 - I2C interface sensors from Devantech
- SRF485 - an RS-485 interface sonar from Devantech
- EZ-1, EZ-3, etc - Maxbotix makes several different sensors each with different detection cone sizes.
All of these sensors are fairly similar other than the interface used, but they all reduce the load on the microcontroller as it no longer has to time the pulses.
Global Navigation Sensors
In addition to sensors that tell you where objects might be, there are other sensors that can be useful for navigation. These sensors give you information about where a robot is, or where it is heading.
Digital compasses can aid a robot outdoors, telling it which way it is going. However, these sensors can be very unreliable as they work off of magnetic fields, and anything magnetic or metal can create a magnetic field. Utmost care must be taken to isolate the compass from things like the motors of the bot which can generate huge magnetic fields.
There are two main types of compasses available. Devantech makes an I2C device which returns headings in 8-bit or 10-bit resolution. There are also several models available that just have 4 pins, one for each of N,W,S,E, thus giving either 4 or 8 possible directions (8 if it can give NW, SE, etc, by setting two pins high).
Every time I've taught a robotics course, when we arrive at the topic of navigation and localization everyone says "just use GPS!" Experienced robot builders will point out that GPS isn't viable for much robot navigation -- it won't work reliably indoors and it is fairly low accuracy and resolution. Where GPS can be used, is for global navigation. If we know we want to go 300km to the south, we can move a little, figure out our change in position, and then go on our way, always heading towards our destination, but using other sensors for local path planning.
There are dozens of GPS sensors on the market today. They typically have a serial interface, which is fairly standard amongst them.
Indoor navigation can be difficult, since you generally can't use GPS or compasses. The typical solution is to create complex 2D and 3D maps of the area using an array of IR and sonar rangers, and more commonly today LIDAR. A creative solution is to point a camera up at the ceiling, which is always exposed, and see where we are, building a visual map as we go. Obviously, you can't mount this sort of processing on a Boe-bot, but larger bots might find use of such a system. Further extensions include putting infrared markings on the ceiling, which would be visible only to the robot.
Encoders are used to measure distance traveled, by measuring the number of rotations of a wheel or axle. They are either magnetic or light based. A typical encoder will put out pulses as the device it is measuring rotates. By counting these pulses, and knowing the size of the wheel, we can measure how far the wheel has gone. Further, if we look at pulses/time, we can measure the speed of the wheel. See my tutorial on encoders for more information.
(Page 2 of 3)