Aria  2.8.0

ArP2Arm is the interface to the AROS/P2OS-based Pioneer 2 Arm servers, by means of which the robot microcontroller firmware can control the original 5-DOF Pioneer 2 Arm manipulator. More...

#include <ArP2Arm.h>

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. More...
 
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. More...
 
virtual State init ()
 Init the arm class. More...
 
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. More...
 
virtual State moveStepTicks (int joint, signed char pos)
 Move a joint step ticks. More...
 
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 moveVel (int joint, int vel)
 Set the joint to move at the given velocity. More...
 
virtual State park ()
 Home the arm and power if off.
 
virtual State powerOff ()
 Power off the arm. More...
 
virtual State powerOn (bool doWait=true)
 Power on the arm. More...
 
virtual State requestInfo ()
 Request the arm info packet. More...
 
virtual State requestInit ()
 Request arm initialization. More...
 
virtual State requestStatus (StatusType status)
 Request the arm status packet. 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 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. More...
 
virtual State uninit ()
 Uninit the arm class. More...
 
virtual ~ArP2Arm ()
 Destructor.
 

Static Public Attributes

static const int ArmGood =0x100
 Bit for arm good state in arm status byte.
 
static const int ArmHoming =0x800
 Bit for arm homing in arm status byte.
 
static const int ArmInited =0x200
 Bit for arm initialized in arm status byte.
 
static const int ArmJoint1 =0x1
 Bit for joint 1 in arm status byte.
 
static const int ArmJoint2 =0x2
 Bit for joint 2 in arm status byte.
 
static const int ArmJoint3 =0x4
 Bit for joint 3 in arm status byte.
 
static const int ArmJoint4 =0x8
 Bit for joint 4 in arm status byte.
 
static const int ArmJoint5 =0x10
 Bit for joint 5 in arm status byte.
 
static const int ArmJoint6 =0x20
 Bit for joint 6 in arm status byte.
 
static const int ArmPower =0x400
 Bit for arm powered on in arm status byte.
 
static int NumJoints =6
 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 =0xa1
 
static const unsigned int ARMpac =0xa0
 
static const unsigned char ComArmAutoPark =80
 
static const unsigned char ComArmCheckArm =73
 
static const unsigned char ComArmGripperPark =81
 
static const unsigned char ComArmHome =75
 
static const unsigned char ComArmInfo =70
 
static const unsigned char ComArmInit =72
 
static const unsigned char ComArmPark =76
 
static const unsigned char ComArmPos =77
 
static const unsigned char ComArmPower =74
 
static const unsigned char ComArmSpeed =78
 
static const unsigned char ComArmStats =71
 
static const unsigned char ComArmStop =79
 

Detailed Description

ArP2Arm is the interface to the AROS/P2OS-based Pioneer 2 Arm servers, by means of which the robot microcontroller firmware can control the original 5-DOF Pioneer 2 Arm manipulator.

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.

For additional information about the original 5-DOF Pioneer 2 Arm, see the robot operations manual and the arm manual, available at http://robots.mobilerobots.com.Arm Control class

Examples:
armExample.cpp.

Member Enumeration Documentation

◆ PacketType

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

Enumerator
StatusPacket 

The status packet type.

InfoPacket 

The info packet type.

◆ 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.

◆ 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.

Member Function Documentation

◆ checkArm()

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 received.

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

Parameters
waitForResponsecause the function to block until their is a response
See also
requestInit
setPacketCB

◆ home()

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
jointhome only that joint

◆ init()

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.

Examples:
armExample.cpp.

◆ moveStep()

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
jointthe joint to move
posthe position in degrees to step
velthe speed at which to move. 0 will use the currently set speed
See also
moveTo
moveVel

◆ moveStepTicks()

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
jointthe joint to move
posthe position, in ticks, to move to
See also
moveStep

◆ moveTo()

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
jointthe joint to move
posthe position in degrees to move to
velthe speed at which to move. 0 will use the currently set speed
See also
moveToTicks
moveVel

◆ moveToTicks()

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
jointthe joint to move
posthe position, in ticks, to move to
See also
moveTo
Examples:
armExample.cpp.

◆ moveVel()

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
jointthe joint to move
velthe velocity to move at

◆ powerOff()

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

◆ powerOn()

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
doSleepif true, sleeps 2 seconds to wait for the arm to stop shaking
Examples:
armExample.cpp.

◆ requestInfo()

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 received.

See also
setPacketCB

◆ requestInit()

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 received. 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

◆ requestStatus()

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 received.

See also
setPacketCB
Examples:
armExample.cpp.

◆ setAutoParkTimer()

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
waitSecsseconds to wait till parking the arm when idle

◆ setGripperParkTimer()

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
waitSecsseconds to wait till parking the gripper once it has begun to grip something

◆ stop()

ArP2Arm::State ArP2Arm::stop ( void  )
virtual

Stop the arm.

Stop the arm from moving.

This overrides all other actions except for the arms initilization sequence.

◆ uninit()

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: