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

ArRobot Class Reference

THE important class. More...

#include <ArRobot.h>

List of all members.

Public Types

enum  ChargeState {
  CHARGING_UNKNOWN = -1, CHARGING_NOT = 0, CHARGING_BULK = 1, CHARGING_OVERCHARGE = 2,
  CHARGING_FLOAT = 3
}
enum  WaitState {
  WAIT_CONNECTED, WAIT_FAILED_CONN, WAIT_RUN_EXIT, WAIT_TIMEDOUT,
  WAIT_INTR, WAIT_FAIL
}

Public Member Functions

void actionHandler (void)
 Action Handler, internal.
bool addAction (ArAction *action, int priority)
void addConnectCB (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST)
 Adds a connect callback.
void addDisconnectNormallyCB (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST)
 Adds a callback for when disconnect is called while connected.
void addDisconnectOnErrorCB (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST)
 Adds a callback for when disconnection happens because of an error.
void addFailedConnectCB (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST)
 Adds a callback for when a connection to the robot is failed.
void addPacketHandler (ArRetFunctor1< bool, ArRobotPacket * > *functor, ArListPos::Pos position=ArListPos::LAST)
 Adds a packet handler to the list of packet handlers.
void addRangeDevice (ArRangeDevice *device)
 Adds a rangeDevice to the robot's list of them, and set the device's robot pointer.
void addRunExitCB (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST)
 Adds a callback for when the run loop exits for what ever reason.
bool addSensorInterpTask (const char *name, int position, ArFunctor *functor, ArTaskState::State *state=NULL)
 Adds a task under the sensor interp part of the syncronous tasks.
void addStabilizingCB (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST)
 Adds a callback called when the robot starts stabilizing before declaring connection.
bool addUserTask (const char *name, int position, ArFunctor *functor, ArTaskState::State *state=NULL)
 Adds a user task to the list of synchronous taskes.
void applyTransform (ArTransform trans, bool doCumulative=true)
 This applies a transform to all the robot range devices and to the sonar.
bool areMotorsEnabled (void) const
 returns true if the motors are enabled
bool areSonarsEnabled (void) const
 returns true if the motors are enabled
void ariaExitCallback (void)
 internal function called when Aria::exit is called
 ArRobot (const char *name=NULL, bool ignored=true, bool doSigHandle=true, bool normalInit=true, bool addAriaExitCallback=true)
 Constructor.
bool asyncConnect (void)
 Connects to a robot, from the robots own thread.
int asyncConnectHandler (bool tryHarderToConnect)
 Internal function, shouldn't be used, does a single run of connecting.
void attachKeyHandler (ArKeyHandler *keyHandler, bool exitOnEscape=true, bool useExitNotShutdown=true)
 Attachs a key handler.
bool blockingConnect (void)
 Connects to a robot, not returning until connection made or failed.
void cancelConnection (void)
 Internal function, shouldn't be used, cancels the connection quietly.
double checkRangeDevicesCumulativeBox (double x1, double y1, double x2, double y2, ArPose *readingPos=NULL) const
double checkRangeDevicesCumulativePolar (double startAngle, double endAngle, double *angle=NULL) const
 Goes through all the range devices and checks them.
double checkRangeDevicesCurrentBox (double x1, double y1, double x2, double y2, ArPose *readingPos=NULL) const
double checkRangeDevicesCurrentPolar (double startAngle, double endAngle, double *angle=NULL) const
 Goes through all the range devices and checks them.
void clearDirectMotion (void)
 Clears what direct motion commands have been given, so actions work.
bool com (unsigned char command)
 Sends a command to the robot with no arguments.
bool com2Bytes (unsigned char command, char high, char low)
 Sends a command to the robot with two bytes for argument.
bool comInt (unsigned char command, short int argument)
 Sends a command to the robot with an int for argument.
bool comStr (unsigned char command, const char *argument)
 Sends a command to the robot with a string for argument.
bool comStrN (unsigned char command, const char *str, int size)
 Sends a command to the robot with a size bytes of str as argument.
void deactivateActions (void)
 Deactivates all the actions.
void disableMotors ()
 Disables the motors on the robot.
bool disconnect (void)
 Disconnects from a robot.
void dropConnection (void)
 Internal function, shouldn't be used, drops the conn because of error.
void enableMotors ()
 Enables the motors on the robot.
void failedConnect (void)
 Internal function, shouldn't be used, denotes the conn failed.
ArActionfindAction (const char *actionName)
double findAngleTo (const ArPose pose)
 Gets the distance to a point from the robot.
double findDeltaHeadingTo (const ArPose pose)
 Gets the distance to a point from the robot.
double findDistanceTo (const ArPose pose)
 Gets the distance to a point from the robot.
ArRangeDevicefindRangeDevice (const char *name)
 Finds a rangeDevice in the robot's list.
const ArRangeDevicefindRangeDevice (const char *name) const
 Finds a rangeDevice in the robot's list.
ArSyncTaskfindTask (ArFunctor *functor)
 Finds a task by functor.
ArSyncTaskfindTask (const char *name)
 Finds a task by name.
ArSyncTaskfindUserTask (ArFunctor *functor)
 Finds a user task by functor.
ArSyncTaskfindUserTask (const char *name)
 Finds a user task by name.
void finishedConnection (void)
 Internal function, shouldn't be used, does the after conn stuff.
double getAbsoluteMaxRotVel (void) const
 Gets the robots absolute maximum rotational velocity.
double getAbsoluteMaxTransVel (void) const
 Gets the robots absolute maximum translational velocity.
ArResolver::ActionMapgetActionMap (void)
unsigned char getAnalog (void) const
 Gets the analog value.
int getAnalogPortSelected (void) const
 Gets which analog port is selected.
double getBatteryVoltage (void) const
 Gets the battery voltage of the robot (normalized to 12 volt system).
size_t getBatteryVoltageAverageOfNum (void)
 Gets the number of readings the battery voltage is the average of.
double getBatteryVoltageNow (void) const
 Gets the instaneous battery voltage.
ChargeState getChargeState (void) const
 Gets the charge state of the robot (see long docs).
int getClosestSonarNumber (double startAngle, double endAngle) const
 Returns the number of the sonar that has the closest current reading in the given range.
int getClosestSonarRange (double startAngle, double endAngle) const
 Returns the closest of the current sonar reading in the given range.
double getCompass (void) const
 Gets the compass heading from the robot.
unsigned int getConnectionCycleMultiplier (void) const
 Gets the multiplier for how many cycles ArRobot waits when connecting.
int getConnectionTimeoutTime (void) const
 Gets the time without a response until connection assumed lost.
double getControl (void) const
 Gets the control heading.
unsigned int getCounter (void) const
 Gets the Counter for the time through the loop.
unsigned int getCycleTime (void) const
 Gets the number of ms between cycles.
unsigned int getCycleWarningTime (void)
 Gets the number of ms between cycles to warn over.
unsigned int getCycleWarningTime (void) const
 Gets the number of ms between cycles to warn over.
ArDeviceConnectiongetDeviceConnection (void) const
 Gets the connection this instance uses.
unsigned char getDigIn (void) const
 Gets the byte representing digital input status.
unsigned char getDigOut (void) const
 Gets the byte representing digital output status.
unsigned int getDirectMotionPrecedenceTime (void) const
ArRetFunctor1< double, ArPoseWithTime > * getEncoderCorrectionCallback (void) const
 Gets the encoderCorrectionCallback.
ArPose getEncoderPose (void) const
 Gets the position of the robot according to the encoders.
size_t getEncoderPoseInterpNumReadings (void) const
 Sets the number of packets back in time the encoder position interpolation goes.
int getEncoderPoseInterpPosition (ArTime timeStamp, ArPose *position)
 Gets the encoder position the robot was at at the given timestamp.
ArTransform getEncoderTransform (void) const
 Gets the encoder transform.
bool getEstop (void)
 Returns true if the E-Stop button is pressed.
int getFlags (void) const
 Gets the flags values.
double getHeadingDoneDiff (void) const
 Gets the difference required for being done with a heading change.
int getIOAnalog (int num) const
 Gets the n'th byte from the analog input data from the IO packet.
int getIOAnalogSize (void) const
 Gets the number of bytes in the analog IO buffer.
double getIOAnalogVoltage (int num) const
 Gets the n'th byte from the analog input data from the IO packet.
unsigned char getIODigIn (int num) const
 Gets the n'th byte from the digital input data from the IO packet.
int getIODigInSize (void) const
 Gets the number of bytes in the digital input IO buffer.
unsigned char getIODigOut (int num) const
 Gets the n'th byte from the digital output data from the IO packet.
int getIODigOutSize (void) const
 Gets the number of bytes in the digital output IO buffer.
ArTime getIOPacketTime (void) const
 Returns the time received of the last IO packet.
ArKeyHandlergetKeyHandler (void) const
 Gets the key handler attached to this robot.
ArTime getLastPacketTime (void) const
 Gets the time the last packet was received.
long int getLeftEncoder (void)
 Gets packet data from the left encoder.
double getLeftVel (void) const
 Gets the velocity of the left wheel.
bool getLogMovementReceived (void)
 Gets if we're logging all the positions received from the robot.
bool getLogMovementSent (void)
 Gets if we're logging all the movement commands sent down.
bool getLogVelocitiesReceived (void)
 Gets if we're logging all the velocities (and heading) received.
int getMotorPacCount (void) const
 Gets the number of motor packets received in the last second.
double getMoveDoneDist (void)
 Gets the difference required for being done with a move.
const char * getName (void) const
 Gets the robots name in ARIAs list.
bool getNoTimeWarningThisCycle (void)
 Internal function for sync loop and sync task to see if we should warn this cycle or not.
unsigned int getNumFrontBumpers (void) const
 Gets the number of the front bumpers.
unsigned int getNumRearBumpers (void) const
 Gets the number of the rear bumpers.
int getNumSonar (void) const
 Find the number of sonar there are.
const ArRobotConfigPacketReadergetOrigRobotConfig (void) const
 Gets the original robot config packet information.
bool getPacketsReceivedTracking (void)
 Gets if we're logging all the packets received (just times and types).
bool getPacketsSentTracking (void)
 Gets if we're logging all the packets sent and their payload.
ArPose getPose (void) const
 Gets the global position of the robot.
size_t getPoseInterpNumReadings (void) const
 Sets the number of packets back in time the position interpol goes.
int getPoseInterpPosition (ArTime timeStamp, ArPose *position)
 Gets the position the robot was at at the given timestamp.
ArPTZgetPTZ (void)
 Sets the camera this robot is using.
std::list< ArRangeDevice * > * getRangeDeviceList (void)
 Gets the range device list.
ArPose getRawEncoderPose (void) const
 Internal function to get the raw encoder reading, don't use it.
double getRealBatteryVoltage (void) const
 Gets the real battery voltage of the robot.
size_t getRealBatteryVoltageAverageOfNum (void)
 Gets the number of readings the battery voltage is the average of.
double getRealBatteryVoltageNow (void) const
 Gets the instaneous battery voltage.
ArResolvergetResolver (void)
 Gets the resolver the robot is using.
long int getRightEncoder (void)
 Gets packet data from the right encoder.
double getRightVel (void) const
 Gets the velocity of the right wheel.
double getRobotDiagonal (void) const
 Gets the robot diagonal (half-height to diagonal of octagon) (in mm).
double getRobotLength (void) const
 Gets the robot radius (in mm).
const char * getRobotName (void) const
 Returns the Robot's name that is set in its onboard configuration.
const ArRobotParamsgetRobotParams (void) const
 Gets the parameters the robot is using.
double getRobotRadius (void) const
 Gets the robot radius (in mm).
const char * getRobotSubType (void) const
 Returns the subtype of the robot connected to.
const char * getRobotType (void) const
 Returns the type of the robot connected to.
double getRobotWidth (void) const
 Gets the robot width (in mm).
double getRotAccel (void) const
 Gets the rotational acceleration.
double getRotDecel (void) const
 Gets the rotational acceleration.
double getRotVel (void) const
 Gets the rotational velocity of the robot.
double getRotVelMax (void) const
 Gets the maximum rotational velocity.
std::list< ArFunctor * > * getRunExitListCopy ()
 Internal function, shouldn't be used, does what its name says.
