Main Page   Class Hierarchy   Compound List   Compound Members  

ArP2Arm Class Reference

Arm Control class. More...

#include <ArP2Arm.h>

List of all members.

Public Types

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  PacketType { StatusPacket, InfoPacket }
 Type of arm packet identifiers. Used in ArP2Arm::setPacketCB(). More...

enum  StatusType { StatusOff = 0, StatusSingle = 1, StatusContinuous = 2 }
 Type of status packets to request for. Used in ArP2Arm::requestStatus(). More...


Public Methods

 ArP2Arm ()
 Constructor.

virtual ~ArP2Arm ()
 Destructor.

void setRobot (ArRobot *robot)
 Set the robot to use to talk to the arm.

virtual State init ()
 Init the arm class. More...

virtual State uninit ()
 Uninit the arm class. More...

virtual State powerOn (bool doWait=true)
 Power on the arm. More...

virtual State powerOff ()
 Power off the arm. More...

virtual State requestInfo ()
 Request the arm info packet. More...

virtual State requestStatus (StatusType status)
 Request the arm status packet. More...

virtual State requestInit ()
 Request arm initialization. More...

virtual State checkArm (bool waitForResponse=true)
 Check to see if the arm is still connected. More...

virtual State home (int joint=-1)
 Home the arm. More...

virtual State park ()
 Home the arm and power if off.

virtual State moveTo (int joint, float pos, unsigned char vel=0)
 Move a joint to a position in degrees. More...

virtual State moveToTicks (int joint, unsigned char pos)
 Move a joint to a position in low level arm controller ticks. More...

virtual State moveStep (int joint, float pos, unsigned char vel=0)
 Move a joint step degrees. More...

virtual State moveStepTicks (int joint, signed char pos)
 Move a joint step ticks. More...

virtual State moveVel (int joint, int vel)
 Set the joint to move at the given velocity. More...

virtual State stop ()
 Stop the arm. More...

virtual State setAutoParkTimer (int waitSecs)
 Set the auto park timer value. More...

virtual State setGripperParkTimer (int waitSecs)
 Set the gripper park timer value. More...

virtual void setStoppedCB (ArFunctor *func)
 Set the arm stopped callback.

virtual void setPacketCB (ArFunctor1< PacketType > *func)
 set the arm packet callback.

virtual std::string getArmVersion ()
 Get the arm version.

virtual float getJointPos (int joint)
 Get the joints position in degrees.

virtual unsigned char getJointPosTicks (int joint)
 Get the joints position in ticks.

virtual bool getMoving (int joint=-1)
 Check to see if the arm is moving.

virtual bool isPowered ()
 Check to see if the arm is powered.

virtual bool isGood ()
 Check to see if the arm is communicating.

virtual int getStatus ()
 Get the two byts of status info from P2OS.

virtual ArTime getLastStatusTime ()
 Get when the last arm status packet came in.

virtual ArRobotgetRobot ()
 Get the robot that the arm is on.

virtual P2ArmJointgetJoint (int joint)
 Get the joints data structure.

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.


Static Public Attributes

const int ArmJoint1 = 0x1
 Bit for joint 1 in arm status byte.

const int ArmJoint2 = 0x2
 Bit for joint 2 in arm status byte.

const int ArmJoint3 = 0x4
 Bit for joint 3 in arm status byte.

const int ArmJoint4 = 0x8
 Bit for joint 4 in arm status byte.

const int ArmJoint5 = 0x10
 Bit for joint 5 in arm status byte.

const int ArmJoint6 = 0x20
 Bit for joint 6 in arm status byte.

const int ArmGood = 0x100
 Bit for arm good state in arm status byte.

const int ArmInited = 0x200
 Bit for arm initialized in arm status byte.

const int ArmPower = 0x400
 Bit for arm powered on in arm status byte.

const int ArmHoming = 0x800
 Bit for arm homing in arm status byte.

int NumJoints = 6
 Number of joints that the arm has.


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.


Member Enumeration Documentation

enum ArP2Arm::PacketType
 

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

Enumeration values:
StatusPacket  The status packet type.
InfoPacket  The info packet type.

enum ArP2Arm::State
 

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

Enumeration values:
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().

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


Member Function Documentation

ArP2Arm::State ArP2Arm::checkArm bool    waitForResponse = true [virtual]
 

Check to see if the arm is still connected.

