ScorbotInterface.H
00001 #ifndef ROBOTS_SCORBOT_INTERFACE_H
00002 #define ROBOTS_SCORBOT_INTERFACE_H
00003
00004 #include "Component/ModelComponent.H"
00005 #include "Devices/Serial.H"
00006 #include <pthread.h>
00007 #include <map>
00008
00009 class ScorbotInterface : public ModelComponent
00010 {
00011 public:
00012
00013 enum Joint_t {Base=0, Shoulder=1, Elbow=2, Wrist1=3, Wrist2=4, Gripper=5, Slider=6};
00014 typedef std::map<Joint_t, int32> encoderVals_t;
00015 typedef std::map<Joint_t, float> pwmVals_t;
00016
00017 ScorbotInterface(OptionManager& mgr,
00018 const std::string& descrName = "ScorbotInterface",
00019 const std::string& tagName = "ScorbotInterface");
00020
00021
00022 ~ScorbotInterface();
00023
00024
00025 void start2();
00026
00027
00028 void setJoint(Joint_t joint, int32 encoderPos, int32 time_ms);
00029
00030
00031
00032 void setJoints(encoderVals_t pos, int32 time_ms);
00033
00034
00035 int32 getEncoder(Joint_t joint);
00036
00037
00038 encoderVals_t getEncoders();
00039
00040
00041 void setEnabled(bool enabled);
00042
00043
00044 void resetEncoders();
00045
00046
00047 float getPWM(Joint_t joint);
00048
00049
00050 pwmVals_t getPWMs();
00051
00052
00053 void setControlParams(Joint_t joint,
00054 float pGain, float iGain, float dGain, float maxI, float maxPWM, float pwmOffset);
00055
00056
00057 void getPIDVals(Joint_t joint,
00058 float &pGain, float &iGain, float &dGain, float &maxI, float &maxPWM, float &pwmOffset);
00059
00060
00061 void getTuningVals(Joint_t joint,
00062 int32 &targetPos, int32 &targetVel, float& gravityCompensation);
00063
00064
00065 void setGravityParameters(int32 upperArmMass, int32 foreArmMass, float compensationScale);
00066
00067
00068 void getGravityParameters(int32 &upperArmMass, int32 &foreArmMass, float &compensationScale);
00069
00070 private:
00071 nub::soft_ref<Serial> itsSerial;
00072 pthread_mutex_t itsSerialMutex;
00073 };
00074
00075 #endif // ROBOTS_SCORBOT_INTERFACE_H
00076