int getSonarPacCount (void) const
 Gets the number of sonar returns received in the last second.
int getSonarRange (int num) const
 Gets the range of the last sonar reading for the given sonar.
ArSensorReadinggetSonarReading (int num) const
 Returns the sonar reading for the given sonar.
int getStabilizingTime (void) const
 How long we stabilize for in ms (0 means no stabilizng).
int getStallValue (void) const
 Gets the 2 bytes of stall return from the robot.
int getStateReflectionRefreshTime (void) const
ArSyncTaskgetSyncTaskRoot (void)
double getTh (void) const
 Gets the global Th location of the robot.
ArTransform getToGlobalTransform (void) const
 This gets the transform from local coords to global coords.
ArTransform getToLocalTransform (void) const
 This gets the transform for going from global coords to local coords.
double getTransAccel (void) const
 Gets the translational acceleration.
double getTransDecel (void) const
 Gets the translational acceleration.
double getTransVelMax (void) const
 Gets the maximum translational velocity.
double getVel (void) const
 Gets the translational velocity of the robot.
double getX (void) const
 Gets the global X location of the robot.
double getY (void) const
 Gets the global Y location of the robot.
bool handlePacket (ArRobotPacket *packet)
bool hasFrontBumpers (void) const
 Gets whether the robot has front bumpers (see params in docs).
bool hasRangeDevice (ArRangeDevice *device) const
 Finds whether a particular range device is attached to this robot or not.
bool hasRearBumpers (void) const
 Gets whether the robot has rear bumpers (see params in docs).
bool hasSettableAccsDecs (void) const
 If the robot has settable accels and decels.
bool hasSettableVelMaxes (void) const
 If the robot has settable maximum velocities.
bool hasTableSensingIR (void) const
 Gets whether the robot has table sensing IR or not (see params in docs).
void incCounter (void)
 This is only for use by syncLoop.
void init (void)
 Internal function, shouldn't be used.
bool isConnected (void) const
 Questions whether the robot is connected or not.
bool isCycleChained (void) const
 Gets whether we chain the robot cycle to when we get in SIP packets.
bool isDirectMotion (void) const
 Returns true if direct motion commands are blocking actions.
bool isEStopPressed (void) const
 returns true if the estop is pressed (or unrelieved)
bool isHeadingDone (double delta=0.0) const
 Sees if the robot is done changing to the previously given setHeading.
bool isLeftBreakBeamTriggered (void) const
 Returns true if the left break beam IR is triggered.
bool isLeftMotorStalled (void) const
 Returns true if the left motor is stalled.
bool isLeftTableSensingIRTriggered (void) const
 Returns true if the left table sensing IR is triggered.
bool isMoveDone (double delta=0.0)
 Sees if the robot is done moving the previously given move.
bool isRightBreakBeamTriggered (void) const
 Returns true if the right break beam IR is triggered.
bool isRightMotorStalled (void) const
 Returns true if the left motor is stalled.
bool isRightTableSensingIRTriggered (void) const
 Returns true if the right table sensing IR is triggered.
bool isRunning (void) const
 Returns whether the robot is currently running or not.
bool isSonarNew (int num) const
 Find out if the given sonar has a new reading.
bool isStabilizing (void)
 This tells us if we're in the preconnection state.
void keyHandlerExit (void)
 For the key handler, escape calls this to exit, internal.
bool loadParamFile (const char *file)
 Loads a parameter file (replacing all other params).
int lock ()
 Lock the robot instance.
void logActions (void) const
 Logs out the actions and their priorities.
void logAllTasks (void) const
 Logs the list of all tasks, strictly for your viewing pleasure.
void logUserTasks (void) const
 Logs the list of user tasks, strictly for your viewing pleasure.
void loopOnce (void)
 This function loops once... only serious developers should use it.
bool madeConnection (void)
 Internal function, shouldn't be used, does the initial conn stuff.
void move (double distance)
 Move the given distance forward/backwards.
void moveTo (ArPose to, ArPose from, bool doCumulative=true)
 Moves the robot's RW position to reflect pose From => pose To.
void moveTo (ArPose pose, bool doCumulative=true)
 Moves the robot's idea of its position to this position.
void packetHandler (void)
 Packet Handler, internal.
bool processEncoderPacket (ArRobotPacket *packet)
 Processes a new encoder packet, internal.
bool processIOPacket (ArRobotPacket *packet)
 Processes a new IO packet, internal.
bool processMotorPacket (ArRobotPacket *packet)
 Processes a motor packet, internal.
void processNewSonar (char number, int range, ArTime timeReceived)
 Processes a new sonar reading, internal.
void processParamFile (void)
 Internal function, processes a parameter file.
bool remAction (const char *actionName)
bool remAction (ArAction *action)
void remConnectCB (ArFunctor *functor)
 Removes a connect callback.
void remDisconnectNormallyCB (ArFunctor *functor)
 Removes a callback for when disconnect is called while connected.
void remDisconnectOnErrorCB (ArFunctor *functor)
 Removes a callback for when disconnection happens because of an error.
void remFailedConnectCB (ArFunctor *functor)
 Removes a callback for when a connection to the robot is failed.
void remPacketHandler (ArRetFunctor1< bool, ArRobotPacket * > *functor)
 Removes a packet handler from the list of packet handlers.
void remRangeDevice (ArRangeDevice *device)
 Remove a range device from the robot's list, by instance.
void remRangeDevice (const char *name)
 Remove a range device from the robot's list, by name.
void remRunExitCB (ArFunctor *functor)
 Removes a callback for when the run loop exits for what ever reason.
void remSensorInterpTask (ArFunctor *functor)
 Removes a sensor interp tasks by functor.
void remSensorInterpTask (const char *name)
 Removes a sensor interp tasks by name.
void remStabilizingCB (ArFunctor *functor)
 Removes stabilizing callback.
void remUserTask (ArFunctor *functor)
 Removes a user task from the list of synchronous taskes by functor.
void remUserTask (const char *name)
 Removes a user task from the list of synchronous taskes by name.
void requestEncoderPackets (void)
 Starts a continuous stream of encoder packets.
void requestIOPackets (void)
 Starts a continuous stream of IO packets.
void robotLocker (void)
 Robot locker, internal.
void robotUnlocker (void)
 Robot unlocker, internal.
void run (bool stopRunIfNotConnected)
 Starts the instance to do processing in this thread.
void runAsync (bool stopRunIfNotConnected)
 Starts the instance to do processing in its own new thread.
bool setAbsoluteMaxRotVel (double maxVel)
 Sets the robots absolute maximum rotational velocity.
bool setAbsoluteMaxTransVel (double maxVel)
 Sets the robots absolute maximum translational velocity.
void setBatteryVoltageAverageOfNum (size_t numToAverage)
 Sets the number of readings the battery voltage is the average of (default 20).
void setConnectionCycleMultiplier (unsigned int multiplier)
 Sets the multiplier for how many cycles ArRobot waits when connecting.
void setConnectionTimeoutTime (int mSecs)
 Sets the time without a response until connection assumed lost.
void setCycleChained (bool cycleChained)
 Sets whether to chain the robot cycle to when we get in SIP packets.
void setCycleTime (unsigned int ms)
 Sets the number of ms between cycles.
void setCycleWarningTime (unsigned int ms)
 Sets the number of ms between cycles to warn over.
void setDeadReconPose (ArPose pose)
 Sets the dead recon position of the robot.
void setDeltaHeading (double deltaHeading)
 Sets the delta heading.
void setDeviceConnection (ArDeviceConnection *connection)
 Sets the connection this instance uses.
void setDirectMotionPrecedenceTime (int mSec)
void setEncoderCorrectionCallback (ArRetFunctor1< double, ArPoseWithTime > *functor)
 Sets the encoderCorrectionCallback.
void setEncoderPoseInterpNumReadings (size_t numReadings)
 Sets the number of packets back in time the ArInterpolation goes for encoder readings.
void setEncoderTransform (ArPose transformPos)
 Changes the transform directly.
void setEncoderTransform (ArPose deadReconPos, ArPose globalPos)
 Changes the transform.
void setHeading (double heading)
 Sets the heading.
void setHeadingDoneDiff (double degrees)
 sets the difference required for being done with a heading change
void setLogMovementReceived (bool logMovementReceived)
 Sets if we're logging all the positions received from the robot.
void setLogMovementSent (bool logMovementSent)
 Sets if we're logging all the movement commands sent down.
void setLogVelocitiesReceived (bool logVelocitiesReceived)
 Sets if we're logging all the velocities (and heading) received.
void setMoveDoneDist (double dist)
 Sets the difference required for being done with a move.
void setName (const char *name)
 Sets the robots name in ARIAs list.
void setNoTimeWarningThisCycle (bool noTimeWarningThisCycle)
 Internal function for sync loop and sync task to say if we should warn this cycle or not.
void setPacketsReceivedTracking (bool packetsReceivedTracking)
 Sets if we're logging all the packets received (just times and types).
void setPacketsSentTracking (bool packetsSentTracking)
 Sets if we're logging all the packets received (just times and types).
void setPoseInterpNumReadings (size_t numReadings)
 Sets the number of packets back in time the ArInterpolation goes.
void setPTZ (ArPTZ *ptz)
 Sets the camera this robot is using.
void setRealBatteryVoltageAverageOfNum (size_t numToAverage)
 Sets the number of readings the real battery voltage is the average of (default 20).
void setResolver (ArResolver *resolver)
 Sets the resolver the robot is using.
void setRotAccel (double acc)
 Sets the rotational acceleration.
void setRotDecel (double decel)
 Sets the rotational acceleration.
void setRotVel (double velocity)
 Sets the rotational velocity.
void setRotVelMax (double vel)
 Sets the maximum rotational velocity.
void setStabilizingTime (int mSecs)
 How long we should stabilize for in ms (0 disables stabilizing).
void setStateReflectionRefreshTime (int msec)
void setTransAccel (double acc)
 Sets the translational acceleration.
void setTransDecel (double decel)
 Sets the translational acceleration.
void setTransVelMax (double vel)
 Sets the maximum translational velocity.
void setUpPacketHandlers (void)
 Internal function, shouldn't be used, sets up the default packet handlers.
void setUpSyncList (void)
 Internal function, shouldn't be used, sets up the default sync list.
void setVel (double velocity)
void setVel2 (double leftVelocity, double rightVelocity)
 Sets the velocity of the wheels independently.
void startStabilization (void)
 Internal function, shouldn't be used, calls the preconnected stuff.
void stateReflector (void)
 State Reflector, internal.
void stop (void)
void stopEncoderPackets (void)
 Stops a continuous stream of encoder packets.
void stopIOPackets (void)
 Stops a continuous stream of IO packets.
void stopRunning (bool doDisconnect=true)
 Stops the robot from doing any more processing.
void stopStateReflection (void)
int tryLock ()
 Try to lock the robot instance without blocking.
int unlock ()
 Unlock the robot instance.
WaitState waitForConnect (unsigned int msecs=0)
 Suspend calling thread until the ArRobot is connected.
WaitState waitForConnectOrConnFail (unsigned int msecs=0)
 Suspend calling thread until the ArRobot is connected or fails to connect.
WaitState waitForRunExit (unsigned int msecs=0)
 Suspend calling thread until the ArRobot run loop has exited.
void wakeAllConnOrFailWaitingThreads ()
 Wake up all threads waiting for connection or connection failure.
void wakeAllConnWaitingThreads ()
 Wake up all threads waiting for connection.
void wakeAllRunExitWaitingThreads ()
 Wake up all threads waiting for the run loop to exit.
void wakeAllWaitingThreads ()
 Wake up all threads waiting on this robot.
 ~ArRobot ()
 Destructor.

Public Attributes

ArFunctorC< ArRobotmyActionHandlerCB
ArRetFunctor1C< bool, ArRobot,
ArRobotPacket * > 
myEncoderPacketCB
ArRetFunctorC< unsigned int,
ArRobot
myGetCycleWarningTimeCB
ArRetFunctorC< bool, ArRobotmyGetNoTimeWarningThisCycleCB
ArRetFunctor1C< bool, ArRobot,
ArRobotPacket * > 
myIOPacketCB
ArFunctorC< ArKeyHandler > * myKeyHandlerCB
ArFunctorC< ArRobotmyKeyHandlerExitCB
ArRetFunctor1C< bool, ArRobot,
ArRobotPacket * > 
myMotorPacketCB
ArFunctorC< ArRobotmyPacketHandlerCB
ArFunctorC< ArRobotmyRobotLockerCB
ArFunctorC< ArRobotmyRobotUnlockerCB
ArFunctorC< ArRobotmyStateReflectorCB

