lejos.robotics.objectdetection
Interface FeatureDetector

All Known Implementing Classes:
FeatureDetectorAdapter, FusorDetector, RangeFeatureDetector, TouchFeatureDetector

public interface FeatureDetector

A FeatureDetector is capable of detecting objects and notifying listeners when it detects something. A Feature is a term for any property that can be added to map data. The FeatureListener is notified when an object is detected, even if it has previously detected the same object.

The most basic feature is the Range Feature, which indicates the position of the detected object relative to the "center" of the robot (normally the point mid-way between the drive wheels). A robot with many bumpers arrayed around the robot will also report the bumper location relative to the robot center.

There can be many different qualities recorded by different FeatureDetector implementations. For example, you could implement a VectorFeatureDetector that could take multiple readings of an object, determine any change in position, and return the velocity/vector of the object (provided the sensor is capable of identifying an object and change in position). For example, a camera could note the change in position of objects and estimate the vector/velocity of the object.

Note: Because FeatureListener.featureDetected(Feature, FeatureDetector) and scan() are only capable of returning a Feature object, any classes that want to read extended feature qualities (e.g. vector, color, or person data) would need to use an instanceof test to see if it is the appropriate data container, then cast the object into that type in order to retrieve the unique data.

Author:
BB based on concepts by Lawrie Griffiths
See Also:
FeatureListener

Method Summary
 void addListener(FeatureListener listener)
          Adds a listener to the FeatureDetector.
 void enableDetection(boolean on)
          Enable or disable detection of objects.
 int getDelay()
          The minimum delay between notification of readings from the feature detector.
 boolean isEnabled()
          Indicates if automatic scanning mode and listener notification is currently enabled.
 Feature scan()
          Performs a single scan for an object and returns the results.
 void setDelay(int delay)
          Sets the minimum delay between readings from the feature detector.
 

Method Detail

addListener

void addListener(FeatureListener listener)
Adds a listener to the FeatureDetector. The FeatureListener will be notified when objects are detected.

Parameters:
listener - The FeatureListener that is notified every time a feature is detected.

scan

Feature scan()

Performs a single scan for an object and returns the results. If an object is not detected, this method returns null.

Warning: Make sure to check for a null object before trying to read data from the returned Feature object, otherwise your code will throw a null pointer exception.

Returns:
A feature it has detected. null if nothing found.

enableDetection

void enableDetection(boolean on)
Enable or disable detection of objects.

Parameters:
on - true enables detection and notifications, false disables this class until it is enabled again.

isEnabled

boolean isEnabled()
Indicates if automatic scanning mode and listener notification is currently enabled. (true by default)

Returns:
true if enabled, false if not

getDelay

int getDelay()
The minimum delay between notification of readings from the feature detector. If no objects are detected, no notification will occur. Some sensors, such as touch sensors, check the sensor more frequently than other sensors, such as range sensors.

Returns:
The delay between sensor readings.

setDelay

void setDelay(int delay)
Sets the minimum delay between readings from the feature detector. The notification thread will notify FeatureListener objects every delay milliseconds, unless it takes longer to retrieve readings from the sensor.

Parameters:
delay - The FeatureDetector will return one new set of readings every delay milliseconds.