Sensors, Sensing and Control


Saturday, 02/10/01

Your robot kit includes a variety of sensors, including simple contact or bump sensors, two shaft encoders or rotation sensors, and two light sensors that have integral light sources. Sensors are used to gain information about the world that is useful for guiding a robot to achieve a particular goal. Typically, the values returned by sensors have to be interpreted in order for the information to be directly useful for control purposes. Interpretation involves mapping sensed values to states of the world. Often enough this process of interpretation requires that we know a lot about the world so as to avoid being fooled by sensed values that are ambiguous or that are corrupted by noise (those parts of the signal that we don't care about and that potentially masquerade as parts of the signal that we do care about). Noise can come from sources in the external world, e.g., ambient light sources when you're trying to measure light from a particular source, or from the sensors themselves or any part of the sensor processing, e.g., degradation in the electrical characteristics of a sensor. In building good sensor systems, we'll have to understand the underlying physics as well as what we intend to use the information for in building a control system.

In Wednesday's lab you'll learn more about using the sensors in your robot kit, but today we'll talk about a much wider range of sensors, their limitations and applications in which they have been found to be particularly effective. As one source of additional information, Dave Gasperi has written extensively about the Lego sensors and his web page includes some information on the Lego light sensor drawn from a number of sources including a Japanese fellow who has reverse engineered the Lego light sensor. Gasperi discusses various methods for overcoming the limitations of having only three sensors, including ORing and ANDing sensor inputs together. Gasperi's page also includes a description of how the Lego rotation sensor works and a Lego version of Grey Walter's Machina Speculatrix.

Basic Sensors

Contact sensors are one of the most basic and useful sensors for building lego robots. Such sensors include mechanical contact microswitches, mercury switches, and Hall-effect sensors (that sense the presence of a magnetic field and are used in high-end keyboards since they are less sensitive to moisture and mechanical damage). Most switches require some sort of debouncing, signal processing, latching, etc., to be useful; the routines built into the standard firmware support various sensor modes for contact sensors that, e.g., trigger on the rising or falling edge of the square wave that results when the sensor is pressed or released. (Why is it necessary to debounce the switches on computer keyboards and is this same or some other sort of processing necessary for contact sensors used for, say, bump detection on soccer playing robots?) The standard firmware routines accessible through NQC or legOS wrap a layer of software abstraction around the sensors to make them easier to use.

In the case of sensors such as light sensors whose sensed values span a continuous range of values often the outputs of these sensors are converted to binary using one or more threshold levels. Multiple thresholds are used to induce hysteresis into sensing or control. Hysteresis typically involves using two thresholds to monitor (interpret) a signal or control a parameter. For example, in interpreting a sinusoidal signal (or any signal that varies continuously throughout its range), we might set one threshold to determine when the signal changes from "off" to "on" and another threshold to determine the opposite change. Typically, thermostats employ two thresholds for implement a form of hysteresis. For example, if you set the thermostat to 70 degrees, the device might turn the furnace on when the temperature drops below 68 degrees and turn the furnace off when the thermostat goes above 72 degrees. The resulting system is more robust to small disturbances and avoids rapidly switching the furnace on and off as might be the case with a single threshold. You'll probably want to use hysteresis in interpreting the light sensors in your robot designs.

There are lots of ways of categorizing sensors and we'll consider a few general categories here, but as the sensors become more complicated the lines between these categories often blur. Proprioceptive sensors measure signals that originate from sensing the robot itself, e.g., rotation sensors and shaft encoders for odometric sensing. The simplest rotation sensor operates by attaching the the axle whose rotation you want to measure to a disk with holes in it or with light (reflective) and dark (nonreflective) patches on it. A light sensor (e.g., phototransistor) and light source are then used to determine when the holes or patches are moving and thus the shaft rotating. This works to determine motion but not direction. Quadrature shaft encoders use two light sensor / source pairs positioned 90 degrees apart and a simple state machine to determine the direction in which the shaft is turning. The resolving power of a rotation sensor is determined by the number of holes / patches in the disk.

Proximity sensors measure the relative distance between the sensors and objects in the robot's environment, e.g., polaroid range finders and bump sensors. Digital camera systems that employ machine vision and image processing routines for recognizing objects and reconstructing 3-D scenes seem a separate category entirely and the systems themselves often blur the lines between sensing and sensor interpretation. We won't be talking about full fledged machine vision systems in this course. There are other sense modalities, e.g., temperature, tactile pressure, force and conductivity, that you may encounter in special applications.

There is also a distinction made between passive sensors that do not produce signals of their own and active sensors that emit signals that are subsequently sensed, perhaps in an attenuated, distorted, or delayed form, to extract information about the robot's environment. Active sensing is often used as part of a strategy to reduce the so-called signal-to-noise ratio. By emitting a signal that is different from the background signals we expect to encounter we can make it much easier to detect a particular signal. Active sensor strategies include using frequency or amplitude modulation or projecting patterns that are easy to distinguish from other signals. The Lego light sensors are active sensors. The fact that they have their own self-contained light sources makes them particularly useful for sensing light and dark patches on the floor; they can even be used for simple pattern recognition tasks. Light sensors are designed to be sensitive to different wavelengths of light; active infrared (IR) sensors are particularly useful as they don't emit light in the visible range. IR devices are used in TV remotes and to flush toilets or open doors.

All sensors require some interpretation. Here is the general form for a sensor of the sort we'll encounter in programming Lego robots.

Advanced Sensing

Polaroid ultrasonic ranging sensors are used to estimate distances to nearby objects by calculating the time it takes an ultrasonic pulse to travel from the Polaroid sensor to the object and then back to the sensor. The sensor is called a transceiver because it includes both a transducer for emitting a high-pitched pulse of sound and a receiver for detecting the energy of the reflected pulse. For a transmitted pulse to leave the sensor, strike a target two feet away, and then return the sensor requires an elapsed time of approximately 3.5 milliseconds. Polaroid sensors are typically packaged with circuitry to generate the ultrasonic pulse and then calculate the time of flight which is then converted into distance using the speed of sound. If the sensor is directly facing a sizable object, then the Polaroid sensor generally provides a reasonably accurate estimate of the distance to this object. However, when the surfaces of the nearest object are at an angle to the direction of travel of the ultrasonic pulse much of the energy is reflected away from the sensor possibly to return by a circuitous route having bounced off several other objects before returning to the sensor with enough energy to trigger terminate the time-of-flight calculation. The result could be an estimate of the distance to the nearest object which is misleading. While the temperature, the surface properties of sensed objects, and humidity, all can lead to inaccuracies, ultrasonic ranging with individual sensors or rings of sensors remains a popular method for obstacle avoidance and navigation.

To understand better how to interpret sonar data, you have to understand how sound propagates in your target environment. In the idealized case, the sound waves propagate as a cone approximatey 30 degrees wide. The further the sound propagates the more the power disipates and the larger the obstacle needed to reflect sufficient energy to trigger the time-of-flight return flag. In indoor environments, sonars can be effective up to 25 feet; in outdoor environments you're lucky if you can good performance at 8 feet. Due to frequency characteristics of the transducer, most ultrasonic sensors are unable to sense objects closer than about 11 inches. Real (non idealized) sonars generate secondary sound waves called side lobes that complicate interpretation. The geometry of propagating sound waves bouncing off surfaces that are not perpendicular to the wave front coupled with uncertainty about the specularity of surfaces using sonars for navigation tricky. The lore of mobile robotics abounds with tales of carefully tuned robots that go crazy when they enter an unfamiliar area, say, with highly specular surfaces (e.g., lots of glass) or highly absorbing surfaces (e.g, cloth partitions in many office environments).

Active IR sensors can be fooled by other sources of light in the infrared range. To make a good proximity sensor using infrared it is important to be able to distinquish the IR emitted by the source in the active sensor from other ambient sources of IR. This can be done by "labeling" the light emitted by the source using frequency modulation techniques. The IR source is made to turn on and off at a particular frequency. Then the output of the IR sensor is electronically filtered to eliminate signals except those at the specified frequency. IR proximity sensors provide a crude but useful sensor for detecting the presence of nearby objects and are often used in conjunction with Polaroid sensors as part of a general strategy for navigation and obstacle avoidance. The Sony Aibo robot dog uses IR proximity sensing. (Another way of labeling the light source for an active sensor is to project the light as a distinct pattern. Researchers at U of Penn's GRASP lab once had a mobile robot that carried an overhead projector with a transparency of a grid pattern taped to its surface. A vision system analyzed the distortions in the pattern when projected on an object to make guesses about the location and 3-D orientation of the surfaces of the object with respect to the frame of reference of the robot. It was very effective but most people don't want a robot wandering the halls shining an overhead projector into everyone's face.)

Laser range finders are popular active sensors that are often used as an alternative to ultrasonic range finders such as the Polaroid sensor. A typical laser range finder takes advantage of the geometry (similar triangles) of reflected light and the ability to easily extract light of a particular narrow range of wavelengths using optical filters. In the so-called laser light striper type of range finder, a laser of a given frequency is focused as a stripe or narrow band of light by a cylindrical lens. For robot navigation tasks, this thin stripe of laser light is generally aimed along a plane horizontal to the ground. When the light hits an object, some of the light is reflected back toward the sensor where a flat CCD (for Charge Coupled Device) array is mounted at a known distance and angle with respect to the laser. The array is essentially a matrix of tiny light sensitive sensors. An optical filter in front of the CCD array admits only light of the same wavelength as the laser. Each vertical column on the image plane of the array corresponds to a point along the laser light stripe. The element of a given column registering the greatest intensity provides us with the means to calculate an estimate of the distance to the nearest object directly in front of the corresponding point along the laser light stripe. The following diagram gives some clue as to how this accomplished.


Sunday, 02/11/01

Sensing is performed to gain information about the world that is useful for decision making. Often, the programmer has in mind some desired state of the world and wants to reduce the difference (or error) between the desired and the actual state of the world so as to eventually achieve the desired state. In cases such as designing a cruise control for an automobile, this view of control is easy to realize in a feedback controller. In other cases such as cleaning an office or delivering mail, the view is less useful. Nevertheless, simple feedback systems figure prominently in the low-level control components of more complicated systems and are worth understanding. The follow diagram (adapted from [Martin, 2001]) illustrates the basic components of feedback control.

Feedback control is useful for such low-level behaviors as following walls, controlling the speed of a mobile robot as it travels over uneven terrain, docking maneuvers, and a host of other applications in which there is an obvious error signal that can be used to adjust a control parameter for achieving a given purpose. As to the particulars of how to adjust control parameters, I refer back to an earlier journal entry in which I discuss PID (for Proportional Integral Derivative) control in the context of controlling robots. There are advanced courses in engineering devoted to the art and mathematics of PID control and we have no intention of covering this material in detail; however, there are some very basic ideas that are easy to absorb and apply in building Lego robots.


Previous Home Next


Last updated on February 11, 2001.

Home