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