RoboJDETM v2.0

com.ridgesoft.robotics.behaviors
Class AvoidBehavior

java.lang.Object
  extended by com.ridgesoft.robotics.behaviors.AbstractBehavior2
      extended by 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

Field Summary
 
Fields inherited from class com.ridgesoft.robotics.behaviors.AbstractBehavior2
mEnabled, mIsActive, mListener
 
Constructor Summary
AvoidBehavior(Localizer localizer, Navigator navigator, AnalogInput leftRange, AnalogInput rightRange, int threshold, float turnAmount, int holdTime, boolean enabled)
          Constructs an AvoidBehavior object.
 
Method Summary
 boolean poll()
          This method is invoked at regular intervals to determine if the behavior desires to control the robot.
 
Methods inherited from class com.ridgesoft.robotics.behaviors.AbstractBehavior2
setActive, setEnabled, setListener
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait
 

Constructor Detail

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 localizer
navigator - the robot's navigator
leftRange - the analog input for the left range sensor
rightRange - the analog input for the right range sensor
threshold - 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 range
holdTime - the time, in milliseconds, to head away from the object
enabled - initial enabled state of the behavior
Method Detail

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

RoboJDETM v2.0

Copyright (c) 2003-2009 RidgeSoft, LLC. All rights reserved.
www.ridgesoft.com