Protected Types

enum  RotDesired { ROT_NONE, ROT_IGNORE, ROT_HEADING, ROT_VEL }
enum  TransDesired {
  TRANS_NONE, TRANS_IGNORE, TRANS_VEL, TRANS_VEL2,
  TRANS_DIST, TRANS_DIST_NEW
}

Protected Member Functions

void reset (void)

Protected Attributes

double myAbsoluteMaxRotVel
double myAbsoluteMaxTransVel
ArActionDesired myActionDesired
bool myActionRotSet
ArResolver::ActionMap myActions
bool myActionTransSet
bool myAddedAriaExitCB
unsigned char myAnalog
int myAnalogPortSelected
ArFunctorC< ArRobotmyAriaExitCB
bool myAsyncConnectFlag
int myAsyncConnectNoPacketCount
bool myAsyncConnectSentChangeBaud
int myAsyncConnectStartBaud
ArTime myAsyncConnectStartedChangeBaud
int myAsyncConnectState
int myAsyncConnectTimesTried
ArTime myAsyncStartedConnection
ArRunningAverage myBatteryAverager
double myBatteryVoltage
bool myBlockingConnectRun
ChargeState myChargeState
double myCompass
ArDeviceConnectionmyConn
std::list< ArFunctor * > myConnectCBList
ArCondition myConnectCond
unsigned int myConnectionCycleMultiplier
ArCondition myConnOrFailCond
double myControl
unsigned int myCounter
bool myCycleChained
unsigned int myCycleTime
unsigned int myCycleWarningTime
unsigned char myDigIn
unsigned char myDigOut
int myDirectPrecedenceTime
std::list< ArFunctor * > myDisconnectNormallyCBList
std::list< ArFunctor * > myDisconnectOnErrorCBList
ArRetFunctor1< double, ArPoseWithTime > * myEncoderCorrectionCB
ArTransform myEncoderGlobalTrans
ArInterpolation myEncoderInterpolation
ArPoseWithTime myEncoderPose
ArTime myEncoderPoseTaken
ArTransform myEncoderTransform
std::list< ArFunctor * > myFailedConnectCBList
bool myFirstEncoderPose
int myFlags
ArPose myGlobalPose
double myHeadingDoneDiff
ArInterpolation myInterpolation
int myIOAnalog [128]
int myIOAnalogSize
unsigned char myIODigIn [255]
int myIODigInSize
unsigned char myIODigOut [255]
int myIODigOutSize
bool myIsConnected
bool myIsStabilizing
ArKeyHandlermyKeyHandler
bool myKeyHandlerUseExitNotShutdown
bool myLastActionRotHeading
bool myLastActionRotStopped
int myLastActionRotVal
int myLastActionTransVal
ArTime myLastIOPacketReceivedTime
ArTime myLastPacketReceivedTime
ArTime myLastPulseSent
ArTime myLastRotSent
RotDesired myLastRotType
int myLastRotVal
double myLastSentRotAccel
double myLastSentRotDecel
double myLastSentRotVelMax
double myLastSentTransAccel
double myLastSentTransDecel
double myLastSentTransVelMax
int myLastTh
ArTime myLastTransSent
TransDesired myLastTransType
int myLastTransVal
int myLastTransVal2
int myLastX
int myLastY
long int myLeftEncoder
double myLeftVel
bool myLogMovementReceived
bool myLogMovementSent
bool myLogVelocitiesReceived
int myMotorPacCount
int myMotorPacCurrentCount
double myMoveDoneDist
ArMutex myMutex
std::string myName
bool myNoTimeWarningThisCycle
int myNumSonar
ArRobotConfigPacketReadermyOrigRobotConfig
bool myOwnTheResolver
std::list< ArRetFunctor1<
bool, ArRobotPacket * > * > 
myPacketHandlerList
bool myPacketsReceivedTracking
long myPacketsReceivedTrackingCount
ArTime myPacketsReceivedTrackingStarted
bool myPacketsSentTracking
ArRobotParamsmyParams
ArPTZmyPtz
std::list< ArRangeDevice * > myRangeDeviceList
ArPoseWithTime myRawEncoderPose
ArRunningAverage myRealBatteryAverager
double myRealBatteryVoltage
ArRobotPacketReceiver myReceiver
bool myRequestedEncoderPackets
bool myRequestedIOPackets
ArResolvermyResolver
long int myRightEncoder
double myRightVel
std::string myRobotName
std::string myRobotSubType
std::string myRobotType
double myRotAccel
double myRotDecel
ArTime myRotSetTime
RotDesired myRotType
double myRotVal
double myRotVel
double myRotVelMax
std::list< ArFunctor * > myRunExitCBList
ArCondition myRunExitCond
ArRobotPacketSender mySender
bool mySentPulse
int mySonarPacCount
int mySonarPacCurrentCount
std::map< int, ArSensorReading * > mySonars
std::list< ArFunctor * > myStabilizingCBList
int myStabilizingTime
int myStallValue
ArTime myStartedStabilizing
int myStateReflectionRefreshTime
ArSyncLoop mySyncLoop
ArSyncTaskmySyncTaskRoot
time_t myTimeLastMotorPacket
time_t myTimeLastSonarPacket
int myTimeoutTime
double myTransAccel
double myTransDecel
ArPose myTransDistStart
ArTime myTransSetTime
TransDesired myTransType
double myTransVal
double myTransVal2
double myTransVelMax
double myVel
bool myWarnedAboutExtraSonar


Detailed Description

THE important class.

This is the most important class, the only classes most people will ever have to use are this one, and the ArSimpleConnector. NOTE: In Windows you cannot make an ArRobot a global, it will crash because the windows compiler initializes the constructors in the wrong order... you can make a pointer to an ArRobot and then new one however.

See also:
ArSerialConnection

ArTcpConnection

Definition at line 66 of file ArRobot.h.


Member Enumeration Documentation

enum ArRobot::WaitState
 

Enumeration values:
WAIT_CONNECTED  The robot has connected.
WAIT_FAILED_CONN  The robot failed to connect.
WAIT_RUN_EXIT  The run loop has exited.
WAIT_TIMEDOUT  The wait reached the timeout specified.
WAIT_INTR  The wait was interupted by a signal.
WAIT_FAIL  The wait failed due to an error.

Definition at line 70 of file ArRobot.h.


Constructor & Destructor Documentation

ArRobot::ArRobot const char *  name = NULL,
bool  obsolete = true,
bool  doSigHandle = true,
bool  normalInit = true,
bool  addAriaExitCallback = true
 

Constructor.

Parameters:
name A name for this robot
obsolete Don't use this parameter, it is ignored. (This used to be state reflection but with many additions that make it so that things can't work right without state reflection the ability to not do state refleciton has been removed)
normalInit whether the robot should initializes its structures or the calling program will take care of it. No one will probalby ever use this value, since if they are doing that then overriding will probably be more useful, but there it is.
doSigHandle do normal signal handling and have this robot instance stopRunning() when the program is signaled

Definition at line 69 of file ArRobot.cpp.

References Aria::addExitCallback(), Aria::addRobot(), init(), ArFunctor::setName(), setName(), ArPose::setPose(), and ArTime::setToNow().


Member Function Documentation

void ArRobot::actionHandler void   ) 
 

Action Handler, internal.

Runs the resolver on the actions, it just saves these values for use by the stateReflector, otherwise it sends these values straight down to the robot.

See also:
addAction

remAction

Definition at line 3225 of file ArRobot.cpp.

References isConnected(), ArActionDesired::merge(), ArActionDesired::reset(), and ArResolver::resolve().

bool ArRobot::addAction ArAction action,
int  priority
 

Adds an action to the list with the given priority

See also:
remAction(ArAction*)

remAction(const char*)

findAction(const char*)

Definition at line 2317 of file ArRobot.cpp.

References ArLog::log().

Referenced by ArActionGroup::addAction().

void ArRobot::addConnectCB ArFunctor functor,
ArListPos::Pos  position = ArListPos::LAST
 

Adds a connect callback.

Adds a connect callback, which is an ArFunctor, (created as an ArFunctorC). The entire list of connect callbacks is called when a connection is made with the robot. If you have some sort of module that adds a callback, that module must remove the callback when the module is removed.

Parameters:
functor A functor (created from ArFunctorC) which refers to the function to call.
position whether to place the functor first or last
See also:
remConnectCB

Definition at line 1698 of file ArRobot.cpp.

References ArLog::log().

Referenced by ArGripper::ArGripper(), ArPTZ::ArPTZ(), ArRobotConfigPacketReader::ArRobotConfigPacketReader(), ArRobotJoyHandler::ArRobotJoyHandler(), ArSick::setRobot(), ArActionRobotJoydrive::setRobot(), and ArSick::~ArSick().

void ArRobot::addDisconnectNormallyCB ArFunctor functor,
ArListPos::Pos  position = ArListPos::LAST
 

Adds a callback for when disconnect is called while connected.

Adds a disconnect normally callback,which is an ArFunctor, created as an ArFunctorC. This whole list of disconnect normally callbacks is called when something calls disconnect if the instance isConnected. If there is no connection and disconnect is called nothing is done. If you have some sort of module that adds a callback, that module must remove the callback when the module is removed.

Parameters:
functor functor created from ArFunctorC which refers to the function to call.
position whether to place the functor first or last
See also:
remFailedConnectCB

Definition at line 1765 of file ArRobot.cpp.

References ArLog::log().

void ArRobot::addDisconnectOnErrorCB ArFunctor functor,
ArListPos::Pos  position = ArListPos::LAST
 

Adds a callback for when disconnection happens because of an error.

Adds a disconnect on error callback, which is an ArFunctor, created as an ArFunctorC. This whole list of disconnect on error callbacks is called when ARIA loses connection to a robot because of an error. This can occur if the physical connection (ie serial cable) between the robot and the computer is severed/disconnected, if one of a pair of radio modems that connect the robot and computer are disconnected, if someone presses the reset button on the robot, or if the simulator is closed while ARIA is connected to it. Note that if the link between the two is lost the ARIA assumes it is temporary until it reaches a timeout value set with setConnectionTimeoutTime. If you have some sort of module that adds a callback, that module must remove the callback when the module removed.

Parameters:
functor functor created from ArFunctorC which refers to the function to call.
position whether to place the functor first or last
See also:
remDisconnectOnErrorCB

Definition at line 1802 of file ArRobot.cpp.

References ArLog::log().

void ArRobot::addFailedConnectCB ArFunctor functor,
ArListPos::Pos  position = ArListPos::LAST
 

Adds a callback for when a connection to the robot is failed.

Adds a failed connect callback,which is an ArFunctor, created as an ArFunctorC. This whole list of failed connect callbacks is called when an attempt is made to connect to the robot, but fails. The usual reason for this failure is either that there is no robot/sim where the connection was tried to be made, the robot wasn't given a connection, or the radio modems that communicate with the robot aren't on. If you have some sort of module that adds a callback, that module must remove the callback when the module removed.

Parameters:
functor functor created from ArFunctorC which refers to the function to call.
position whether to place the functor first or last
See also:
remFailedConnectCB

Definition at line 1733 of file ArRobot.cpp.

References ArLog::log().

void ArRobot::addPacketHandler ArRetFunctor1< bool, ArRobotPacket * > *  functor,
ArListPos::Pos  position = ArListPos::LAST
 

Adds a packet handler to the list of packet handlers.

Adds a packet handler. A packet handler is an ArRetFunctor1, created as an instance of ArRetFunctor1C. The return is a boolean, while the functor takes an ArRobotPacket pointer as the argument. This functor is placed in the list of functors to call when a packet arrives. This list is gone through by order until one of the handlers returns true.

Parameters:
functor the functor to call when the packet comes in
position whether to place the functor first or last
See also:
remPacketHandler

Definition at line 1665 of file ArRobot.cpp.

References ArLog::log().

