| CSC 161 | Grinnell College | Spring, 2012 |
| Imperative Problem Solving and Data Structures | ||
A Scribbler 2 robot has numerous sensors for detecting the world, and the MyroC library provides function calls to obtain data from the sensors.
The following figures indicate which functions reference which sensors.
| Sensor Set | Vector Function | Text Functions | Number Functions | Values Returned | Comments |
|---|---|---|---|---|---|
| Light Sensors (really darkness sensors) | int vals[3] rGetLightAll(vals); | rGetLightTxt("left"); rGetLightTxt("middle"); rGetLightTxt("right"); | rGetLightNum(0); rGetLightNum(1); rGetLightNum(2); | bright light returns values near 0; dark areas return large integers (about 65,000) | bright, direct light needed for small-value results |
| IR Scribbler Sensors | int vals[2] rGetIRAll(vals); | rGetIRTxt("left"); rGetIRTxt("right"); | rGetIRNum(0); rGetIRNum(1); | output 0 indicates no obstacle; output 1 indicates obstacle | light must reflect from emitter to receiver, so obstacle must be a 4-6 inches away |
| Sensor Set | Vector Function | Text Functions | Number Functions | Values Returned | Comments |
|---|---|---|---|---|---|
| Obstacle Sensors | int vals[3] rGetObstacleAll(vals); | rGetObstacleTxt("left"); rGetObstacleTxt("middle"); rGetObstacleTxt("right"); | rGetObstacleNum(0); rGetObstacleNum(1); rGetObstacleNum(2); | 0 indicates no obstacle (no light reflected from emitters) large integers (about 6,000) indicates obstacle | value returned depends upon battery strength and output; level of emitters (set by rSetIRPower(level), where level in range 0, 255) |