Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef CONTROLALLEGROHAND_H_
00009 #define CONTROLALLEGROHAND_H_
00010
00011 #include <list>
00012 #include "BHand/BHand.h"
00013 #include "allgroCANProtocol.h"
00014 #include <libpcan.h>
00015 #include <fcntl.h>
00016
00017 #define ALLEGRO_CONTROL_TIME_INTERVAL 0.003
00018
00019 #define PWM_LIMIT_ROLL 250.0*1.5
00020 #define PWM_LIMIT_NEAR 450.0*1.5
00021 #define PWM_LIMIT_MIDDLE 300.0*1.5
00022 #define PWM_LIMIT_FAR 190.0*1.5
00023
00024 #define PWM_LIMIT_THUMB_ROLL 350.0*1.5
00025 #define PWM_LIMIT_THUMB_NEAR 270.0*1.5
00026 #define PWM_LIMIT_THUMB_MIDDLE 180.0*1.5
00027 #define PWM_LIMIT_THUMB_FAR 180.0*1.5
00028
00029 class controlAllegroHand
00030 {
00031 public:
00032 controlAllegroHand();
00033 ~controlAllegroHand();
00034
00035 void init(int mode = 0);
00036 int update(void);
00037 int command(const short& cmd, const int& arg = 0);
00038
00039 void setTorque(double *torque);
00040 void getJointInfo(double *position, double *torque);
00041
00042 private:
00043 HANDLE CanHandle;
00044
00045 TPCANRdMsg read_msg;
00046
00047 double curr_position[DOF_JOINTS];
00048 double curr_torque[DOF_JOINTS];
00049 double desired_position[DOF_JOINTS];
00050 double desired_torque[DOF_JOINTS];
00051
00052 double mPWM_MAX[DOF_JOINTS];
00053 int mEncoderOffset[DOF_JOINTS];
00054 int mEncoderDirection[DOF_JOINTS];
00055 int mMotorDirection[DOF_JOINTS];
00056
00057 volatile bool mEmergencyStop;
00058
00059 void _readDevices();
00060 DWORD _readDevicesCAN(unsigned char& id, double *position );
00061 void _writeDevices();
00062 void _parseCANMsg();
00063
00064 void _writeDeviceMsg(unsigned long command, unsigned long from, unsigned long to, BYTE len, unsigned char *data);
00065 void _writeDeviceMsg(unsigned long command, unsigned long from, unsigned long to);
00066 char _parseCANMsg(TPCANMsg &read_msg, double *values);
00067
00068 };
00069
00070
00071 #endif