Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

ArActionTriangleDriveTo Class Reference

Action to drive up to a triange found from an ArLineFinder. More...

#include <ArActionTriangleDriveTo.h>

Inheritance diagram for ArActionTriangleDriveTo:

ArAction List of all members.

Public Types

enum  State {
  STATE_INACTIVE, STATE_ACQUIRE, STATE_SEARCHING, STATE_GOTO_APPROACH,
  STATE_ALIGN_APPROACH, STATE_GOTO_VERTEX, STATE_GOTO_FINAL, STATE_ALIGN_FINAL,
  STATE_SUCCEEDED, STATE_FAILED
}

Public Member Functions

virtual void activate (void)
 Activate the action.
 ArActionTriangleDriveTo (const char *name="triangleDriveTo", double finalDistFromVertex=400, double approachDistFromVertex=1000, double speed=200, double closeDist=100, double acquireTurnSpeed=30)
 Constructor.
virtual void deactivate (void)
 Deactivate the action.
virtual ArActionDesiredfire (ArActionDesired currentDesired)
 Fires the action, returning what the action wants to do.
bool getAcquire (void)
 Gets if we will turn to see if we can acquire the triangle.
bool getAdjustVertex (void)
 Gets whether we adjust the vertex or not.
DatagetData (void)
 Interal use only, gets the data we've saved.
virtual ArActionDesiredgetDesired (void)
 Gets what this action wants to do (for display purposes).
double getFinalDistFromVertex (void)
 Sets the final distance from vertex.
bool getGotoVertex (void)
 Gets whether it always goto the vertex and not the point in front.
ArLineFindergetLineFinder (void)
 Sets the line finder used.
bool getSaveData (void)
 Internal use only, gets if we're saving data or not.
State getState (void)
int getVertexUnseenStopMSecs (void)
 How long to keep going without having seen the vertex (0 is no timeout).
void setAcquire (bool acquire=false)
 Sets if we will turn to see if we can acquire the triangle.
void setAdjustVertex (bool adjustVertex)
 Sets whether we adjust the vertex or not.
void setFinalDistFromVertex (double dist)
 Sets the final distance from vertex.
void setGotoVertex (bool gotoVertex)
 Sets whether it always goto the vertex and not the point in front.
void setLineFinder (ArLineFinder *lineFinder)
 Sets the line finder to use.
bool setLogging (void)
 Gets whether we're logging the driving or not.
void setLogging (bool logging)
 Sets whether we're logging the driving or not.
void setParameters (double finalDistFromVertex=400, double approachDistFromVertex=1000, double speed=200, double closeDist=100, double acquireTurnSpeed=30)
virtual void setRobot (ArRobot *robot)
 Sets the robot this action is driving.
void setSaveData (bool saveData)
 Internal use only, sets if we're saving data or not.
void setTriangleParams (double line1Length=254, double angleBetween=135, double line2Length=254)
 Sets the parameter of the triangle we're looking for.
void setVertexUnseenStopMSecs (int vertexUnseenStopMSecs=4000)
 How long to keep going without having seen the vertex (0 is no timeout).
virtual ~ArActionTriangleDriveTo ()
 Destructor.

Protected Member Functions

ArPose findPoseFromVertex (double distFromVertex)
void findTriangle (bool initial, bool goStraight=false)

Protected Attributes

bool myAcquire
double myAcquireTurnSpeed
bool myAdjustVertex
double myAngleBetween
double myApproachDistFromVertex
double myCloseDist
DatamyData
ArMutex myDataMutex
ArActionDesired myDesired
double myFinalDistFromVertex
unsigned int myGotLinesCounter
bool myGotoVertex
ArRangeDevicemyLaser
double myLine1Length
double myLine2Length
ArLineFindermyLineFinder
std::map< int, ArLineFinderSegment * > * myLines
bool myOwnLineFinder
bool myPrinting
bool mySaveData
double mySpeed
State myState
bool myTwoStageApproach
ArPose myVertex
bool myVertexSeen
ArTime myVertexSeenLast
int myVertexUnseenStopMSecs

Classes

class  Data

Detailed Description

Action to drive up to a triange found from an ArLineFinder.

For setting up this action, by default what it will do is find an ArRangeDevice with the name of "laser" attached to the robot and make an ArLineFinder from that. You can also make an ArLineFinder and pass that to the class (you should do it before you do the addAction, but you don't have to).

This action will drive up to a triangle (the triangle description is set with setTriangleParams), it will first pick a triangle and then try to drive to that triangle. If setTwoStageApproach is true (default) it will first drive to a half meter away from the desired spot (distFromVertex from the point of the vertex along the bisection of the angle between segments) and then after it reachs that point it will turn in towards the vertex and drive to the final spot. If setTwoStageApproach is false it'll just drive to the final spot. It will stop at closeDist away unless a large turn is required where it'll stop 2 * closeDist away. It drives in at the speed in the constructor. If the robot is closer to the vertex than it should be for the approach it'll skip the approach, if the robot is closer to the vertex than to the final spot it will back up (if its facing away from the vertex it won't see the vertex).

