Sensors are used by robots to do pretty much the same things we do without even thinking about it - they let the robot 'see' things in its immediate (and not-so-immediate!) vicinity. They can tell the robot what it's near, what kind of weather it's experiencing, and even where it is on planet Earth. Sensors are good, in other words!
Sensors can be classed according to what they measure or sense- whether that's light, sound, vibration, touch, temperature, humidity, pressure, and so on.
One of the great things about robot sensors is that you can now buy sensors to measure or detect just about anything - including temperature, humidity, light, sound, air pressure, even things like gas (there are oxygen sensors, carbon dioxide sensors, even radiation sensors!). They can tell the robot in which direction it's facing, and even where it is. So theoretically, a small robot with US$200 worth of sensors can actually detect more than we humans can!
The only sense that isn't well represented in modern robotic sensors is our sense of smell. I guess as soon as someone figures out a use for smelling your way around, that type of sensor will soon appear on the market - even if only as 'novelty' items at first!
Most sensors can be grouped into one of two categories. You might call them "yes/no" (or digital) sensors, or "how much" (proportional) sensors.
Used to detect contact events
|CO2 Gas Sensor
Used to detect the presence of Co2
|Flex Force Sensor
Used to detect initial contact
Great for magnetic detection
Used for rotary wheel positions
|Some typical digital sensors. These are generally able to report there/not there types of events, rather than 'how much' or 'how many' values.|
Yes/no, or digital, sensors only give an output when they definitely sense something (or the lack of something). So a touch or contact sensor (like a microswitch) will not tell you anything until it's actuated by bumping into something. This is useful information, and is easily incorporated into most robot designs, even without a CPU. Switches or line-following sensors can be wired directly to motors or relays to directly control the direction the robot is travelling in.
These types of sensors generally only work over very small distances (like touch sensors), or have no output at all until whatever it is they're designed to detect is present (like a smoke sensor). This is fine for most purposes, and these sensors can be really useful in small robot projects. Colour sensors in particular can be used to give your robot surprisingly interesting behaviours!
But sometimes you don't want to bump into something before you stop - it would be better not to bump into things at all! A fairly largish robot generally needs a fairly largish battery - and that means it's quite heavy, and has a lot of inertia. So a heavy robot can make quite a dent in a wall - or vase, or window (which don't handle dents very well at all!).
Used to detect increasing weight
Returns the current direction
Shows the degree of tilt in 3 axes
Returns the position on the Earth's surface
Uses sound to measure distance
|IR (Infra Red) Rangefinder
Uses IR light to measure distance
|Some examples of various proportional sensors used by most current robot designers. Note that only the pressure sensor is truly 'analogue'.|
It would sometimes be better to know that "something is approaching" (in the case of people or pets) or that you're approaching something - like a wall, or doorway, or other obstacle. Measurement sensors are really useful here. Using these sensors, your robot can avoid an obstacle entirely - without needing to run into it first!
These sensors are what what are called proportional sensors. They don't give a straight yes/no reading; instead, they tell you what quantity or distance is being measured by the sensor. This means you can use these sensors to measure things - like distance, lightness or darkness, temperature, sound levels, even position on the Earth (in the case of GPS sensors).
While they can be much more useful in avoiding situations (instead of banging into things), they do need a little bit more work to get the most out of them. In many cases, simpler sensors will report using an analogue voltage level in proportion to their measurement, which can be digitised by nearly all modern processors pretty easily. More sophisticated sensors, such as Sonars and electronic compasses, will need to report directly to the computer using particular communication channels. Usually, these sensors use I2C (Inter-IC Communications, or IIC) or SPI (Small Peripheral Interface), or a UART (Universal Asynchronous Receiver/Transmitter, also called just 'serial port'). These need the processor to send them particular commands, such as reading a particular register, to get the latest reading, whether that's a distance value, a direction value, or something simpler.
Other sensors need a little bit more programming. For example, GPS sensors usually report their position information using a long string of digits and letters (callled 'NMEA'), that the computer must pull apart to get the information, then perform calculations to make that information relevant to the robot.
One of the nice things about GPS sensors is that they generally don't need to be 'talked to' - they automatically start up, figure out where on Earth they are, and then start spewing out 'NMEA sentences' that you can either ignore completely or listen to when it suits you.
Unfortunately, while no robot will ever work without at least some sensors, and the greater part of the cost of more sophisticated robots is due to sensors, they're some of the most misunderstood and misused parts of most homebrew robots! Why is this?
Typical 'touch' sensors, such as microswitches, or simple light or sound sensors, such as line followers or light trackers, are fine in this respect. That's because they're generally used for a very specific application, and need to be close to (or against!) something in order to use that information. Too far away from something, and they just don't work.
For example, a line follower consists of a small LED and a closely fitted light sensor. These are usually packaged together in a very robust and simple arrangement (we'll speak more of these below in detail). They need to be spaced a few millimetres to less than an inch away from their 'target', which must also be of high contrast. This means that they are in close proximity to a 'known' signal source - the line they're designed to detect.
Proportional or ranged sensors are generally designed to work at a distance (hence the name, "ranged"). This means that quite a lot of the real world can theoretically get between the sensor and whatever it's designed to measure. Many beginner robot designers assume that the "sensor is wrong". In fact, usually the sensor is fine - it's how it's being interpreted that's the problem! This is a situation unique to proportional sensors - a microswitch is either activated or it's not, not somewhere in-between!
The problem with proportional distance or orientation sensors, is that the device is quite a lot further away from what it's supposed to measure than a yes/no type of sensor would normally be. This includes devices like sonar, laser, compass, accelerometer, and GPS devices. These are extremely complex measuring devices, and because of this, they need a lot of work in order to be able to use them effectively!
Because sophisticated computers can now be used by just about anyone, many roboticists who are starting to use these types of sensors think that fancy (and expensive!) sensors, such as sonar rangefinders, work in much the same way as a line sensor or microswitch. Sadly, nothing could be further from the truth! The problem is that many people believe these components work like they do in the movies and on TV - they can be used to track a captive, say, in the boot of a car, from across the country, into someone's garage (for example).
In real life, such data is utterly, absolutely, impossible to get - at least by people like us who don't work in the NSA! If you were to take a typical hobbyist GPS sensor, connect it to a reliable and precise computer system, and do the same thing as you see on TV or in the movies, you might not even get to see where the package went along the way, let alone where it ends up!
This is because there are so many things, from tall buildings to clouds, from trees to water, that interfere with the signal every step of the way. Unlike the movies, you'd be lucky to track such a device more than a few miles. If you were really clever (and really, really lucky!) you might be able to figure out which city it ended up in - but not the suburb, or street, let alone the right garage! You'd have SWAT teams all over the place!
This isn't just a problem with GPS. Ultrasonic rangefinders can report discrepancies of up to +/- 100% (or more at extreme ranges!) due to timing issues and poor reflections.
Even IR rangefinders generally have issues at very small and very large ranges. You can see from the graph below that the results for the Sharp long-range IR rangefinder can report the same value for something that's either 2 centimetres away or 20 centimetres away!
Source :Sharp Electronics Corp. datasheet, GP2Y0A02YK0F
And this is one of the better IR rangefinders available to us normal people! So the short answer is, you really need to understand whatever sensor it is that you're using. More understanding equals fewer problems later on!
The kinds of data these kinds of sophisticated sensors are dealing with is called "noisy" by computer scientists. That's not because it makes a sound!
It's because in addition to the signal or measurement they're designed to provide, whether it's an ultrasonic 'ping', a light beam, or an infrared laser, quite a lot of real-world 'noise' gets incorporated into their readings. You'll need to learn about things like reflection, absorption, and multiple results to use these sensors well in your designs.
For example, if a sonar rangefinder (which costs about US$35 these days) is used to 'ping' the distance for a typical robot in a typical kitchen, the robot may not be able to tell if it's safe to move anywhere! Why? Because not only does the sonar 'ping' reflect from what's in front of it, it will also get strong 'bounces' from nearby cupboards, metallic objects, walls, even from directly behind the sensor!
The same sensor, in a typical loungeroom, would have a lot of problems even 'seeing' anything at all - because soft fabrics (like curtains, upholstery, and carpet) absorbs the signal without reflecting enough back to get a good 'take'. And even in a "non-fabric" setting, seeing small things like chair legs, ladders, and so on, is almost impossible unless they're smack in the middle of the sensor's coverage area. And then there are the echoes echoes echoes echoes echoes....
Example return pattern from a typical ultrasonic sensor and a 55mm wide plastic pipe
Of course, the same problem doesn't happen with IR rangefinders. No, they have their own issues and special tricks you need to understand too! The same is true for electronic compasses, and especially true for sensitive devices like accelerometers - you'd be surprised how much a tiny speck of sand can make an accelerometer think it's been hit by an elephant. Only for an instant, but during that instant, if you're not filtering your samples, you'll get quite a surprise!
So noise is a problem with nearly all sensors (including, surprisingly, microswitches!). How do you figure out where the noise is coming from?
That's a really simple question, with a really difficult answer. "It depends..."
In a typical robot, there are a number of sources of noise that you need to be aware of.
First and foremost is electrical noise. You would be flabbergasted to realise just how much noise your motors cause to all sensors on your robot! A typical DC brushed motor can generate hundreds (if not thousands) of volts just by turning normally. In a simple robot, with no electronics to speak of, noise isn't an issue at all. But in more complicated robots, noise quickly becomes a major, if not the major issue you'll need to work on.
There are some very simple precautions you can take to reduce electrical noise from motors and their associated circuitry.
A very comprehensive motor noise reduction kit. This includes heavy cable, ferrite beads, and suppression capacitors. A Giant Killer!
For example, spending a few cents on capacitors to place across the motor terminals will significantly reduce the noise generated in the RF (radio frequency) bands. Careful positioning of motors and battery connections will also reduce or eliminate magnetic noise generated when very high currents flow through your PCB, wiring, and motors.
Ferrite beads or rings are exceptionally good at reducing electrical noise from brushless DC motors and servos. These are best used with suppression capacitors, but they'll work fine on their own.
Even relative simple tricks, like keeping all your leads as short as possible, will help to reduce noise generated. You can also purchase ferrite beads, which are placed on the wires leading to and from your power supply and motors, to help reduce high frequency noise.
Obviously, noise isn't so much of an issue with IR and ultrasonic sensors, since these work in the frequencies far above and far below the typical electrical noise frequencies generated by motors and so on. But it's still worthwhile placing small capacitors across the power connections to these sensors, to minimise any noise pickup, whether generated by your motors or your CPU.
Another form of noise that's a problem with every robot is one you're familiar with : ULF (Ultra Low Frequency) noise, AKA vibration!
Even quite small irregularities in the terrain can jolt and jostle sensors, and if you happen to be taking readings from them at the time, your robot might think that something unusual is happening. If you then find out you've just run over a bit of carpet edging or a mains flex cable, that's actually hard to know, without combining sensor readings from different sensors.
So mounting your sensors is also important. Good, tight construction will give you much more reliable - and useable! - readings than you can generally get with double-sided tape or hot glue. (But never underestimate the usefulness of some double-sided tape from time to time!).
A good-quality mounting kit for ultrasonic sensors. Note the strong construction and heavy grommets.
As we mentioned, one way of dealing with "noisy" sensors is to use more than one type of sensor to measure the same thing. That way, even if a curtain doesn't reflect a sonar ping, it should still be measurable by a light measuring sensor, and vice-versa. This allows you to ignore some sensor readings when they don't make sense, and use other sensor readings that do.
You do need to be careful to make sure that you know for sure that one sensor is wrong and the other is right - if you get it wrong, you could get a stuck robot. And common-mode noise - in other words, noise that affects more than one type of sensor - can be downright annoying, and difficult to eliminate entirely. Careful design of your PCB, with particular attention to routing your power and ground connections, can reduce such noise by a surprising amount - and it comes for free!
One way around this noise problem is to use lots and lots of different sensors, so that you can "take a vote" and use the readings from the largest number of sensors that "make sense". But that does get quite complicated to manage, especially for smaller robots without lots and lots of computer "horsepower"!
Not everyone has the ability to upgrade or update their CPU or clock speed - and even so, that's unlikely to make any difference to sensor inadequacies.
One of the less well-understood things about bus-connected devices is that it's nearly always possible to upgrade the sensor without seriously affecting the processor. Of course, this only works if you're upgrading a particular manufacturer's device, and not always then. But at least you have the option of improving the range or resolution (which are usually mutually exclusive!) without a huge increase in cost.
Careful routing, heavy, short wiring, lots of bypass capacitors, and careful placement of sensors, can reduce or eliminate induced noise and will help to significantly increase your sensor reliability.
And don't be scared to spend an extra dollar or euro or two - sometimes you really do get what you pay for!
Since I've been developing Rocky for such a long time, the typical range of ultrasonic sensors has increased 20-fold, and the resolution (the ability to detect 2 or more objects at the same distance) has increased 100-fold! So sensor upgrades do make a lot of sense.
For more details on specific types of sensors, their uses and limitations, and examples of how they're used in Rocky, please do check out the sensors submenu at the left.
If you have questions, comments, or suggestions, please contact me directly!
Good luck with your design, and please let me know if you'd like to see your robot sensor design posted here!
At this build revision (1.7.7), Rocky uses the following sensors:
Eventually, the contact bumpers will be upgraded to Cat's Whisker (piezoelectric contact) sensing, real estate permitting.