Previous Page TOC Index Next Page

BeeSoft User's Guide and Reference

5.2 Infrared Sensors

Infrared light — that part of the electromagnetic spectrum of radiation above 0.75 millimeters in wavelength — is not visible to humans. (We perceive it only as heat.) In many ways, your robot’s infrared sensors are like its sonars: they send out a signal — in this case, infrared light instead of ultrasonic waves — and provide the robot information it can use to help build up a picture of its surroundings.

Your robot incorporates several rows of infrared sensors. These are in the rectangular openings arrayed around the robot’s perimeter, along the lower section of the upper enclosure, and around the lower part of the mobile base. On the B21 robot, there are 56 in all (24 on the enclosure and 32 on the base); the B14 carries 16. For purposes of identification by programs, the IR’s are numbered: IR zero is located at the left rear; numbers ascend clockwise. The rows of IR’s are numbered from the top down, with row one nearer the top of the robot. These sensors give some indication of the proximity of an obstacle by emitting light and measuring the intensity of the reflection bounced back off the obstacle’s surface. The robot "reads" these IR sensors about ten times per second.

The infrared sensors have a fairly short range — about ½ meter — and the reflectance value is heavily dependent on the color of the object detected. Because color affects reflectance so strongly, the robot can find it quite difficult to gain an accurate assessment of the proximity of an object. Mirrors, glass walls and solidly black objects, for example, are apt to mightily confuse the infrared sensors.

The Infrared Application Program Interface (API)

These are the calls and data structures you need to know about to use the your robot’s infrared sensors.

IR Data Structures

irType irs[B_MAX_SENSOR_ROWS] [B_MAX_SENSOR_COLS] - The array containing the reflectance values returned by the infrared transducers. As each infrared returns its readings, it fills in the two-dimensional array structure, irType. Each individual element in the array irs, of type irType, looks like this:

value: An integer representing the reflectance value. This is the actual measurement of the IR’s perception of the obstacle’s reflectance. Values range from zero (no reflectance) to 100 (full reflectance).

mostRecent: An integer, either TRUE or FALSE. If TRUE, the data structure contains a value harvested from the most recent reading.
time: A timeval struct indicating the time the reading was received.

b.Robot.ir_rows - Number of rows of infrareds on the robot, numbered from the top of the robot starting at 1.

int bRobot.ir_cols[bRobot.ir_rows] - An array containing the actual number of IR transducers, and their values, for each infrared row. If bRobot.ir_cols[0] is n, then irs[0][i] does not contain valid data for n >= 0. You can use the value of bRobot.ir_cols to iterate through the valid rows of infrared sensors.

IR API Function Calls

void registerIrCallback (irCallbackType);

Specifies which function BeeSoft should call when it has a fresh set of infrared readings available. It will be called with an updated array of irType.

void irInit(void);

Initializes the infrared system. Call this before calling any other infrared function.

void irStop(void);

Halt operation of the infrared transducers. You don’t need to use this unless your program needs to halt, and then restart, the infrared sensors..

void irStart(void);

Begin operation of the infrared transducers once you’ve halted them.

Previous Page Page Top TOC Index Next Page