Referenced by ArAnalogGyro::ArAnalogGyro(), ArGripper::ArGripper(), ArPTZ::ArPTZ(), ArRobotConfigPacketReader::ArRobotConfigPacketReader(), ArRobotJoyHandler::ArRobotJoyHandler(), ArSickLogger::ArSickLogger(), ArTCM2::ArTCM2(), ArP2Arm::init(), ArSick::setRobot(), ArIrrfDevice::setRobot(), ArActionRobotJoydrive::setRobot(), and setUpPacketHandlers().

void ArRobot::addRunExitCB ArFunctor functor,
ArListPos::Pos  position = ArListPos::LAST
 

Adds a callback for when the run loop exits for what ever reason.

Adds a callback that is called when the run loop exits. The functor is which is an ArFunctor, created as an ArFunctorC. The whole list of functors is called when the run loop exits. This is most usefull for threaded programs that run the robot using ArRobot::runAsync. This will allow user threads to know when the robot loop has exited.

Parameters:
functor functor created from ArFunctorC which refers to the function to call.
position whether to place the functor first or last
See also:
remRunExitCB

Definition at line 1834 of file ArRobot.cpp.

References ArLog::log().

bool ArRobot::addSensorInterpTask const char *  name,
int  position,
ArFunctor functor,
ArTaskState::State state = NULL
 

Adds a task under the sensor interp part of the syncronous tasks.

The synchronous tasks get called every robot cycle (every 100 ms by default).

Parameters:
name the name to give to the task, should be unique
position the place in the list of user tasks to place this task, this can be any integer, though by convention 0 to 100 is used. The tasks are called in order of highest number to lowest number.
functor functor created from ArFunctorC which refers to the function to call.
See also:
remSensorInterpTask

Definition at line 2148 of file ArRobot.cpp.

References ArSyncTask::addNewLeaf(), and ArSyncTask::findNonRecursive().

Referenced by attachKeyHandler(), ArPTZ::setDeviceConnection(), ArSonarDevice::setRobot(), ArSick::setRobot(), ArRangeDevice::setRobot(), ArIRs::setRobot(), ArForbiddenRangeDevice::setRobot(), ArBumpers::setRobot(), and ArACTS_1_2::setRobot().

void ArRobot::addStabilizingCB ArFunctor functor,
ArListPos::Pos  position = ArListPos::LAST
 

Adds a callback called when the robot starts stabilizing before declaring connection.

Adds a stablizing callback, which is an ArFunctor, created as an ArFunctorC. The entire list of connect callbacks is called just before the connection is called done to the robot. This time can be used to calibtrate readings (on things like gyros).

Parameters:
functor The functor to call (e.g. ArFunctorC)
position whether to place the functor first or last
See also:
remConnectCB

Definition at line 1866 of file ArRobot.cpp.

References ArLog::log().

Referenced by ArAnalogGyro::ArAnalogGyro().

bool ArRobot::addUserTask const char *  name,
int  position,
ArFunctor functor,
ArTaskState::State state = NULL
 

Adds a user task to the list of synchronous taskes.

The synchronous tasks get called every robot cycle (every 100 ms by default).

Parameters:
name the name to give to the task, should be unique
position the place in the list of user tasks to place this task, this can be any integer, though by convention 0 to 100 is used. The tasks are called in order of highest number to lowest position number.
functor functor created from ArFunctorC which refers to the function to call.
See also:
remUserTask

Definition at line 2070 of file ArRobot.cpp.

References ArSyncTask::addNewLeaf(), and ArSyncTask::findNonRecursive().

Referenced by ArDataLogger::ArDataLogger(), ArSickLogger::ArSickLogger(), ArVCC4::ArVCC4(), and ArMode::baseActivate().

void ArRobot::applyTransform ArTransform  trans,
bool  doCumulative = true
 

This applies a transform to all the robot range devices and to the sonar.

Applies a transform to the range devices and sonar... this is mostly useful for translating to/from local/global coords, but may have other uses

Parameters:
trans the transform to apply
doCumulative whether to transform the cumulative buffers or not

Definition at line 4407 of file ArRobot.cpp.

References ArSensorReading::applyTransform(), getNumSonar(), and getSonarReading().

bool ArRobot::asyncConnect void   ) 
 

Connects to a robot, from the robots own thread.

Sets up the robot to connect, then returns, but the robot must be running (ie from runAsync) before you do this. Also this will fail if the robot is already connected. If you want to know what happened because of the connect then look at the callbacks. NOTE, this will not lock robot before setting values, so you MUST lock the robot before you call this function and unlock the robot after you call this function. If you fail to lock the robot, you'll may wind up with wierd behavior. Other than the aspect of blocking or not the only difference between async and blocking connects (other than the blocking) is that async is run every robot cycle, whereas blocking runs as fast as it can... also blocking will try to reconnect a radio modem if it looks like it didn't get connected in the first place, so blocking can wind up taking 10 or 12 seconds to decide it can't connect, whereas async doesn't try hard at all to reconnect the radio modem (beyond its first try) (under the assumption the async connect is user driven, so they'll just try again, and so that it won't mess up the sync loop by blocking for so long).

Returns:
true if the robot is running and the robot will try to connect, false if the robot isn't running so won't try to connect or if the robot is already connected
See also:
addConnectCB

addFailedConnectCB

runAsync

Definition at line 539 of file ArRobot.cpp.

References isConnected().

int ArRobot::asyncConnectHandler bool  tryHarderToConnect  ) 
 

Internal function, shouldn't be used, does a single run of connecting.

This is an internal function that is used both for async connects and blocking connects use to connect. It does about the same thing for both, and it should only be used by asyncConnect and blockingConnect really. But here it is. The only difference between when its being used by blocking/async connect is that in blocking mode if it thinks there may be problems with the radio modem it pauses for two seconds trying to deal with this... whereas in async mode it tries to deal with this in a simpler way.

Parameters:
tryHarderToConnect if this is true, then if the radio modems look like they aren't working, it'll take about 2 seconds to try and connect them, whereas if its false, it'll do a little try, but won't try very hard
Returns:
0 if its still trying to connect, 1 if it connected, 2 if it failed

Definition at line 613 of file ArRobot.cpp.

References ArTime::addMSec(), ArBasePacket::bufToStr(), ArRobotPacketSender::com(), com(), ArRobotPacketSender::comInt(), comInt(), failedConnect(), finishedConnection(), ArRobotParams::getAbsoluteMaxRotVelocity(), ArRobotParams::getAbsoluteMaxVelocity(), ArSerialConnection::getBaud(), getCycleTime(), ArRobotPacket::getID(), ArRobotConfigPacketReader::getResetBaud(), ArRobotParams::getRotAccel(), ArRobotConfigPacketReader::getRotAccel(), ArRobotParams::getRotDecel(), ArRobotConfigPacketReader::getRotDecel(), ArRobotParams::getRotVelMax(), ArRobotConfigPacketReader::getRotVelMax(), ArRobotConfigPacketReader::getRotVelTop(), ArDeviceConnection::getStatus(), ArRobotParams::getSwitchToBaudRate(), ArRobotParams::getTransAccel(), ArRobotConfigPacketReader::getTransAccel(), ArRobotParams::getTransDecel(), ArRobotConfigPacketReader::getTransDecel(), ArRobotParams::getTransVelMax(), ArRobotConfigPacketReader::getTransVelMax(), ArRobotConfigPacketReader::getTransVelTop(), ArRobotConfigPacketReader::hasPacketArrived(), ArLogFileConnection::havePose, ArLog::log(), madeConnection(), moveTo(), ArTime::mSecSince(), ArTime::mSecTo(), ArLogFileConnection::myName, ArLogFileConnection::myPose, ArLogFileConnection::mySubtype, ArLogFileConnection::myType, ArDeviceConnection::openSimple(), ArRobotPacketReceiver::receivePacket(), ArRobotConfigPacketReader::requestPacket(), ArBasePacket::resetRead(), setAbsoluteMaxRotVel(), setAbsoluteMaxTransVel(), ArSerialConnection::setBaud(), setCycleChained(), setRotAccel(), setRotDecel(), setRotVelMax(), ArTime::setToNow(), setTransAccel(), setTransDecel(), setTransVelMax(), ArUtil::sleep(), startStabilization(), and ArLogFileConnection::write().

Referenced by blockingConnect(), and packetHandler().

void ArRobot::attachKeyHandler ArKeyHandler keyHandler,
bool  exitOnEscape = true,
bool  useExitNotShutdown = true
 

Attachs a key handler.

This will attach a key handler to a robot, by putting it into the robots sensor interp task list (a keyboards a sensor of users will, right?). By default exitOnEscape is true, which will cause this function to add an escape key handler to the key handler, this will make the program exit when escape is pressed... if you don't like this you can pass exitOnEscape in as false.

Parameters:
keyHandler the key handler to attach
exitOnEscape whether to exit when escape is pressed or not
useExitNotShutdown if true then Aria::exit will be called instead of Aria::shutdown if it tries to exit

Definition at line 4635 of file ArRobot.cpp.

References addSensorInterpTask().

Referenced by ArMode::ArMode(), ArSickLogger::ArSickLogger(), and ArActionKeydrive::setRobot().

bool ArRobot::blockingConnect void   ) 
 

Connects to a robot, not returning until connection made or failed.

Connects to the robot, returning only when a connection has been made or it has been established a connection can't be made. This connection usually is fast, but can take up to 30 seconds if the robot is in a wierd state (this is not often). If the robot is connected via ArSerialConnection then the connect will also connect the radio modems. Upon a successful connection all of the Connection Callback Functors that have been registered will be called. NOTE, this will lock the robot before setting values, so you MUST not have the robot locked from where you call this function. If you do, you'll wind up in a deadlock. This behavior is there because otherwise you'd have to lock the robot before calling this function, and normally blockingConnect will be called from a seperate thread, and that thread won't be doing anything else with the robot at that time. Other than the aspect of blocking or not the only difference between async and blocking connects (other than the blocking) is that async is run every robot cycle, whereas blocking runs as fast as it can... also blocking will try to reconnect a radio modem if it looks like it didn't get connected in the first place, so blocking can wind up taking 10 or 12 seconds to decide it can't connect, whereas async doesn't try hard at all to reconnect the radio modem (under the assumption the async connect is user driven, so they'll just try again, and so that it won't mess up the sync loop by blocking for so long).

Returns:
true if a connection could be made, false otherwise

Definition at line 580 of file ArRobot.cpp.

References asyncConnectHandler(), disconnect(), getCycleTime(), lock(), ArUtil::sleep(), and unlock().

double ArRobot::checkRangeDevicesCumulativeBox double  x1,
double  y1,
double  x2,
double  y2,
ArPose readingPos = NULL
const
 

This goes through all of the registered range devices and locks each, calls cumulativeReadingBox on it, and then unlocks it.

Gets the closest reading in a region defined by the two points of a rectangle.

Parameters:
x1 the x coordinate of one of the rectangle points
y1 the y coordinate of one of the rectangle points
x2 the x coordinate of the other rectangle point
y2 the y coordinate of the other rectangle point
readingPos a pointer to a position in which to store the location of the closest position
Returns:
if the return is >= 0 then this is the distance to the closest reading, if it is < 0 then there were no readings in the given region

Definition at line 4213 of file ArRobot.cpp.

References ArRangeDevice::cumulativeReadingBox(), ArRangeDevice::lockDevice(), and ArRangeDevice::unlockDevice().

double ArRobot::checkRangeDevicesCumulativePolar double  startAngle,
double  endAngle,
double *  angle = NULL
const
 

Goes through all the range devices and checks them.

This goes through all of the registered range devices and locks each, calls cumulativeReadingPolar on it, and then unlocks it.

Gets the closest reading in a region defined by startAngle going to endAngle... going counterclockwise (neg degrees to poseitive... with how the robot is set up, thats counterclockwise)... from -180 to 180... this means if you want the slice between 0 and 10 degrees, you must enter it as 0, 10, if you do 10, 0 you'll get the 350 degrees between 10 and 0... be especially careful with negative... for example -30 to -60 is everything from -30, around through 0, 90, and 180 back to -60... since -60 is actually to clockwise of -30

