ArP2Arm Class Reference

#include <ArP2Arm.h>

List of all members.


Detailed Description

Arm Control class.

ArP2Arm is the interface to the AROS/P2OS-based Pioneer 2 Arm servers. The P2 Arm is attached to the robot's microcontroller via an auxiliary serial port.

To use ArmP2, you must first set up an ArRobot and have it connect with the robot. The ArRobot needs to be run so that it reads and writes packets to and from server. The easiest way is ArRobot::runAsync() which runs the ArRobot in its own thread.

Then call ArP2Arm::setRobot() with ArRobot, and finally initialized with ArmP2::init(). Once initialized, use the various ArP2Arm methods to power the P2 Arm servos, move joints, and so on.

For simple examples on how to use ArP2Arm, look in the Aria/examples directory for P2ArmSimple.cpp and P2ArmJoydrive.cpp.

See the Aria documentation on how to use Aria.


Public Types

enum  PacketType { StatusPacket, InfoPacket }
 Type of arm packet identifiers. Used in ArP2Arm::setPacketCB(). More...
enum  State {
  SUCCESS, ALREADY_INITED, NOT_INITED, ROBOT_NOT_SETUP,
  NO_ARM_FOUND, COMM_FAILED, COULD_NOT_OPEN_PORT, COULD_NOT_SET_UP_PORT,
  ALREADY_CONNECTED, NOT_CONNECTED, INVALID_JOINT, INVALID_POSITION
}
 General error conditions possible from most of the arm related functions. More...
enum  StatusType { StatusOff = 0, StatusSingle = 1, StatusContinuous = 2 }
 Type of status packets to request for. Used in ArP2Arm::requestStatus(). More...

Public Member Functions

 ArP2Arm ()
 Constructor.
virtual State checkArm (bool waitForResponse=true)
 Check to see if the arm is still connected.
virtual bool convertDegToTicks (int joint, float pos, unsigned char *ticks)
 Converts degrees to low level arm controller ticks.
virtual bool convertTicksToDeg (int joint, unsigned char pos, float *degrees)
 Converts low level arm controller ticks to degrees.
virtual std::string getArmVersion ()
 Get the arm version.
virtual P2ArmJointgetJoint (int joint)
 Get the joints data structure.
virtual float getJointPos (int joint)
 Get the joints position in degrees.
virtual unsigned char getJointPosTicks (int joint)
 Get the joints position in ticks.
virtual ArTime getLastStatusTime ()
 Get when the last arm status packet came in.
virtual bool getMoving (int joint=-1)
 Check to see if the arm is moving.
virtual ArRobotgetRobot ()
 Get the robot that the arm is on.
virtual int getStatus ()
 Get the two byts of status info from P2OS.
virtual State home (int joint=-1)
 Home the arm.
virtual State init ()
 Init the arm class.
virtual bool isGood ()
 Check to see if the arm is communicating.
virtual bool isPowered ()
 Check to see if the arm is powered.
virtual State moveStep (int joint, float pos, unsigned char vel=0)
 Move a joint step degrees.
virtual State moveStepTicks (int joint, signed char pos)
 Move a joint step ticks.
virtual State moveTo (int joint, float pos, unsigned char vel=0)
 Move a joint to a position in degrees.
virtual State moveToTicks (int joint, unsigned char pos)
 Move a joint to a position in low level arm controller ticks.
virtual State moveVel (int joint, int vel)
 Set the joint to move at the given velocity.
virtual State park ()
 Home the arm and power if off.
virtual State powerOff ()
 Power off the arm.
virtual State powerOn (bool doWait=true)
 Power on the arm.
virtual State requestInfo ()
 Request the arm info packet.
virtual State requestInit ()
 Request arm initialization.
virtual State requestStatus (StatusType status)
 Request the arm status packet.
virtual State setAutoParkTimer (int waitSecs)
 Set the auto park timer value.
virtual State setGripperParkTimer (int waitSecs)
 Set the gripper park timer value.
virtual void setPacketCB (ArFunctor1< PacketType > *func)
 set the arm packet callback
void setRobot (ArRobot *robot)
 Set the robot to use to talk to the arm.