Requests that P2OS checks to see if the arm is still alive and immediately exits. This is not a full init and differs that P2OS will still accept arm commands and the arm will not be parked. If P2OS fails to find the arm it will change the status byte accordingly and stop accepting arm related commands except for init commands. If the parameter waitForResponse is true then checkArm() will wait the appropriate amoutn of time and check the status of the arm. If you wish to do the waiting else where the arm check sequence takes about 200ms, so the user should wait 300ms then send a ArP2Arm::requestStatus() to get the results of the check arm request. Since there is a very noticable time delay, the user should use the ArP2Arm::setPacketCB() to set a callback so the user knows when the packet has been recieved.

This can be usefull for telling if the arm is still alive. The arm controller can be powered on/off seperately from the robot.

Parameters:
waitForResponse  cause the function to block until their is a response
See also:
requestInit , setPacketCB

ArP2Arm::State ArP2Arm::home int    joint = -1 [virtual]
 

Home the arm.

Tells the arm to go to the home position. While the arm is homing, the status byte will reflect it with the ArP2Arm::ArmHoming flag. If joint is set to -1, then all the joints will be homed at a safe speed. If a single joint is specified, that joint will be told to go to its home position at the current speed its set at.

Parameters:
joint  home only that joint

ArP2Arm::State ArP2Arm::init void    [virtual]
 

Init the arm class.

Initialize the P2 Arm class. This must be called before anything else. The setRobot() must be called to let ArP2Arm know what instance of an ArRobot to use. It talks to the robot and makes sure that there is an arm on it and it is in a good condition. The AROS/P2OS arm servers take care of AUX port serial communications with the P2 Arm controller.

ArP2Arm::State ArP2Arm::moveStep int    joint,
float    pos,
unsigned char    vel = 0
[virtual]
 

Move a joint step degrees.

Step the joint pos degrees from its current position at the given speed. If vel is 0, then the currently set speed will be used.

See ArP2Arm::moveToTicks() for a description of how positions are defined. See ArP2Arm::moveVel() for a description of how speeds are defined.

Parameters:
joint  the joint to move
pos  the position in degrees to step
vel  the speed at which to move. 0 will use the currently set speed
See also:
moveTo , moveVel

ArP2Arm::State ArP2Arm::moveStepTicks int    joint,
signed char    pos
[virtual]
 

Move a joint step ticks.

Move the joint pos ticks from its current position. A tick is the arbitrary position value that the arm controller uses. The arm controller uses a single unsigned byte to represent all the possible positions in the range of the servo for each joint. So the range of ticks is 0-255 which is mapped to the physical range of the servo. Due to the design of the arm, certain joints range are limited by the arm itself. P2OS will bound the position to physical range of each joint. This is a lower level of controlling the arm position than using ArP2Arm::moveTo(). ArP2Arm::moveStep() uses a conversion factor which converts degrees to ticks.

Parameters:
joint  the joint to move
pos  the position, in ticks, to move to
See also:
moveStep

ArP2Arm::State ArP2Arm::moveTo int    joint,
float    pos,
unsigned char    vel = 0
[virtual]
 

Move a joint to a position in degrees.

Move the joint to the position at the given speed. If vel is 0, then the currently set speed will be used. The position is in degrees. Each joint has about a +-90 degree range, but they all differ due to the design.

See ArP2Arm::moveToTicks() for a description of how positions are defined. See ArP2Arm::moveVel() for a description of how speeds are defined.

Parameters:
joint  the joint to move
pos  the position in degrees to move to
vel  the speed at which to move. 0 will use the currently set speed
See also:
moveToTicks , moveVel

ArP2Arm::State ArP2Arm::moveToTicks int    joint,
unsigned char    pos
[virtual]
 

Move a joint to a position in low level arm controller ticks.

Move the joint to the given position in ticks. A tick is the arbitrary position value that the arm controller uses. The arm controller uses a single unsigned byte to represent all the possible positions in the range of the servo for each joint. So the range of ticks is 0-255 which is mapped to the physical range of the servo. Due to the design of the arm, certain joints range are limited by the arm itself. P2OS will bound the position to physical range of each joint. This is a lower level of controlling the arm position than using ArP2Arm::moveTo(). ArP2Arm::moveTo() uses a conversion factor which converts degrees to ticks.

