com.ridgesoft.robotics.behaviors
Class AvoidBehavior
java.lang.Object
com.ridgesoft.robotics.behaviors.AbstractBehavior2
com.ridgesoft.robotics.behaviors.AvoidBehavior
- All Implemented Interfaces:
- Behavior, Behavior2
public class AvoidBehavior
- extends AbstractBehavior2
Implements a behavior that will enable a robot with left and right range
sensors to avoid obstacles when the behavior is enabled.
Sharp infrared range sensors, such as the popular GP2D12, are a good choice
of sensor for use with this class.
- See Also:
BehaviorArbiter
,
SharpGP2D12
Method Summary |
boolean |
poll()
This method is invoked at regular intervals to determine if the behavior
desires to control the robot. |
AvoidBehavior
public AvoidBehavior(Localizer localizer,
Navigator navigator,
AnalogInput leftRange,
AnalogInput rightRange,
int threshold,
float turnAmount,
int holdTime,
boolean enabled)
- Constructs an AvoidBehavior object.
- Parameters:
localizer
- the robot's localizernavigator
- the robot's navigatorleftRange
- the analog input for the left range sensorrightRange
- the analog input for the right range sensorthreshold
- the range sensor threshold value for object detection. A
sensor reading above this value triggers this behavior.turnAmount
- the amount to turn, in radians, when an obstacle is in rangeholdTime
- the time, in milliseconds, to head away from the objectenabled
- initial enabled state of the behavior
poll
public boolean poll()
- This method is invoked at regular intervals to determine if the behavior
desires to control the robot.
If active, this method will steer the robot to avoid obstacles.
- Specified by:
poll
in interface Behavior
- Specified by:
poll
in class AbstractBehavior2
- Returns:
- true if the behavior wants control of the robot, otherwise false
Copyright (c) 2003-2009 RidgeSoft, LLC. All rights reserved.
www.ridgesoft.com