virtual void setStoppedCB (ArFunctor *func)
 Set the arm stopped callback.
virtual State stop ()
 Stop the arm.
virtual State uninit ()
 Uninit the arm class.
virtual ~ArP2Arm ()
 Destructor.

Static Public Attributes

static const int ArmGood
 Bit for arm good state in arm status byte.
static const int ArmHoming
 Bit for arm homing in arm status byte.
static const int ArmInited
 Bit for arm initialized in arm status byte.
static const int ArmJoint1
 Bit for joint 1 in arm status byte.
static const int ArmJoint2
 Bit for joint 2 in arm status byte.
static const int ArmJoint3
 Bit for joint 3 in arm status byte.
static const int ArmJoint4
 Bit for joint 4 in arm status byte.
static const int ArmJoint5
 Bit for joint 5 in arm status byte.
static const int ArmJoint6
 Bit for joint 6 in arm status byte.
static const int ArmPower
 Bit for arm powered on in arm status byte.
static int NumJoints
 Number of joints that the arm has.

Protected Member Functions

bool armPacketHandler (ArRobotPacket *packet)
bool comArmAutoPark (int waitSecs)
bool comArmCheckArm ()
bool comArmGripperPark (int waitSecs)
bool comArmHome (unsigned char joint=0xff)
bool comArmInfo ()
bool comArmInit ()
bool comArmPark ()
bool comArmPos (unsigned char joint, unsigned char pos)
bool comArmPower (bool on)
bool comArmSpeed (unsigned char joint, unsigned char speed)
bool comArmStats (StatusType stats=StatusSingle)
bool comArmStop (unsigned char joint=0xff)

Protected Attributes

ArRetFunctorC< State, ArP2ArmmyAriaUninitCB
ArRetFunctor1C< bool, ArP2Arm,
ArRobotPacket * > 
myArmPacketHandler
ArSerialConnection myCon
bool myInited
P2ArmJoint myJoints [6]
ArTime myLastInfoTime
ArTypes::UByte2 myLastStatus
ArTime myLastStatusTime
ArFunctor1< PacketType > * myPacketCB
ArRobotmyRobot
ArTypes::UByte2 myStatus
StatusType myStatusRequest
ArFunctormyStoppedCB
std::string myVersion

Static Protected Attributes

static const unsigned int ARMINFOpac
static const unsigned int ARMpac
static const unsigned char ComArmAutoPark
static const unsigned char ComArmCheckArm
static const unsigned char ComArmGripperPark
static const unsigned char ComArmHome
static const unsigned char ComArmInfo
static const unsigned char ComArmInit
static const unsigned char ComArmPark
static const unsigned char ComArmPos
static const unsigned char ComArmPower
static const unsigned char ComArmSpeed
static const unsigned char ComArmStats
static const unsigned char ComArmStop


Member Enumeration Documentation

enum ArP2Arm::PacketType

Type of arm packet identifiers. Used in ArP2Arm::setPacketCB().

Enumerator:
StatusPacket  The status packet type.
InfoPacket  The info packet type.

enum ArP2Arm::State

General error conditions possible from most of the arm related functions.

Enumerator:
SUCCESS  Succeded.
ALREADY_INITED  The class is already initialized.
NOT_INITED  The class is not initialized.
ROBOT_NOT_SETUP  The ArRobot class is not setup properly.
NO_ARM_FOUND  The arm can not be found.
COMM_FAILED  Communications has failed.
COULD_NOT_OPEN_PORT  Could not open the communications port.
COULD_NOT_SET_UP_PORT  Could not setup the communications port.
ALREADY_CONNECTED  Already connected to the arm.
NOT_CONNECTED  Not connected with the arm, connect first.
INVALID_JOINT  Invalid joint specified.
INVALID_POSITION  Invalid position specified.

enum ArP2Arm::StatusType

Type of status packets to request for. Used in ArP2Arm::requestStatus().

Enumerator:
StatusOff  Stop sending status packets.
StatusSingle  Send a single status packets.
StatusContinuous  Send continous packets. Once every 100ms.


The documentation for this class was generated from the following file:
Generated on Thu Aug 6 09:39:36 2009 for Aria by  doxygen 1.5.1