Class LightScanner

  extended by lejos.robotics.LightScanner

public class LightScanner
extends java.lang.Object

Software abstraction of a light sensor rotating in a horizontal plane, driven by a motor. Records the raw light value and bearing of beacons seen during a scan, This class assumes that the motor tacho count corresponds to the angle of the sensor in the navigational plane.
After a forward scan is complete, the scan is repeated in the reverse direction and the data are averaged. This averages out the gear backlash error. The results of a scan are returned as a set of RangeReadings, not a good name but this class does have enough fields to do the job. If used in MCL however, a different class name should be used because the algorithm for calculation of particle weights is very different if the basic is angles rather than ranges.

Roger Glassey

Field Summary
protected  RegulatedMotor head
Constructor Summary
LightScanner(RegulatedMotor headMotor, LightDetector lightDetector, int minBeaconLight, int background)
          Specify the hardware for this object.
Method Summary
 RegulatedMotor getMotor()
 void halt()
 RangeReadings scanLight(float startAngle, float endAngle, int direction, int numReadings)
          Perform a scan for a number of light beacons within the arc defined by the start and end angles in the specified direction.
 void setSpeed(int speed)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


protected RegulatedMotor head
Constructor Detail


public LightScanner(RegulatedMotor headMotor,
                    LightDetector lightDetector,
                    int minBeaconLight,
                    int background)
Specify the hardware for this object. Light values less than background are ignored. When a light value larger than minBeaconLight is sensed, it is within the field of view of the light sensor. As scanning continues, when the light value drops below background, it is assumed that the beacon has been passed, and the angle at which the maximum occurred is the angle of the beacon.

headMotor -
lightDetector -
minBeaconLight -
background -
Method Detail


public void setSpeed(int speed)


public void halt()


public RangeReadings scanLight(float startAngle,
                               float endAngle,
                               int direction,
                               int numReadings)
Perform a scan for a number of light beacons within the arc defined by the start and end angles in the specified direction. Scan in both directions and use the average of the angles. Assumes the scanner hardware is built so that increasing tacho count of the motor corresponds to increasing angle in the navigation plane.

startAngle - of the arc
endAngle - of the arc
direction - of the scan. +1 = increasing tacho count of motor.
numReadings -
the set of range readings, containing the light intensity and angle of each beacon


public RegulatedMotor getMotor()