Parameters:
startAngle where to start the slice
endAngle where to end the slice, going clockwise from startAngle
angle a pointer return of the angle to the found reading
Returns:
if the return is >= 0 then this is the distance to the closest reading, if it is < 0 then there were no readings in the given region

Definition at line 4104 of file ArRobot.cpp.

References ArRangeDevice::cumulativeReadingPolar(), ArRangeDevice::lockDevice(), and ArRangeDevice::unlockDevice().

double ArRobot::checkRangeDevicesCurrentBox double  x1,
double  y1,
double  x2,
double  y2,
ArPose readingPos = NULL
const
 

This goes through all of the registered range devices and locks each, calls currentReadingBox on it, and then unlocks it.

Gets the closest reading in a region defined by the two points of a rectangle.

Parameters:
x1 the x coordinate of one of the rectangle points
y1 the y coordinate of one of the rectangle points
x2 the x coordinate of the other rectangle point
y2 the y coordinate of the other rectangle point
readingPos a pointer to a position in which to store the location of the closest position
Returns:
if the return is >= 0 then this is the distance to the closest reading, if it is < 0 then there were no readings in the given region

Definition at line 4159 of file ArRobot.cpp.

References ArRangeDevice::currentReadingBox(), ArRangeDevice::lockDevice(), and ArRangeDevice::unlockDevice().

Referenced by ArActionLimiterForwards::fire(), ArActionLimiterBackwards::fire(), and ArActionDeceleratingLimiter::fire().

double ArRobot::checkRangeDevicesCurrentPolar double  startAngle,
double  endAngle,
double *  angle = NULL
const
 

Goes through all the range devices and checks them.

This goes through all of the registered range devices and locks each, calls currentReadingPolar on it, and then unlocks it.

Gets the closest reading in a region defined by startAngle going to endAngle... going counterclockwise (neg degrees to poseitive... with how the robot is set up, thats counterclockwise)... from -180 to 180... this means if you want the slice between 0 and 10 degrees, you must enter it as 0, 10, if you do 10, 0 you'll get the 350 degrees between 10 and 0... be especially careful with negative... for example -30 to -60 is everything from -30, around through 0, 90, and 180 back to -60... since -60 is actually to clockwise of -30

Parameters:
startAngle where to start the slice
endAngle where to end the slice, going clockwise from startAngle
angle a pointer return of the angle to the found reading
Returns:
if the return is >= 0 then this is the distance to the closest reading, if it is < 0 then there were no readings in the given region

Definition at line 4046 of file ArRobot.cpp.

References ArRangeDevice::currentReadingPolar(), ArRangeDevice::lockDevice(), and ArRangeDevice::unlockDevice().

Referenced by ArActionTurn::fire(), ArActionAvoidSide::fire(), and ArActionAvoidFront::fire().

void ArRobot::clearDirectMotion void   ) 
 

Clears what direct motion commands have been given, so actions work.

This clears the direct motion commands so that actions will be allowed to control the robot again.

See also:
setDirectMotionPrecedenceTime

getDirectMotionPrecedenceTime

Definition at line 4535 of file ArRobot.cpp.

Referenced by ArMode::baseActivate().

bool ArRobot::com unsigned char  command  ) 
 

Sends a command to the robot with no arguments.

Parameters:
command the command number to send
Returns:
whether the command could be sent or not
See also:
ArCommands

Definition at line 3806 of file ArRobot.cpp.

References ArRobotPacketSender::com(), and ArLog::log().

Referenced by asyncConnectHandler(), and stateReflector().

bool ArRobot::com2Bytes unsigned char  command,
char  high,
char  low
 

Sends a command to the robot with two bytes for argument.

Parameters:
command the command number to send
high the high byte to send with the command
low the low byte to send with the command
Returns:
whether the command could be sent or not
See also:
ArCommands

Definition at line 3833 of file ArRobot.cpp.

References ArRobotPacketSender::com2Bytes(), and ArLog::log().

Referenced by stateReflector().

bool ArRobot::comInt unsigned char  command,
short int  argument
 

Sends a command to the robot with an int for argument.

Parameters:
command the command number to send
argument the integer argument to send with the command
Returns:
whether the command could be sent or not
See also:
ArCommands

Definition at line 3819 of file ArRobot.cpp.

References ArRobotPacketSender::comInt(), and ArLog::log().

Referenced by ArGripper::ArGripper(), asyncConnectHandler(), ArTCM2::commandAutoCalibration(), ArTCM2::commandContinuousPackets(), ArTCM2::commandJustCompass(), ArTCM2::commandOff(), ArTCM2::commandOnePacket(), ArTCM2::commandSoftReset(), ArTCM2::commandStopCalibration(), ArTCM2::commandUserCalibration(), ArRobotConfigPacketReader::connected(), ArGripper::connectHandler(), disableMotors(), ArSick::disconnect(), enableMotors(), ArActionIRs::fire(), ArActionDeceleratingLimiter::fire(), ArGripper::gripClose(), ArGripper::gripOpen(), ArGripper::gripperDeploy(), ArGripper::gripperHalt(), ArGripper::gripperStore(), ArGripper::gripPressure(), ArGripper::gripStop(), ArSick::internalConnectSim(), ArGripper::liftCarry(), ArGripper::liftDown(), ArGripper::liftStop(), ArGripper::liftUp(), madeConnection(), ArGripper::packetHandler(), requestEncoderPackets(), requestIOPackets(), ArRobotConfigPacketReader::requestPacket(), ArGripper::setType(), ArAnalogGyro::stabilizingCallback(), stateReflector(), stop(), stopEncoderPackets(), stopIOPackets(), and ArAnalogGyro::~ArAnalogGyro().

bool ArRobot::comStr unsigned char  command,
const char *  argument
 

Sends a command to the robot with a string for argument.

Parameters:
command the command number to send
argument the string to send with the command
Returns:
whether the command could be sent or not
See also:
ArCommands

Definition at line 3847 of file ArRobot.cpp.

References ArRobotPacketSender::comStr(), and ArLog::log().

Referenced by ArSickLogger::ArSickLogger(), and ArSickLogger::~ArSickLogger().

bool ArRobot::comStrN unsigned char  command,
const char *  str,
int  size
 

Sends a command to the robot with a size bytes of str as argument.

Parameters:
command the command number to send
str the character array to send with the command
size length of the array to send
Returns:
whether the command could be sent or not
See also:
ArCommands

Definition at line 3862 of file ArRobot.cpp.

References ArRobotPacketSender::comStrN(), and ArLog::log().

Referenced by ArPTZ::sendPacket().

void ArRobot::disableMotors  ) 
 

Disables the motors on the robot.

This command disables the motors on the robot, if it is connected.

Definition at line 4586 of file ArRobot.cpp.

References comInt().

bool ArRobot::disconnect void   ) 
 

Disconnects from a robot.

Disconnects from a robot. This also calls of the DisconnectNormally Callback Functors if the robot was actually connected to a robot when this member was called.

Returns:
true if not connected to a robot (so no disconnect can happen, but it didn't failed either), also true if the command could be sent to the robot (ie connection hasn't failed)

Definition at line 1301 of file ArRobot.cpp.

References ArDeviceConnection::close(), ArRobotPacketSender::comInt(), ArLog::log(), ArSerialConnection::setBaud(), and ArUtil::sleep().

Referenced by ariaExitCallback(), blockingConnect(), and stopRunning().

void ArRobot::enableMotors  ) 
 

Enables the motors on the robot.

This command enables the motors on the robot, if it is connected.

Definition at line 4578 of file ArRobot.cpp.

References comInt().

ArAction * ArRobot::findAction const char *  actionName  ) 
 

Returns the first (highest priority) action with the given name (or NULL)

See also:
addAction

remAction(ArAction*)

remAction(const char*)

Definition at line 2392 of file ArRobot.cpp.

References ArAction::getName().

ArRangeDevice * ArRobot::findRangeDevice const char *  name  ) 
 

Finds a rangeDevice in the robot's list.

Parameters:
name return the first device with this name
Returns:
if found, a range device with the given name, if not found NULL

Definition at line 3966 of file ArRobot.cpp.

References ArRangeDevice::getName().

const ArRangeDevice * ArRobot::findRangeDevice const char *  name  )  const
 

Finds a rangeDevice in the robot's list.

Parameters:
name return the first device with this name
Returns:
if found, a range device with the given name, if not found NULL

Definition at line 3986 of file ArRobot.cpp.

References ArRangeDevice::getName().

Referenced by ArActionTriangleDriveTo::setRobot().

ArSyncTask * ArRobot::findTask ArFunctor functor  ) 
 

Finds a task by functor.

Finds a task by its functor, searching the entire space of tasks

Returns:
NULL if no task with that functor found, otherwise a pointer to the ArSyncTask for the first task found with that functor

Definition at line 2295 of file ArRobot.cpp.

References ArSyncTask::find().

ArSyncTask * ArRobot::findTask const char *  name  ) 
 

Finds a task by name.

Finds a task by its name, searching the entire space of tasks

Returns:
NULL if no task of that name found, otherwise a pointer to the ArSyncTask for the first task found with that name

Definition at line 2281 of file ArRobot.cpp.

References ArSyncTask::find().

ArSyncTask * ArRobot::findUserTask ArFunctor functor  ) 
 

Finds a user task by functor.

Finds a user task by its functor, searching the entire space of tasks

Returns:
NULL if no user task with that functor found, otherwise a pointer to the ArSyncTask for the first task found with that functor

Definition at line 2263 of file ArRobot.cpp.

References ArSyncTask::find(), and ArSyncTask::findNonRecursive().

ArSyncTask * ArRobot::findUserTask const char *  name  ) 
 

Finds a user task by name.

Finds a user task by its name, searching the entire space of tasks

Returns:
NULL if no user task of that name found, otherwise a pointer to the ArSyncTask for the first task found with that name

Definition at line 2245 of file ArRobot.cpp.

References ArSyncTask::find(), and ArSyncTask::findNonRecursive().

ArResolver::ActionMap * ArRobot::getActionMap void   ) 
 

Returns the map of actions... don't do this unless you really know what you're doing

Definition at line 2415 of file ArRobot.cpp.

Referenced by deactivateActions().

double ArRobot::getBatteryVoltage void   )  const [inline]
 

Gets the battery voltage of the robot (normalized to 12 volt system).

This value is averaged over a number of readings, you can get this by calling getBatteryVoltageAverageOfNum and set this with setBatteryVoltageAverageOfNum... you can call getBatteryVoltageNow to get the reading from the last packet.

This is a value normalized to 12 volts, if you want what the actual voltage of the robot is use getRealBatteryVoltage.

Definition at line 251 of file ArRobot.h.

References ArRunningAverage::getAverage().

double ArRobot::getBatteryVoltageNow void   )  const [inline]
 

Gets the instaneous battery voltage.

This is a value normalized to 12 volts, if you want what the actual voltage of the robot is use getRealBatteryVoltage.

Definition at line 257 of file ArRobot.h.

ArRobot::ChargeState ArRobot::getChargeState void   )  const
 

Gets the charge state of the robot (see long docs).

Note that this is only available on robots with an firwmare operating system (ARCOS or uARCS) thats at least newer than July of 2005. It'll just be CHARGING_UNKNOWN on everything else always.

Definition at line 4686 of file ArRobot.cpp.

unsigned int ArRobot::getConnectionCycleMultiplier void   )  const
 

Gets the multiplier for how many cycles ArRobot waits when connecting.

Returns:
when the ArRobot is waiting for a connection packet back from a robot, it waits for this multiplier times the cycle time for the packet to come back before it gives up on it... This should be small for normal connections but if doing something over a slow network then you may want to make it larger

Definition at line 3358 of file ArRobot.cpp.

int ArRobot::getConnectionTimeoutTime void   )  const
 

Gets the time without a response until connection assumed lost.

Gets the number of seconds to go without response from the robot until it is assumed tha tthe connection with the robot has been broken and the disconnect on error events will happen.

Definition at line 494 of file ArRobot.cpp.

double ArRobot::getControl void   )  const [inline]
 

Gets the control heading.

Gets the control heading as an offset from the current heading.

See also:
getTh

Definition at line 299 of file ArRobot.h.

unsigned int ArRobot::getCycleTime void   )  const
 

Gets the number of ms between cycles.

