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.
FeatureListener
Modifier and Type | Method and Description |
---|---|
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.
|
void addListener(FeatureListener listener)
listener
- The FeatureListener that is notified every time a feature is detected.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.
void enableDetection(boolean on)
on
- true enables detection and notifications, false disables this class until it is enabled again.boolean isEnabled()
int getDelay()
void setDelay(int delay)
delay
- The FeatureDetector will return one new set of readings every delay milliseconds.