If you want the action to drive straight to the vertex instead of to a point in front of it call setGotoVertex with a true argument... It will no longer do this if finalDistFromVertex is 0... you would do this if you want to drive until a bumper is hit for instance.

If you want the action to position using the front of the robot then use setPositionFront

Definition at line 67 of file ArActionTriangleDriveTo.h.


Member Enumeration Documentation

enum ArActionTriangleDriveTo::State
 

Enumeration values:
STATE_INACTIVE  we aren't trying
STATE_ACQUIRE  finding the target
STATE_SEARCHING  Turning trying to find the target.
STATE_GOTO_APPROACH  driving to the approach point
STATE_ALIGN_APPROACH  aligning to the target the first time
STATE_GOTO_VERTEX  driving to the vertex
STATE_GOTO_FINAL  driving to the final point
STATE_ALIGN_FINAL  aligning to the target the final time
STATE_SUCCEEDED  pointing at the target
STATE_FAILED  if we're not acquiring and we lost the vertex we fail

Definition at line 119 of file ArActionTriangleDriveTo.h.


Member Function Documentation

void ArActionTriangleDriveTo::findTriangle bool  initial,
bool  goStraight = false
[protected]
 

This finds our vertex point and angle from vertex.

Parameters:
initial if we're finding the initial vertex then we look for more in front of us than on the side and closer, if we're not finding the initial one we look more towards where we found it last time

difference between line1 and how long it should be

difference between line2 and how long it should be

Definition at line 153 of file ArActionTriangleDriveTo.cpp.

References ArMath::addAngle(), ArMath::cos(), ArRangeDevice::currentReadingBox(), ArTransform::doInvTransform(), ArTransform::doTransform(), ArMath::fabs(), ArPose::findAngleTo(), ArRobot::findDeltaHeadingTo(), ArPose::findDistanceTo(), ArUtil::findMax(), ArRobot::getCounter(), ArLineSegment::getDistToLine(), ArRobot::getEncoderTransform(), ArLineSegment::getEndPoint1(), ArLineFinder::getLines(), ArRobot::getPose(), ArRobot::getTh(), ArPose::getTh(), ArRobot::getToGlobalTransform(), ArRobot::getToLocalTransform(), ArPose::getX(), ArPose::getY(), ArLine::intersects(), ArMutex::lock(), ArLog::log(), ArLineSegment::newEndPoints(), ArActionTriangleDriveTo::Data::setLinesAndVertex(), ArPose::setPose(), ArPose::setTh(), ArTime::setToNow(), ArMath::sin(), ArMath::subAngle(), and ArMutex::unlock().

Referenced by fire().

ArActionDesired * ArActionTriangleDriveTo::fire ArActionDesired  currentDesired  )  [virtual]
 

Fires the action, returning what the action wants to do.

Parameters:
currentDesired this is what the current resolver has for its desired, this is SOLELY for the purpose of giving information to the action
Returns:
pointer to what this action wants to do, NULL if it wants to do nothing

Implements ArAction.

Definition at line 442 of file ArActionTriangleDriveTo.cpp.

References ArTransform::doTransform(), ArMath::fabs(), ArPose::findAngleTo(), ArRobot::findDeltaHeadingTo(), ArPose::findDistanceTo(), ArRobot::findDistanceTo(), findTriangle(), ArRobot::getEncoderTransform(), ArRobot::getPose(), ArRobot::getTh(), ArRobot::getVel(), ArMutex::lock(), ArLog::log(), ArTime::mSecSince(), ArActionDesired::reset(), ArActionTriangleDriveTo::Data::setApproach(), ArActionDesired::setDeltaHeading(), ArActionTriangleDriveTo::Data::setFinal(), ArActionDesired::setHeading(), ArActionDesired::setRotVel(), ArActionDesired::setVel(), STATE_ACQUIRE, STATE_ALIGN_APPROACH, STATE_ALIGN_FINAL, STATE_FAILED, STATE_GOTO_APPROACH, STATE_GOTO_FINAL, STATE_GOTO_VERTEX, STATE_INACTIVE, STATE_SEARCHING, STATE_SUCCEEDED, and ArMutex::unlock().


The documentation for this class was generated from the following files:
Generated on Wed Oct 19 12:56:42 2005 for Aria by  doxygen 1.4.0