Finds the number of milliseconds between cycles, at each cycle is when all packets are processed, all sensors are interpretted, all actions are called, and all user tasks are serviced. Be warned, if you set this too small you could overflow your serial connection.

Returns:
the number of milliseconds between cycles

Definition at line 3331 of file ArRobot.cpp.

Referenced by asyncConnectHandler(), blockingConnect(), and packetHandler().

unsigned int ArRobot::getCycleWarningTime void   ) 
 

Gets the number of ms between cycles to warn over.

Sets a time such that if the number of milliseconds between cycles goes over this then there will be an ArLog::log(ArLog::Normal) warning.

Returns:
the number of milliseconds between cycles to warn over, 0 means warning is off

Definition at line 3277 of file ArRobot.cpp.

unsigned int ArRobot::getCycleWarningTime void   )  const
 

Gets the number of ms between cycles to warn over.

Sets a time such that if the number of milliseconds between cycles goes over this then there will be an ArLog::log(ArLog::Normal) warning.

Returns:
the number of milliseconds between cycles to warn over, 0 means warning is off

Definition at line 3264 of file ArRobot.cpp.

ArDeviceConnection * ArRobot::getDeviceConnection void   )  const
 

Gets the connection this instance uses.

Gets the connection this instance uses to the actual robot. This is where commands will be sent and packets will be received from

Returns:
the deviceConnection used for this robot
See also:
ArDeviceConnection

ArSerialConnection

ArTcpConnection

Definition at line 465 of file ArRobot.cpp.

unsigned int ArRobot::getDirectMotionPrecedenceTime void   )  const
 

Gets the length of time a direct motion command will take precedence over actions, in milliseconds

Definition at line 4523 of file ArRobot.cpp.

ArRetFunctor1< double, ArPoseWithTime > * ArRobot::getEncoderCorrectionCallback void   )  const
 

Gets the encoderCorrectionCallback.

This gets the encoderCorrectionCB, see setEncoderCorrectionCallback for details.

Returns:
the callback, or NULL if there isn't one

Definition at line 4491 of file ArRobot.cpp.

int ArRobot::getEncoderPoseInterpPosition ArTime  timeStamp,
ArPose position
[inline]
 

Gets the encoder position the robot was at at the given timestamp.

See also:
ArInterpolation::getPose

Definition at line 694 of file ArRobot.h.

References ArInterpolation::getPose().

Referenced by ArSick::runOnce(), and ArSick::sensorInterpCallback().

ArTransform ArRobot::getEncoderTransform void   )  const
 

Gets the encoder transform.

Returns:
the transform from encoder to global coords

Definition at line 4356 of file ArRobot.cpp.

Referenced by ArActionTriangleDriveTo::findTriangle(), ArActionTriangleDriveTo::fire(), ArActionGotoStraight::fire(), ArIrrfDevice::packetHandler(), ArSick::runOnce(), ArActionGotoStraight::setEncoderGoalRel(), and ArSick::simPacketHandler().

int ArRobot::getIOAnalog int  num  )  const
 

Gets the n'th byte from the analog input data from the IO packet.

This gets the raw IO Analog value, which is a number between 0 and 1024 (2^10).

Definition at line 1601 of file ArRobot.cpp.

References getIOAnalogSize().

double ArRobot::getIOAnalogVoltage int  num  )  const
 

Gets the n'th byte from the analog input data from the IO packet.

This gets the IO Analog value converted to a voltage between 0 and 5 voltes.

Definition at line 1612 of file ArRobot.cpp.

References getIOAnalogSize().

ArTime ArRobot::getLastPacketTime void   )  const
 

Gets the time the last packet was received.

This gets the ArTime that the last packet was received at

Returns:
the time the last packet was received

Definition at line 504 of file ArRobot.cpp.

const ArRobotConfigPacketReader * ArRobot::getOrigRobotConfig void   )  const
 

Gets the original robot config packet information.

Returns:
the ArRobotConfigPacketReader taken when this instance got connected to the robot

Definition at line 1650 of file ArRobot.cpp.

Referenced by ArActionDeceleratingLimiter::fire(), packetHandler(), and ArAnalogGyro::stabilizingCallback().

int ArRobot::getPoseInterpPosition ArTime  timeStamp,
ArPose position
[inline]
 

Gets the position the robot was at at the given timestamp.

See also:
ArInterpolation::getPose

Definition at line 680 of file ArRobot.h.

References ArInterpolation::getPose().

Referenced by ArSick::runOnce(), and ArSick::sensorInterpCallback().

std::list< ArRangeDevice * > * ArRobot::getRangeDeviceList void   ) 
 

Gets the range device list.

This gets the list of range devices attached to this robot, do NOT manipulate this list directly. If you want to manipulate use the appropriate addRangeDevice, or remRangeDevice

Returns:
the list of range dvices attached to this robot

Definition at line 4008 of file ArRobot.cpp.

double ArRobot::getRealBatteryVoltage void   )  const [inline]
 

Gets the real battery voltage of the robot.

This value is averaged over a number of readings, you can get this by calling getRealBatteryVoltageAverageOfNum and set this with setRealBatteryVoltageAverageOfNum... you can call getRealBatteryVoltageNow to get the reading from the last packet.

This is whatever the actual voltage of the robot is, if you want a value normalized to 12 volts use getBatteryVoltage.

If the robot connected to doesn't send the real battery voltage it will just use the normal battery voltage (normalized to 12 volt scale).

Definition at line 272 of file ArRobot.h.

References ArRunningAverage::getAverage().

Referenced by ArModeWander::userTask(), ArModeUnguardedTeleop::userTask(), and ArModeTeleop::userTask().

double ArRobot::getRealBatteryVoltageNow void   )  const [inline]
 

Gets the instaneous battery voltage.

This is whatever the actual voltage of the robot is, if you want a value normalized to 12 volts use getBatteryVoltage. If the robot doesn't support this number the voltage will be less than 0 and you should use getBatteryVoltageNow.

Definition at line 281 of file ArRobot.h.

const ArRobotParams * ArRobot::getRobotParams void   )  const
 

Gets the parameters the robot is using.

Returns:
the ArRobotParams instance the robot is using for its parameters

Definition at line 1641 of file ArRobot.cpp.

Referenced by ArBumpers::addBumpToBuffer(), ArSick::robotConnectCallback(), ArIRs::setRobot(), ArActionIRs::setRobot(), ArSimpleConnector::setupLaserArbitrary(), and ArAnalogGyro::stabilizingCallback().

int ArRobot::getSonarRange int  num  )  const
 

Gets the range of the last sonar reading for the given sonar.

Parameters:
num the sonar number to check, should be between 0 and the number of sonar, the function won't fail if a bad number is given, will just return -1
Returns:
-1 if the sonar has never returned a reading, otherwise the sonar range, which is the distance from the physical sonar disc to where the sonar bounced back
See also:
getNumSonar

Definition at line 3750 of file ArRobot.cpp.

Referenced by getClosestSonarRange(), and ArModeSonar::userTask().

ArSensorReading * ArRobot::getSonarReading int  num  )  const
 

Returns the sonar reading for the given sonar.

Parameters:
num the sonar number to check, should be between 0 and the number of sonar, the function won't fail if a bad number is given, will just return false
Returns:
NULL if there is no sonar defined for the given number, otherwise it returns a pointer to an instance of the ArSensorReading, note that this class retains ownership, so the instance pointed to should not be deleted and no pointers to it should be stored. Note that often there will be sonar defined but no readings for it (since the readings may be created by the parameter reader), if there has never been a reading from the sonar then the range of that sonar will be -1 and its counterTaken value will be 0

Definition at line 3790 of file ArRobot.cpp.

Referenced by applyTransform(), getClosestSonarNumber(), moveTo(), and ArSonarDevice::processReadings().

int ArRobot::getStabilizingTime void   )  const
 

How long we stabilize for in ms (0 means no stabilizng).

This is the amount of time the robot will stabilize for after it has connected to the robot (it won't report it is connected until after this time is over).

Definition at line 3319 of file ArRobot.cpp.

Referenced by ArAnalogGyro::stabilizingCallback().

int ArRobot::getStateReflectionRefreshTime void   )  const
 

Sets the number of milliseconds between state reflection refreshes if the state has not changed

Definition at line 4615 of file ArRobot.cpp.

ArSyncTask * ArRobot::getSyncTaskRoot void   ) 
 

This gets the root of the syncronous task tree, only serious developers should use it

Definition at line 2049 of file ArRobot.cpp.

Referenced by ArNetServer::open(), and ArNetServer::~ArNetServer().

ArTransform ArRobot::getToGlobalTransform void   )  const
 

This gets the transform from local coords to global coords.

Returns:
an ArTransform which can be used for transforming a position in local coordinates to one in global coordinates

Definition at line 4376 of file ArRobot.cpp.

References getPose(), and ArTransform::setTransform().

Referenced by ArBumpers::addBumpToBuffer(), ArActionTriangleDriveTo::findTriangle(), moveTo(), processNewSonar(), ArIRs::processReadings(), ArActionGotoStraight::setEncoderGoalRel(), ArActionGotoStraight::setGoalRel(), and ArSick::simPacketHandler().

ArTransform ArRobot::getToLocalTransform void   )  const
 

This gets the transform for going from global coords to local coords.

Returns:
an ArTransform which can be used for transforming a position in global coordinates to one in local coordinates

Definition at line 4390 of file ArRobot.cpp.

References getPose(), and ArTransform::setTransform().

Referenced by ArActionTriangleDriveTo::findTriangle(), and moveTo().

bool ArRobot::handlePacket ArRobotPacket packet  ) 
 

Internal function, takes a packet and passes it to the packet handlers, returns true if handled, false otherwise

Definition at line 3045 of file ArRobot.cpp.

References dropConnection(), lock(), ArLog::log(), and unlock().

Referenced by packetHandler().

bool ArRobot::hasRangeDevice ArRangeDevice device  )  const
 

Finds whether a particular range device is attached to this robot or not.

Parameters:
device the device to check for

Definition at line 4016 of file ArRobot.cpp.

void ArRobot::init void   ) 
 

Internal function, shouldn't be used.

Sets up the packet handlers, sets up the sync list and makes the default priority resolver.

Definition at line 177 of file ArRobot.cpp.

References setUpPacketHandlers(), and setUpSyncList().

Referenced by ArRobot().

bool ArRobot::isConnected void   )  const [inline]
 

Questions whether the robot is connected or not.

Returns:
true if connected to a robot, false if not

Definition at line 114 of file ArRobot.h.

Referenced by actionHandler(), ArAnalogGyro::ArAnalogGyro(), ArGripper::ArGripper(), ArRobotJoyHandler::ArRobotJoyHandler(), asyncConnect(), ArSick::configureShort(), ArP2Arm::init(), ArP2Arm::isGood(), packetHandler(), ArSick::robotConnectCallback(), ArSick::sensorInterpCallback(), ArSick::setRobot(), ArSimpleConnector::setupLaserArbitrary(), ArAnalogGyro::stabilizingCallback(), stopRunning(), waitForConnect(), and waitForConnectOrConnFail().

bool ArRobot::isDirectMotion void   )  const
 

Returns true if direct motion commands are blocking actions.

Returns the state of direct motion commands: whether actions are allowed or not

See also:
clearDirectMotion

Definition at line 4565 of file ArRobot.cpp.

bool ArRobot::isHeadingDone double  delta = 0.0  )  const
 

Sees if the robot is done changing to the previously given setHeading.

Determines if a setHeading() command is finished, to within a small distance. If delta = 0 (default), the delta distance is what was set with setHeadingDoneDiff(), you can get the distnace with getHeadingDoneDiff()

Parameters:
delta how close to the goal distance the robot must be
Returns:
true if the robot has achieved the heading given in a move command or if the robot is no longer in heading mode mode (because its now running off of actions, setDHeading(), or setRotVel() was called).

Definition at line 1483 of file ArRobot.cpp.

References getTh().

bool ArRobot::isMoveDone double  delta = 0.0  ) 
 

Sees if the robot is done moving the previously given move.

Determines if a move command is finished, to within a small distance threshold, "delta". If delta = 0 (default), the delta distance set with setMoveDoneDist() will be used.

