3.2. Sensors

How can we define a sensor?

A sensor is a device that measures and converts a physical quantity into a signal which can be processed. Examples:

  • temperature / humidity / pressure
  • motion / distance
  • presence or absence of an object
  • etc.

In robotics most common used sensors are:

  • infrared sensors
  • accelerometers
  • gyroscopes
  • proximity sensors
  • temperature and humidity
  • ultrasonic range finders
  • current and voltage sensors
  • cameras and vision sensors

During this workshop you will use two sensors:

  • Sharp Analog Distance Sensor 10-80cm
  • Sharp Digital Distance Sensor 10cm

Both sensors are infrared sensors. They work by emitting an infrared wave which reflects back when it hits an object. The reflected wave is then processed and converted into a signal.

If the signal is produced by an analog sensor, we know how far away the object is positioned.

If the signal is produced by a digital sensor, we only know if an object is in front of the sensor or not.

Analog vs Digital

Analog sensors

What is an analog sensor?

We can define an analog sensor as a device which measures and converts a physical quantity into a continuously variable signal. That signal can vary between some limits (e.g. in our case between 0V and 5V).

Figure 1. Example of an analog signal

One simple analog sensor is the potentiometer. The potentiometers are great for determining the angle of a robot arm. Their resistance changes depending on the current angular position.

  • Sharp analog distance sensor
    • the detection range of this sensor is 10-80 cm
    • the distance is indicated through an analog voltage
Figure 2. Correspondence between distance and voltage

More information about the sensor can be found in the datasheet: http://www.pololu.com/file/0J85/gp2y0a21yk0f.pdf or here http://www.pololu.com/catalog/product/136

Digital sensors

What is a digital sensor?

  • A digital sensor can defined as a device that measures and converts a physical quantity into a discrete signal.
Figure 3. Example of digital discrete signal

In our particular case, the discrete signal represents two logic values:

  • logic “1” – meaning that the signal is HIGH and the voltage is close to 5V
  • logic “0” – meaning that the signal is LOW and the signal is close to 0V

How does it work?

Most of the input sensors use a pull-up resistor to force the line HIGH (around 5V). When the sensor detects something it pulls the line LOW.

For object detection during the workshop you will use a digital distance sensor. The sensor’s output will be:

  • HIGH ⇒ meaning that no object was detected
  • LOW ⇒ meaning that an object was detected

The sensor that you will use is able to detect objects between 2 cm and 10 cm. Note that this sensor will tell you if an object is within the detection range, not how far away the object is placed.

More information about the sensor can be found in the datasheet: http://www.pololu.com/file/0J154/GP2Y0D810Z0F.pdf or here http://www.pololu.com/catalog/product/1134

Filtering results

Noise

What is noise?

Noise can be considered any unwanted signal which alters another signal.

Figure 4. Noisy signal

As in real life, noise is bad, and we have to find a way to remove it.

Filters

What is a filter? A filter is an algorithm which receives a noisy signal and tries to obtain a more accurate signal.

Types of filters

  1. Averaging filter
    • The filter takes calculates the average value for N consecutive readings. Because it’s a very basic technique, it doesn’t work always well because gives all the readings the same weight in calculating the final result (e.g. if we have spiky signal, the spikes are considered valid, but they aren’t).
Figure 5. Signal with spikes
  1. Median filter
    • It’s better than the averaging filter in reducing the noise.
    • The filter takes N measurements, sorts them ascending and takes the middle value.
    • It is less susceptible to noise, including spikes, because the noisy values end up at the beginning or at the end.
    • The filter assumes that exist at least some correct measurements.
  2. Modal filter
    • It’s a combination of median and averaging filter.
    • Values are sorted first and then the middle values are averaged
  3. Kalman filter
    • It’s a two step algorithm.
    • To compute the current state it needs only the previous estimated state and current measurements.
    • Steps:
      1. Prediction step: the algorithm produces estimates for the current state, based on previous measurements.
      2. Updating: the estimates are compared with current measurements. The estimates are updated using a weighted average. More weight is being given to estimates with higher certainty.
    1. Low/High/Band Pass filter
      • Low pass filter sets an upper threshold. If the value is lower than the threshold, it passes unmodified. If the value is higher, the filter modifies the value to be equal to the threshold.
    • High pass filter sets a lower threshold. If the value is higher than the threshold it passes unmodified. If the value is lower, the filter modifies the value to be equal to the threshold.
    • Band pass filter is a combination between low pass and high pass filter.
signals.jpg
Figure 6. Blue and red signals are noisy. Green and purple signals are filtered signals.

Resources

roboticsisfun/chapter3/ch3_2_sensors.txt · Last modified: 2012/11/25 14:07 by liviu.radoi