00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef P2OS_DRIVER__SIP_HPP_
00023 #define P2OS_DRIVER__SIP_HPP_
00024 #include <p2os_driver/p2os.hpp>
00025
00026 #include <climits>
00027 #include <cstdint>
00028 #include <string>
00029
00030 typedef struct ArmJoint
00031 {
00032 char speed;
00033 unsigned char home;
00034 unsigned char min;
00035 unsigned char centre;
00036 unsigned char max;
00037 unsigned char ticksPer90;
00038 } ArmJoint;
00039
00040 enum PlayerGripperStates
00041 {
00042 PLAYER_GRIPPER_STATE_OPEN = 1,
00043 PLAYER_GRIPPER_STATE_CLOSED,
00044 PLAYER_GRIPPER_STATE_MOVING,
00045 PLAYER_GRIPPER_STATE_ERROR
00046 };
00047
00048 enum PlayerActArrayStates
00049 {
00050 PLAYER_ACTARRAY_ACTSTATE_IDLE = 1,
00051 PLAYER_ACTARRAY_ACTSTATE_MOVING,
00052 PLAYER_ACTARRAY_ACTSTATE_STALLED
00053 };
00054
00055 class SIP
00056 {
00057 private:
00058 int PositionChange(uint16_t, uint16_t);
00059 int param_idx;
00060
00061 public:
00062
00063 bool lwstall, rwstall;
00064 unsigned char motors_enabled, sonar_flag;
00065 unsigned char status, battery, sonarreadings, analog, digin, digout;
00066 uint16_t ptu, compass, timer, rawxpos;
00067 uint16_t rawypos, frontbumpers, rearbumpers;
00068 int16_t angle, lvel, rvel, control;
00069 uint16_t * sonars;
00070 int xpos, ypos;
00071 int x_offset, y_offset, angle_offset;
00072 std::string odom_frame_id;
00073 std::string base_link_frame_id;
00074
00075
00076
00077 uint16_t blobmx, blobmy;
00078 uint16_t blobx1, blobx2, bloby1, bloby2;
00079 uint16_t blobarea, blobconf;
00080 unsigned int blobcolor;
00081
00082
00083 int32_t gyro_rate;
00084
00085
00086 bool armPowerOn, armConnected;
00087 bool armJointMoving[6];
00088 unsigned char armJointPos[6];
00089 double armJointPosRads[6];
00090 unsigned char armJointTargetPos[6];
00091 char * armVersionString;
00092 unsigned char armNumJoints;
00093 ArmJoint * armJoints;
00094
00095
00096
00097 double lastLiftPos;
00098
00099
00100
00101
00102
00103 void ParseStandard(unsigned char * buffer);
00104 void ParseSERAUX(unsigned char * buffer);
00105 void ParseGyro(unsigned char * buffer);
00106 void ParseArm(unsigned char * buffer);
00107 void ParseArmInfo(unsigned char * buffer);
00108 void Print();
00109 void PrintSonars();
00110 void PrintArm();
00111 void PrintArmInfo();
00112 void FillStandard(ros_p2os_data_t * data);
00113
00114
00115
00116
00117 explicit SIP(int idx)
00118 : param_idx(idx), sonarreadings(0), sonars(NULL),
00119 xpos(0), ypos(0), x_offset(0), y_offset(0), angle_offset(0),
00120 blobmx(0), blobmy(0), blobx1(0), blobx2(0), bloby1(0), bloby2(0),
00121 blobarea(0), blobconf(0), blobcolor(0),
00122 armPowerOn(false), armConnected(false), armVersionString(NULL),
00123 armNumJoints(0), armJoints(NULL),
00124 lastLiftPos(0.0f)
00125 {
00126 for (int i = 0; i < 6; ++i) {
00127 armJointMoving[i] = false;
00128 armJointPos[i] = 0;
00129 armJointPosRads[i] = 0;
00130 armJointTargetPos[i] = 0;
00131 }
00132 }
00133
00134 ~SIP()
00135 {
00136 delete[] sonars;
00137 }
00138 };
00139
00140 #endif // P2OS_DRIVER__SIP_HPP_