Parameters:
delta how close to the goal distance the robot must be, or 0 for previously set default
Returns:
true if the robot has finished the distance given in a move command or if the robot is no longer in a move mode (because its now running off of actions, or setVel() or setVel2() was called).
See also:
setMoveDoneDist

getMoveDoneDist

Definition at line 1458 of file ArRobot.cpp.

References ArPose::findDistanceTo(), and getPose().

bool ArRobot::isRunning void   )  const
 

Returns whether the robot is currently running or not.

Returns:
true if the robot is currently running in a run or runAsync, otherwise false

Definition at line 213 of file ArRobot.cpp.

Referenced by ArP2Arm::init(), ArP2Arm::isGood(), packetHandler(), and waitForRunExit().

bool ArRobot::isSonarNew int  num  )  const
 

Find out if the given sonar has a new reading.

Parameters:
num the sonar number to check, should be between 0 and the number of sonar, the function won't fail if a bad number is given, will just return false
Returns:
false if the sonar reading is old, or if there is no reading from that sonar

Definition at line 3768 of file ArRobot.cpp.

References getCounter().

bool ArRobot::loadParamFile const char *  file  ) 
 

Loads a parameter file (replacing all other params).

Returns:
true if the file could be loaded, false otherwise

Definition at line 1038 of file ArRobot.cpp.

References ArLog::log(), ArConfig::parseFile(), and processParamFile().

void ArRobot::logAllTasks void   )  const
 

Logs the list of all tasks, strictly for your viewing pleasure.

See also:
ArLog

Definition at line 2234 of file ArRobot.cpp.

References ArSyncTask::log().

void ArRobot::logUserTasks void   )  const
 

Logs the list of user tasks, strictly for your viewing pleasure.

See also:
ArLog

Definition at line 2218 of file ArRobot.cpp.

References ArSyncTask::findNonRecursive(), and ArSyncTask::log().

void ArRobot::loopOnce void   ) 
 

This function loops once... only serious developers should use it.

This function is only for serious developers, it basically runs the loop once. You would use this function if you were wanting to use robot control in some other monolithic program, so you could work within its framework, rather than trying to get it to work in ARIA.

Definition at line 3370 of file ArRobot.cpp.

References incCounter(), and ArSyncTask::run().

void ArRobot::move double  distance  ) 
 

Move the given distance forward/backwards.

Tells the robot to begin moving the specified distance forward/backwards. ArRobot caches this value, and sends it during the next cycle (with a MOVE or VEL command, depending on the robot).

Parameters:
distance the distance for the robot to move (millimeters)

Definition at line 1435 of file ArRobot.cpp.

References getPose(), and ArTime::setToNow().

void ArRobot::moveTo ArPose  poseTo,
ArPose  poseFrom,
bool  doCumulative = true
 

Moves the robot's RW position to reflect pose From => pose To.

Parameters:
poseTo the absolute real world position to move to
poseFrom the original absolute real world position
doCumulative whether to update the cumulative buffers or not

Definition at line 4295 of file ArRobot.cpp.

References ArSensorReading::applyTransform(), ArTransform::doInvTransform(), ArTransform::doTransform(), getNumSonar(), getSonarReading(), getToGlobalTransform(), getToLocalTransform(), and ArTransform::setTransform().

void ArRobot::moveTo ArPose  pose,
bool  doCumulative = true
 

Moves the robot's idea of its position to this position.

Parameters:
pose the absolute real world position to place the robot
doCumulative whether to update the cumulative buffers or not

Definition at line 4255 of file ArRobot.cpp.

References ArSensorReading::applyTransform(), ArTransform::doTransform(), getNumSonar(), getSonarReading(), getToGlobalTransform(), getToLocalTransform(), and ArTransform::setTransform().

Referenced by asyncConnectHandler().

void ArRobot::packetHandler void   ) 
 

Packet Handler, internal.

Reads in all of the packets that are available to read in, then runs through the list of packet handlers and tries to get each packet handled.

See also:
addPacketHandler

remPacketHandler

Definition at line 3120 of file ArRobot.cpp.

References asyncConnectHandler(), dropConnection(), getCycleTime(), ArRobotPacket::getID(), getOrigRobotConfig(), ArRobotConfigPacketReader::getSipCycleTime(), handlePacket(), ArRobotConfigPacketReader::hasPacketArrived(), isConnected(), isCycleChained(), isRunning(), lock(), ArLog::log(), ArTime::mSecSince(), ArTime::mSecTo(), ArRobotPacketReceiver::receivePacket(), ArTime::setToNow(), and unlock().

void ArRobot::processNewSonar char  number,
int  range,
ArTime  timeReceived
 

Processes a new sonar reading, internal.

This function used to just create more sonar readings if it didn't have the sonar number that was given (only the case if that sonar didn't have an entry in the param file), this caused some silent bugs in other peoples code and so was removed... especially since we don't know where the sonar are at if they weren't in the parameter file anyways.

Definition at line 3664 of file ArRobot.cpp.

References getCounter(), getEncoderPose(), getPose(), getToGlobalTransform(), ArLog::log(), and ArSensorReading::newData().

Referenced by processMotorPacket().

bool ArRobot::remAction const char *  actionName  ) 
 

Removes an action from the list, by name

See also:
addAction

remAction(ArAction*)

findAction(const char*)

Definition at line 2338 of file ArRobot.cpp.

References ArAction::getName().

bool ArRobot::remAction ArAction action  ) 
 

Removes an action from the list, by pointer

See also:
addAction

remAction(const char*)

findAction(const char*)

Definition at line 2365 of file ArRobot.cpp.

Referenced by ArActionGroup::remAction(), ArActionGroup::removeActions(), and ArAction::~ArAction().

void ArRobot::remConnectCB ArFunctor functor  ) 
 

Removes a connect callback.

Parameters:
functor the functor to remove from the list of connect callbacks
See also:
addConnectCB

Definition at line 1714 of file ArRobot.cpp.

Referenced by ArPTZ::~ArPTZ(), ArRobotConfigPacketReader::~ArRobotConfigPacketReader(), and ArRobotJoyHandler::~ArRobotJoyHandler().

void ArRobot::remDisconnectNormallyCB ArFunctor functor  ) 
 

Removes a callback for when disconnect is called while connected.

Parameters:
functor the functor to remove from the list of connect callbacks
See also:
addDisconnectNormallyCB

Definition at line 1781 of file ArRobot.cpp.

void ArRobot::remDisconnectOnErrorCB ArFunctor functor  ) 
 

Removes a callback for when disconnection happens because of an error.

Parameters:
functor the functor to remove from the list of connect callbacks
See also:
addDisconnectOnErrorCB

Definition at line 1818 of file ArRobot.cpp.

void ArRobot::remFailedConnectCB ArFunctor functor  ) 
 

Removes a callback for when a connection to the robot is failed.

Parameters:
functor the functor to remove from the list of connect callbacks
See also:
addFailedConnectCB

Definition at line 1749 of file ArRobot.cpp.

void ArRobot::remPacketHandler ArRetFunctor1< bool, ArRobotPacket * > *  functor  ) 
 

Removes a packet handler from the list of packet handlers.

Parameters:
functor the functor to remove from the list of packet handlers
See also:
addPacketHandler

Definition at line 1682 of file ArRobot.cpp.

Referenced by ArPTZ::setDeviceConnection(), ArAnalogGyro::~ArAnalogGyro(), ArIrrfDevice::~ArIrrfDevice(), ArP2Arm::~ArP2Arm(), ArPTZ::~ArPTZ(), ArRobotConfigPacketReader::~ArRobotConfigPacketReader(), ArRobotJoyHandler::~ArRobotJoyHandler(), ArSick::~ArSick(), ArSickLogger::~ArSickLogger(), and ArTCM2::~ArTCM2().

void ArRobot::remRangeDevice ArRangeDevice device  ) 
 

Remove a range device from the robot's list, by instance.

Parameters:
device remove the first device with this pointer value

Definition at line 3949 of file ArRobot.cpp.

void ArRobot::remRangeDevice const char *  name  ) 
 

Remove a range device from the robot's list, by name.

Parameters:
name remove the first device with this name

Definition at line 3933 of file ArRobot.cpp.

Referenced by ArIrrfDevice::~ArIrrfDevice(), ArSick::~ArSick(), and ArSonarDevice::~ArSonarDevice().

void ArRobot::remRunExitCB ArFunctor functor  ) 
 

Removes a callback for when the run loop exits for what ever reason.

Parameters:
functor The functor to remove from the list of run exit callbacks
See also:
addRunExitCB

Definition at line 1849 of file ArRobot.cpp.

void ArRobot::remSensorInterpTask ArFunctor functor  ) 
 

Removes a sensor interp tasks by functor.

See also:
addSensorInterpTask

remSensorInterpTask(std::string name)

Definition at line 2193 of file ArRobot.cpp.

References ArSyncTask::findNonRecursive().

void ArRobot::remSensorInterpTask const char *  name  ) 
 

Removes a sensor interp tasks by name.

See also:
addSensorInterpTask

remSensorInterpTask(ArFunctor *functor)

Definition at line 2168 of file ArRobot.cpp.

References ArSyncTask::findNonRecursive().

Referenced by ArPTZ::setDeviceConnection(), ArRangeDevice::setRobot(), ArACTS_1_2::setRobot(), ArPTZ::~ArPTZ(), ArRangeDevice::~ArRangeDevice(), ArSick::~ArSick(), and ArSonarDevice::~ArSonarDevice().

void ArRobot::remStabilizingCB ArFunctor functor  ) 
 

Removes stabilizing callback.

Parameters:
functor the functor to remove from the list of stabilizing callbacks
See also:
addConnectCB

Definition at line 1882 of file ArRobot.cpp.

Referenced by ArAnalogGyro::~ArAnalogGyro().

void ArRobot::remUserTask ArFunctor functor  ) 
 

Removes a user task from the list of synchronous taskes by functor.

See also:
addUserTask

remUserTask(std::string name)

Definition at line 2115 of file ArRobot.cpp.

References ArSyncTask::findNonRecursive().

void ArRobot::remUserTask const char *  name  ) 
 

Removes a user task from the list of synchronous taskes by name.

See also:
addUserTask

remUserTask(ArFunctor *functor)

Definition at line 2090 of file ArRobot.cpp.

References ArSyncTask::findNonRecursive().

Referenced by ArMode::baseDeactivate(), ArMode::~ArMode(), ArSickLogger::~ArSickLogger(), and ArVCC4::~ArVCC4().

void ArRobot::run bool  stopRunIfNotConnected  ) 
 

Starts the instance to do processing in this thread.

This starts the list of tasks to be run through until stopped. This function doesn't return until something calls stop on this instance.

Parameters:
stopRunIfNotConnected if true, the run will return if there is no connection to the robot at any given point, this is good for one-shot programs... if it is false the run won't return unless stop is called on the instance

Definition at line 195 of file ArRobot.cpp.

References ArLog::log().

void ArRobot::runAsync bool  stopRunIfNotConnected  ) 
 

Starts the instance to do processing in its own new thread.

This starts a new thread then has runs through the tasks until stopped. This function doesn't return until something calls stop on this instance. This function returns immediately

Parameters:
stopRunIfNotConnected if true, the run will stop if there is no connection to the robot at any given point, this is good for one-shot programs... if it is false the run won't stop unless stop is called on the instance

Definition at line 227 of file ArRobot.cpp.

References ArLog::log().

bool ArRobot::setAbsoluteMaxRotVel double  maxVel  ) 
 

Sets the robots absolute maximum rotational velocity.

This sets the absolute maximum velocity the robot will go... the maximum velocity can also be set by the actions and by setRotVelMax, but it will not be allowed to go higher than this value. You should not set this very often, if you want to manipulate this value you should use the actions or setRotVelMax.

Parameters:
maxVel the maximum velocity to be set, it must be a non-zero number
Returns:
true if the value is good, false othrewise

Definition at line 1587 of file ArRobot.cpp.

References getRotVelMax(), and setRotVelMax().

Referenced by asyncConnectHandler().

bool ArRobot::setAbsoluteMaxTransVel double  maxVel  ) 
 

Sets the robots absolute maximum translational velocity.

This sets the absolute maximum velocity the robot will go... the maximum velocity can also be set by the actions and by setTransVelMax, but it will not be allowed to go higher than this value. You should not set this very often, if you want to manipulate this value you should use the actions or setTransVelMax.

Parameters:
maxVel the maximum velocity to be set, it must be a non-zero number
Returns:
true if the value is good, false othrewise

Definition at line 1566 of file ArRobot.cpp.

References getTransVelMax(), and setTransVelMax().

Referenced by asyncConnectHandler().

void ArRobot::setConnectionCycleMultiplier unsigned int  multiplier  ) 
 

Sets the multiplier for how many cycles ArRobot waits when connecting.

Parameters:
multiplier when the ArRobot is waiting for a connection packet back from a robot, it waits for this multiplier times the cycle time for the packet to come back before it gives up on it... This should be small for normal connections but if doing something over a slow network then you may want to make it larger

Definition at line 3346 of file ArRobot.cpp.

void ArRobot::setConnectionTimeoutTime int  mSecs  ) 
 

Sets the time without a response until connection assumed lost.

Sets the number of milliseconds to go without a response from the robot until it is assumed that the connection with the robot has been broken and the disconnect on error events will happen. Note that this will only happen with the default packet handler.

Parameters:
mSecs if seconds is 0 then the connection timeout feature will be disabled, otherwise disconnect on error will be triggered after this number of seconds...

Definition at line 480 of file ArRobot.cpp.

void ArRobot::setCycleTime unsigned int  ms  ) 
 

Sets the number of ms between cycles.

Sets the number of milliseconds between cycles, at each cycle is when all packets are processed, all sensors are interpretted, all actions are called, and all user tasks are serviced. Be warned, if you set this too small you could overflow your serial connection.

Parameters:
ms the number of milliseconds between cycles

Definition at line 3289 of file ArRobot.cpp.

void ArRobot::setCycleWarningTime unsigned int  ms  ) 
 

Sets the number of ms between cycles to warn over.

Sets a time such that if the number of milliseconds between cycles goes over this then there will be an ArLog::log(ArLog::Normal) warning.

Parameters:
ms the number of milliseconds between cycles to warn over, 0 turns warning off

Definition at line 3250 of file ArRobot.cpp.

void ArRobot::setDeadReconPose ArPose  pose  ) 
 

Sets the dead recon position of the robot.

Parameters:
pose the position to set the dead recon position to

Definition at line 4364 of file ArRobot.cpp.

References ArTransform::doTransform(), ArPose::setPose(), and ArTransform::setTransform().

void ArRobot::setDeltaHeading double  deltaHeading  ) 
 

Sets the delta heading.

Sets a delta heading to the robot, it caches this value, and sends it during the next cycle.

Parameters:
deltaHeading the desired amount to change the heading of the robot by

Definition at line 1540 of file ArRobot.cpp.

References ArMath::addAngle(), getTh(), and ArTime::setToNow().

void ArRobot::setDeviceConnection ArDeviceConnection connection  ) 
 

Sets the connection this instance uses.

Sets the connection this instance uses to the actual robot. This is where commands will be sent and packets will be received from

Parameters:
connection The deviceConnection to use for this robot
See also:
ArDeviceConnection, ArSerialConnection, ArTcpConnection

Definition at line 450 of file ArRobot.cpp.

References ArRobotPacketReceiver::setDeviceConnection(), and ArRobotPacketSender::setDeviceConnection().

void ArRobot::setDirectMotionPrecedenceTime int  mSec  ) 
 

Sets the length of time a direct motion command will take precedence over actions, in milliseconds

Definition at line 4506 of file ArRobot.cpp.

void ArRobot::setEncoderCorrectionCallback ArRetFunctor1< double, ArPoseWithTime > *  functor  ) 
 

Sets the encoderCorrectionCallback.

This sets the encoderCorrectionCB, this callback returns the robots change in heading, it takes in the change in heading, x, and y, between the previous and current readings.

Parameters:
functor an ArRetFunctor1 created as an ArRetFunctor1C, that will be the callback... call this function NULL to clear the callback
See also:
getEncoderCorrectionCallback

Definition at line 4479 of file ArRobot.cpp.

Referenced by ArAnalogGyro::ArAnalogGyro(), and ArAnalogGyro::~ArAnalogGyro().

void ArRobot::setEncoderTransform ArPose  transformPos  ) 
 

Changes the transform directly.

Parameters:
transformPos the position to transform to

Definition at line 4347 of file ArRobot.cpp.

References ArTransform::doTransform(), and ArTransform::setTransform().

void ArRobot::setEncoderTransform ArPose  deadReconPos,
ArPose  globalPos
 

Changes the transform.

Parameters:
deadReconPos the dead recon position to transform from
globalPos the real world global position to transform to

Definition at line 4337 of file ArRobot.cpp.

References ArTransform::doTransform(), and ArTransform::setTransform().

void ArRobot::setHeading double  heading  ) 
 

Sets the heading.

Sets the heading of the robot, it caches this value, and sends it during the next cycle.

Parameters:
heading the desired heading of the robot (degrees)

Definition at line 1502 of file ArRobot.cpp.

References ArTime::setToNow().

void ArRobot::setRotVel double  velocity  ) 
 

Sets the rotational velocity.

Sets the rotational velocity of the robot, it caches this value, and sends it during the next cycle.

Parameters:
velocity the desired rotational velocity of the robot (deg/sec)

Definition at line 1521 of file ArRobot.cpp.

References ArTime::setToNow().

Referenced by stop().

void ArRobot::setStabilizingTime int  mSecs  ) 
 

How long we should stabilize for in ms (0 disables stabilizing).

This is the amount of time the robot will stabilize for after it has connected to the robot (it won't report it is connected until after this time is over). By convention you should never set this lower than what you find the value at (though it will let you) this is so that everything can get itself stabilized before we let things drive.

Parameters:
mSecs the amount of time to stabilize for (0 disables)
See also:
addStabilizingCB

Definition at line 3306 of file ArRobot.cpp.

Referenced by ArAnalogGyro::stabilizingCallback().

void ArRobot::setStateReflectionRefreshTime int  msec  ) 
 

Sets the number of milliseconds between state reflection refreshes if the state has not changed

Definition at line 4600 of file ArRobot.cpp.

void ArRobot::setVel double  velocity  ) 
 

Sets the velocity

See also:
clearDirectMotion

Definition at line 1396 of file ArRobot.cpp.

References ArTime::setToNow().

Referenced by stop().

void ArRobot::setVel2 double  leftVelocity,
double  rightVelocity
 

Sets the velocity of the wheels independently.

Sets the velocity of each of the wheels on the robot independently. ArRobot caches these values, and sends them with a VEL2 command during the next cycle. Note that this cancels both translational velocity AND rotational velocity, and is canceled by any of the other direct motion commands.

See also:
setVel

setRotVel

clearDirectMotion

Parameters:
leftVelocity the desired velocity of the left wheel
rightVelocity the desired velocity of the right wheel

Definition at line 1418 of file ArRobot.cpp.

References ArTime::setToNow().

void ArRobot::stop void   ) 
 

Stops the robot

See also:
clearDirectMotion

Definition at line 1379 of file ArRobot.cpp.

References comInt(), setRotVel(), and setVel().

Referenced by ArMode::baseActivate().

void ArRobot::stopRunning bool  doDisconnect = true  ) 
 

Stops the robot from doing any more processing.

This stops this robot's processing cycle. If it is running in a background thread (from runAsync()), it will cause that thread to exit. If it is running synchronously (from run()), then run() will return.

Parameters:
doDisconnect If true, also disconnect from the robot connection (default is true).
See also:
isRunning

Definition at line 249 of file ArRobot.cpp.

References disconnect(), isConnected(), ArKeyHandler::restore(), waitForRunExit(), and wakeAllWaitingThreads().

Referenced by ArNetServer::internalShutdownServer(), keyHandlerExit(), and ~ArRobot().

void ArRobot::stopStateReflection void   ) 
 

Sets the state reflection to be inactive (until motion or clearDirectMotion)

See also:
clearDirectMotion

Definition at line 4553 of file ArRobot.cpp.

ArRobot::WaitState ArRobot::waitForConnect unsigned int  msecs = 0  ) 
 

Suspend calling thread until the ArRobot is connected.

This will suspend the calling thread until the ArRobot's run loop has managed to connect with the robot. There is an optional paramater of milliseconds to wait for the ArRobot to connect. If msecs is set to 0, it will wait until the ArRobot connects. This function will never return if the robot can not be connected with. If you want to be able to handle that case within the calling thread, you must call waitForConnectOrConnFail().

Parameters:
msecs milliseconds in which to wait for the ArRobot to connect
Returns:
WAIT_CONNECTED for success
See also:
waitForConnectOrConnFail

wakeAllWaitingThreads

wakeAllConnWaitingThreads

wakeAllRunExitWaitingThreads

Definition at line 1908 of file ArRobot.cpp.

References isConnected(), ArCondition::timedWait(), ArCondition::wait(), WAIT_CONNECTED, WAIT_FAIL, WAIT_INTR, and WAIT_TIMEDOUT.

ArRobot::WaitState ArRobot::waitForConnectOrConnFail unsigned int  msecs = 0  ) 
 

Suspend calling thread until the ArRobot is connected or fails to connect.

This will suspend the calling thread until the ArRobot's run loop has managed to connect with the robot or fails to connect with the robot. There is an optional paramater of milliseconds to wait for the ArRobot to connect. If msecs is set to 0, it will wait until the ArRobot connects.

Parameters:
msecs milliseconds in which to wait for the ArRobot to connect
Returns:
WAIT_CONNECTED for success
See also:
waitForConnect

Definition at line 1940 of file ArRobot.cpp.

References isConnected(), ArCondition::timedWait(), ArCondition::wait(), WAIT_CONNECTED, WAIT_FAIL, WAIT_FAILED_CONN, WAIT_INTR, and WAIT_TIMEDOUT.

ArRobot::WaitState ArRobot::waitForRunExit unsigned int  msecs = 0  ) 
 

Suspend calling thread until the ArRobot run loop has exited.

This will suspend the calling thread until the ArRobot's run loop has exited. There is an optional paramater of milliseconds to wait for the ArRobot run loop to exit . If msecs is set to 0, it will wait until the ArRrobot run loop exits.

Parameters:
msecs milliseconds in which to wait for the robot to connect
Returns:
WAIT_RUN_EXIT for success

Definition at line 1975 of file ArRobot.cpp.

References isRunning(), ArCondition::timedWait(), ArCondition::wait(), WAIT_FAIL, WAIT_INTR, WAIT_RUN_EXIT, and WAIT_TIMEDOUT.

Referenced by stopRunning().

void ArRobot::wakeAllConnOrFailWaitingThreads  ) 
 

Wake up all threads waiting for connection or connection failure.

This will wake all the threads waiting for the robot to be connected or waiting for the robot to fail to connect.

See also:
wakeAllWaitingThreads

wakeAllRunExitWaitingThreads

Definition at line 2027 of file ArRobot.cpp.

References ArCondition::broadcast().

Referenced by failedConnect().

void ArRobot::wakeAllConnWaitingThreads  ) 
 

Wake up all threads waiting for connection.

This will wake all the threads waiting for the robot to be connected.

See also:
wakeAllWaitingThreads

wakeAllRunExitWaitingThreads

Definition at line 2015 of file ArRobot.cpp.

References ArCondition::broadcast().

Referenced by finishedConnection(), and wakeAllWaitingThreads().

void ArRobot::wakeAllRunExitWaitingThreads  ) 
 

Wake up all threads waiting for the run loop to exit.

This will wake all the threads waiting for the run loop to exit.

See also:
wakeAllWaitingThreads

wakeAllConnWaitingThreads

Definition at line 2037 of file ArRobot.cpp.

References ArCondition::broadcast().

Referenced by wakeAllWaitingThreads().

void ArRobot::wakeAllWaitingThreads  ) 
 

Wake up all threads waiting on this robot.

This will wake all the threads waiting for various major state changes in this particular ArRobot. This includes all threads waiting for the robot to be connected and all threads waiting for the run loop to exit.

See also:
wakeAllConnWaitingThreads

wakeAllRunExitWaitingThreads

Definition at line 2004 of file ArRobot.cpp.

References wakeAllConnWaitingThreads(), and wakeAllRunExitWaitingThreads().

Referenced by stopRunning().


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