Download coen-2003-project-22..

Transcript
}
B.6 The Action Maintain Distance Behavior and UWB Access Files
/*
Defintion of the ActionMaintainDistance class
*/
#include
#include
#include
#include
"Aria.h"
"PADRequest.h"
<stdio.h>
<iostream.h>
class ActionMaintainDistance : public ArAction
{
public:
// constructor, sets myDistance, robot, and the PAD
ActionMaintainDistance(double distance, PADRequest* PADComm, bool
inFront, bool simulator);
// destructor, its just empty, we don't need to do anything
virtual ~ActionMaintainDistance(void) {};
// fire, this is what the resolver calls to figure out what this
action wants
virtual ArActionDesired *fire(ArActionDesired currentDesired);
// sets the robot pointer, also gets the sonar device
virtual void setRobot(ArRobot *robot);
protected:
// this is to hold the sonar device form the robot
ArRangeDevice *mySonar;
// what the action wants to do
ArActionDesired myDesired;
// distance to stop at
double myDistance;
// myFrontFlag is true if the robot is in front of the other
bool myFrontFlag;
// mySimulator is true if we are using the simulator
bool mySimulator;
// need to keep track of the current range for thhe simulator
double myRange;
// Array to check that error is getting smaller
double errors[2];
PADRequest* myPADComm;
};
/*
File: ActionMaintainDistance.cpp
This is the action definition for the Maintain Distance Behavior
It uses the Ultra Wideband functionality to determine the distance
between two UWB units and then maintains the desired range.
*/
77