Parameters:
joint  the joint to move
pos  the position, in ticks, to move to
See also:
moveTo

ArP2Arm::State ArP2Arm::moveVel int    joint,
int    vel
[virtual]
 

Set the joint to move at the given velocity.

Set the joints velocity. The arm controller has no way of controlling the speed of the servos in the arm. So to control the speed of the arm, P2OS will incrementaly send a string of position commands to the arm controller to get the joint to move to its destination. To vary the speed, the amount of time to wait between each point in the path is varied. The velocity parameter is simply the number of milliseconds to wait between each point in the path. 0 is the fastest and 255 is the slowest. A reasonable range is around 10-40.

Parameters:
joint  the joint to move
vel  the velocity to move at

ArP2Arm::State ArP2Arm::powerOff   [virtual]
 

Power off the arm.

Powers off the arm. This should only be called when the arm is in a good position to power off. Due to the design, it will go limp when the power is turned off. A more safe way to power off the arm is to use the ArP2Arm::park() function. Which will home the arm, then power if off.

See also:
park

ArP2Arm::State ArP2Arm::powerOn bool    doSleep = true [virtual]
 

Power on the arm.

Powers on the arm. The arm will shake for up to 2 seconds after powering on. If the arm is told to move before it stops shaking, that vibration can be amplified by moving. The default is to wait the 2 seconds for the arm to settle down.

Parameters:
doSleep  if true, sleeps 2 seconds to wait for the arm to stop shaking

ArP2Arm::State ArP2Arm::requestInfo   [virtual]
 

Request the arm info packet.

Requests the arm info packet from P2OS and immediately returns. This packet will be sent during the next 100ms cycle of P2OS. Since there is a very noticable time delay, the user should use the ArP2Arm::setPacketCB() to set a callback so the user knows when the packet has been recieved.

See also:
setPacketCB

ArP2Arm::State ArP2Arm::requestInit   [virtual]
 

Request arm initialization.

Requests that P2OS initialize the arm and immediately returns. The arm initialization procedure takes about 700ms to complete and a little more time for the status information to be relayed back to the client. Since there is a very noticable time delay, the user should use the ArP2Arm::setPacketCB() to set a callback so the user knows when the arm info packet has been recieved. Then wait about 800ms, and send a ArP2Arm::requestStatus() to get the results of the init request. While the init is proceding, P2OS will ignore all arm related commands except requests for arm status and arm info packets.

ArP2Arm::checkArm() can be used to periodicly check to make sure that the arm controller is still alive and responding.

See also:
checkArm , setPacketCB

ArP2Arm::State ArP2Arm::requestStatus StatusType    status [virtual]
 

Request the arm status packet.

Requests the arm status packet from P2OS and immediately returns. This packet will be sent during the next 100ms cycle of P2OS. Since there is a very noticable time delay, the user should use the ArP2Arm::setPacketCB() to set a callback so the user knows when the packet has been recieved.

See also:
setPacketCB

ArP2Arm::State ArP2Arm::setAutoParkTimer int    waitSecs [virtual]
 

Set the auto park timer value.

P2OS will automaticly park the arm if it gets no arm related packets after waitSecs. This is to help protect the arm when the program looses connection with P2OS. Set the value to 0 to disable this timer. Default wait is 10 minutes.

Parameters:
waitSecs  seconds to wait till parking the arm when idle

ArP2Arm::State ArP2Arm::setGripperParkTimer int    waitSecs [virtual]
 

Set the gripper park timer value.

P2OS/AROS automatically park the gripper after its been closed for more than waitSecs. The gripper servo can overheat and burnout if it is holding something for more than 10 minutes. Care must be taken to ensure that this does not happen. If you wish to manage the gripper yourself, you can disable this timer by setting it to 0.

Parameters:
waitSecs  seconds to wait till parking the gripper once it has begun to grip something

ArP2Arm::State ArP2Arm::stop   [virtual]
 

Stop the arm.

Stop the arm from moving. This overrides all other actions except for the arms initilization sequence.

ArP2Arm::State ArP2Arm::uninit   [virtual]
 

Uninit the arm class.

Uninitialize the arm class. This simply asks the arm to park itself and cleans up its internal state. To completely uninitialize the P2 Arm itself have the ArRobot disconnect from P2OS.


The documentation for this class was generated from the following files:
Generated on Tue Nov 12 17:43:59 2002 for Aria by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001