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

ArP2Arm.h

00001 /*
00002 MobileRobots Advanced Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004, 2005 ActivMedia Robotics LLC
00004 Copyright (C) 2006, 2007 MobileRobots Inc.
00005 
00006      This program is free software; you can redistribute it and/or modify
00007      it under the terms of the GNU General Public License as published by
00008      the Free Software Foundation; either version 2 of the License, or
00009      (at your option) any later version.
00010 
00011      This program is distributed in the hope that it will be useful,
00012      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014      GNU General Public License for more details.
00015 
00016      You should have received a copy of the GNU General Public License
00017      along with this program; if not, write to the Free Software
00018      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 If you wish to redistribute ARIA under different terms, contact 
00021 MobileRobots for information about a commercial version of ARIA at 
00022 robots@mobilerobots.com or 
00023 MobileRobots Inc, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
00024 */
00025 
00026 #ifndef ARP2ARM_H
00027 #define ARP2ARM_H
00028 
00029 #include "ArRobot.h"
00030 #include "ariaTypedefs.h"
00031 #include "ArSerialConnection.h"
00032 #include "ariaOSDef.h"
00033 
00034 // P2 Arm classes: ArP2Arm for control and ArP2ArmJoints for P2 Arm joint data
00035 
00037 class P2ArmJoint
00038 {
00039 public:
00040 
00041   AREXPORT P2ArmJoint();
00042   AREXPORT virtual ~P2ArmJoint();
00043 
00044   ArTypes::UByte myPos;
00045   ArTypes::UByte myVel;
00046   ArTypes::UByte myHome;
00047   ArTypes::UByte myMin;
00048   ArTypes::UByte myCenter;
00049   ArTypes::UByte myMax;
00050   ArTypes::UByte myTicksPer90;
00051 };
00052 
00072 
00073 class ArP2Arm
00074 {
00075 public:
00076 
00078   typedef enum {
00079     SUCCESS, 
00080     ALREADY_INITED, 
00081     NOT_INITED, 
00082     ROBOT_NOT_SETUP, 
00083     NO_ARM_FOUND, 
00084     COMM_FAILED, 
00085     COULD_NOT_OPEN_PORT, 
00086     COULD_NOT_SET_UP_PORT, 
00087     ALREADY_CONNECTED, 
00088     NOT_CONNECTED, 
00089     INVALID_JOINT, 
00090     INVALID_POSITION 
00091     } State;
00092 
00094   typedef enum {
00095     StatusPacket, 
00096     InfoPacket 
00097   } PacketType;
00098 
00100   typedef enum
00101   {
00102     StatusOff=0, 
00103     StatusSingle=1, 
00104     StatusContinuous=2 
00105   } StatusType;
00106 
00108   AREXPORT static const int ArmJoint1;
00110   AREXPORT static const int ArmJoint2;
00112   AREXPORT static const int ArmJoint3;
00114   AREXPORT static const int ArmJoint4;
00116   AREXPORT static const int ArmJoint5;
00118   AREXPORT static const int ArmJoint6;
00120   AREXPORT static const int ArmGood;
00122   AREXPORT static const int ArmInited;
00124   AREXPORT static const int ArmPower;
00126   AREXPORT static const int ArmHoming;
00128   AREXPORT static int NumJoints;
00129 
00131   AREXPORT ArP2Arm();
00132 
00134   AREXPORT virtual ~ArP2Arm();
00135 
00137   AREXPORT void setRobot(ArRobot *robot) {myRobot=robot;}
00138 
00140   AREXPORT virtual State init();
00141 
00143   AREXPORT virtual State uninit();
00144 
00146   AREXPORT virtual State powerOn(bool doWait=true);
00147 
00149   AREXPORT virtual State powerOff();
00150 
00152   AREXPORT virtual State requestInfo();
00153 
00155   AREXPORT virtual State requestStatus(StatusType status);
00156 
00158   AREXPORT virtual State requestInit();
00159 
00161   AREXPORT virtual State checkArm(bool waitForResponse=true);
00162 
00164   AREXPORT virtual State home(int joint=-1);
00165 
00167   AREXPORT virtual State park();
00168 
00170   AREXPORT virtual State moveTo(int joint, float pos, unsigned char vel=0);
00171 
00173   AREXPORT virtual State moveToTicks(int joint, unsigned char pos);
00174 
00176   AREXPORT virtual State moveStep(int joint, float pos, unsigned char vel=0);
00177 
00179   AREXPORT virtual State moveStepTicks(int joint, signed char pos);
00180 
00182   AREXPORT virtual State moveVel(int joint, int vel);
00183 
00185   AREXPORT virtual State stop();
00186 
00188   AREXPORT virtual State setAutoParkTimer(int waitSecs);
00189 
00191   AREXPORT virtual State setGripperParkTimer(int waitSecs);
00192 
00194   AREXPORT virtual void setStoppedCB(ArFunctor *func) {myStoppedCB=func;}
00195 
00197   AREXPORT virtual void setPacketCB(ArFunctor1<PacketType> *func)
00198     {myPacketCB=func;}
00199 
00201   AREXPORT virtual std::string getArmVersion() {return(myVersion);}
00202 
00204   AREXPORT virtual float getJointPos(int joint);
00205 
00207   AREXPORT virtual unsigned char getJointPosTicks(int joint);
00208 
00210   AREXPORT virtual bool getMoving(int joint=-1);
00211 
00213   AREXPORT virtual bool isPowered();
00214 
00216   AREXPORT virtual bool isGood();
00217 
00219   AREXPORT virtual int getStatus() {return(myStatus);}
00220 
00222   AREXPORT virtual ArTime getLastStatusTime() {return(myLastStatusTime);}
00223 
00225   AREXPORT virtual ArRobot * getRobot() {return(myRobot);}
00226 
00228   AREXPORT virtual P2ArmJoint * getJoint(int joint);
00229 
00231   AREXPORT virtual bool convertDegToTicks(int joint, float pos,
00232                       unsigned char *ticks);
00233 
00235   AREXPORT virtual bool convertTicksToDeg(int joint, unsigned char pos,
00236                       float *degrees);
00237 
00238 
00239 protected:
00240 
00241   // AROS/P2OS parameters
00242   static const unsigned int ARMpac;
00243   static const unsigned int ARMINFOpac;
00244   static const unsigned char ComArmInfo;
00245   static const unsigned char ComArmStats;
00246   static const unsigned char ComArmInit;
00247   static const unsigned char ComArmCheckArm;
00248   static const unsigned char ComArmPower;
00249   static const unsigned char ComArmHome;
00250   static const unsigned char ComArmPark;
00251   static const unsigned char ComArmPos;
00252   static const unsigned char ComArmSpeed;
00253   static const unsigned char ComArmStop;
00254   static const unsigned char ComArmAutoPark;
00255   static const unsigned char ComArmGripperPark;
00256 
00257   bool comArmInfo();
00258   bool comArmStats(StatusType stats=StatusSingle);
00259   bool comArmInit();
00260   bool comArmCheckArm();
00261   bool comArmPower(bool on);
00262   bool comArmHome(unsigned char joint=0xff);
00263   bool comArmPark();
00264   bool comArmPos(unsigned char joint, unsigned char pos);
00265   bool comArmSpeed(unsigned char joint, unsigned char speed);
00266   bool comArmStop(unsigned char joint=0xff);
00267   bool comArmAutoPark(int waitSecs);
00268   bool comArmGripperPark(int waitSecs);
00269 
00270   bool armPacketHandler(ArRobotPacket *packet);
00271 
00272   bool myInited;
00273   ArRobot *myRobot;
00274   //  ArmP2Model myModel;
00275   ArTime myLastStatusTime;
00276   ArTime myLastInfoTime;
00277   std::string myVersion;
00278   StatusType myStatusRequest;
00279   ArTypes::UByte2 myLastStatus;
00280   ArTypes::UByte2 myStatus;
00281   ArSerialConnection myCon;
00282   ArRetFunctorC<State, ArP2Arm> myAriaUninitCB;
00283   ArRetFunctor1C<bool, ArP2Arm, ArRobotPacket*> myArmPacketHandler;
00284   ArFunctor1<PacketType> *myPacketCB;
00285   ArFunctor *myStoppedCB;
00286 
00287   // We have 6 joints. Including the gripper. It's here so that we can
00288   // store its position even though its not really a joint.
00289   P2ArmJoint myJoints[6];
00290 };
00291 
00292 #endif // _ARP2ARM_H

Generated on Tue Feb 20 10:51:40 2007 for Aria by  doxygen 1.4.0