CSC 161 Grinnell College Spring, 2014
 
Imperative Problem Solving and Data Structures
 
 

Sensors for the Scribbler 2 Robot

A Scribbler 2 robot has numerous sensors for detecting the world. Two versions are available, providing functioncalls to obtain data from the sensors.

The following figures indicate which functions reference which sensors.

Scribbler forward

Scribbler 2 with
                                                  scribbler-forward
Sensor Set Vector Function Text Functions Number Functions Values Returned Typical Variability Comments
Light Sensors
(really darkness sensors)
int vals[3]
# rGetLightAll(vals);

@ int n; /*sampleSize*/
@ rGetLightAll(vals, n);
# rGetLightTxt("left");
# rGetLightTxt("middle");
# rGetLightTxt("right");

@ int n; /*sampleSize*/
@ rGetLightTxt("left", n);
@ rGetLightTxt("middle", n);
@ rGetLightTxt("right", n);
# rGetLightNum(0);
# rGetLightNum(1);
# rGetLightNum(2);
bright light returns values near 0;
dark areas return large integers (about 65535)
under 5%-10% bright, direct light needed for small-value results
 
IR Scribbler Sensors int vals[2]
# rGetIRAll(vals);

@ int n; /*sampleSize*/
@ rGetIRAll(vals, n);
# rGetIRTxt("left");
# rGetIRTxt("right");

@ int n; /*sampleSize*/
@ rGetIRTxt("left", n);
@ rGetIRTxt("right", n);
# rGetIRNum(0);
# rGetIRNum(1);
output 0 indicates no obstacle;
output 1 indicates obstacle
substantial variation likely; sample several times for average light must reflect from emitter to receiver, so obstacle must be a 4-6 inches away

Key:

Fluke forward

Scribbler 2 with fluke-forward
Sensor Set Vector Function Text Functions Number Functions Values Returned Typical Variability Comments
Obstacle Sensors int vals[3]
# rGetObstacleAll(vals);

@ int n; /*sampleSize*/
@ rGetObstacleAll(vals, n);
# rGetObstacleTxt("left");
# rGetObstacleTxt("middle");
# rGetObstacleTxt("right");

@ int n; /* sampleSize */
@ rGetObstacleTxt("left", n);
@ rGetObstacleTxt("middle", n);
@ rGetObstacleTxt("right", n);
# rGetObstacleNum(0);
# rGetObstacleNum(1);
# rGetObstacleNum(2);
values near 0 indicate no obstacle (no light reflected from emitters)
large integers (near 6,000) indicates obstacle
substantial variation possible; sensor values degrade as battery degrades value returned depends upon battery strength and output; level of emitters (set by rSetIRPower(level), where level in range 0, 255)
  • values under 1000 are likely to imply an obstacle
  • values over 5000 are likely to imply no obstacle
  • values between 1000 and 5000 may not give definitive results
 
Virtual Light Sensors int vals[2];
# rGetBrightAll(vals);

@ int n; /* sampleSize */
@ rGetBrightAll(vals, n);
# rGetBrightTxt("left");
# rGetBrightTxt("right");

@ int n; /* sampleSize */
@ rGetBrightTxt("left", n);
@ rGetBrightTxt("right", n);
not available values near 0 represent bright light; values may extend to about 65535 for very dark region variation of 5000-10000 common averaging encouraged for modest consistency

Key: