sip.h
Go to the documentation of this file.
1 /*
2  * P2OS for ROS
3  * Copyright (C) 2009
4  * David Feil-Seifer, Brian Gerkey, Kasper Stoy,
5  * Richard Vaughan, & Andrew Howard
6  *
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  *
22  */
23 
24 #ifndef _SIP_H
25 #define _SIP_H
26 
27 #include <limits.h>
28 #include <stdint.h>
29 #include <p2os_driver/p2os.h>
30 
31 typedef struct ArmJoint
32 {
33  char speed;
34  unsigned char home;
35  unsigned char min;
36  unsigned char centre;
37  unsigned char max;
38  unsigned char ticksPer90;
39 } ArmJoint;
40 
46 };
47 
52 };
53 
54 class SIP
55 {
56  private:
57  int PositionChange( unsigned short, unsigned short );
58  int param_idx; // index of our robot's data in the parameter table
59 
60  public:
61  // these values are returned in every standard SIP
63  unsigned char motors_enabled, sonar_flag;
65  unsigned short ptu, compass, timer, rawxpos;
66  unsigned short rawypos, frontbumpers, rearbumpers;
67  short angle, lvel, rvel, control;
68  unsigned short *sonars;
69  int xpos, ypos;
71 
72  // these values are returned in a CMUcam serial string extended SIP
73  // (in host byte-order)
74  unsigned short blobmx, blobmy; // Centroid
75  unsigned short blobx1, blobx2, bloby1, bloby2; // Bounding box
76  unsigned short blobarea, blobconf; // Area and confidence
77  unsigned int blobcolor;
78 
79  // This value is filled by ParseGyro()
80  int32_t gyro_rate;
81 
82  // This information comes from the ARMpac and ARMINFOpac packets
84  bool armJointMoving[6];
85  unsigned char armJointPos[6];
86  double armJointPosRads[6];
87  unsigned char armJointTargetPos[6];
89  unsigned char armNumJoints;
91 
92  // Need this value to calculate approx position of lift when in between up
93  // and down
94  double lastLiftPos;
95 
96  //Timestamping SIP packets
97  //double timeStandardSIP, timeGyro, timeSERAUX, timeArm;
98 
99  /* returns 0 if Parsed correctly otherwise 1 */
100  void ParseStandard( unsigned char *buffer );
101  void ParseSERAUX( unsigned char *buffer );
102  void ParseGyro(unsigned char* buffer);
103  void ParseArm (unsigned char *buffer);
104  void ParseArmInfo (unsigned char *buffer);
105  void Print();
106  void PrintSonars();
107  void PrintArm ();
108  void PrintArmInfo ();
109  void FillStandard(ros_p2os_data_t* data);
110  //void FillSERAUX(player_p2os_data_t* data);
111  //void FillGyro(player_p2os_data_t* data);
112  //void FillArm(player_p2os_data_t* data);
113 
114  SIP(int idx) :
115  param_idx(idx), sonarreadings(0), sonars(NULL),
116  xpos(0), ypos(0), x_offset(0), y_offset(0), angle_offset(0),
117  blobmx(0), blobmy(0), blobx1(0), blobx2(0), bloby1(0), bloby2(0),
118  blobarea(0), blobconf(0), blobcolor(0),
119  armPowerOn(false), armConnected(false), armVersionString(NULL),
120  armNumJoints(0), armJoints(NULL),
121  lastLiftPos(0.0f)
122  {
123  for (int i = 0; i < 6; ++i)
124  {
125  armJointMoving[i] = false;
126  armJointPos[i] = 0;
127  armJointPosRads[i] = 0;
128  armJointTargetPos[i] = 0;
129  }
130  }
131 
132  ~SIP(void)
133  {
134  delete[] sonars;
135  }
136 };
137 
138 #endif
unsigned char armJointPos[6]
Definition: sip.h:85
Container struct.
Definition: p2os.h:54
bool rwstall
Definition: sip.h:62
unsigned short blobx1
Definition: sip.h:75
unsigned short compass
Definition: sip.h:65
unsigned short blobmy
Definition: sip.h:74
unsigned char centre
Definition: sip.h:36
int xpos
Definition: sip.h:69
char * armVersionString
Definition: sip.h:88
double lastLiftPos
Definition: sip.h:94
unsigned char status
Definition: sip.h:64
void ParseGyro(unsigned char *buffer)
Definition: sip.cc:567
unsigned short blobmx
Definition: sip.h:74
void ParseArmInfo(unsigned char *buffer)
Definition: sip.cc:667
unsigned char sonar_flag
Definition: sip.h:63
unsigned char home
Definition: sip.h:34
unsigned char digout
Definition: sip.h:64
short control
Definition: sip.h:67
short lvel
Definition: sip.h:67
void Print()
Definition: sip.cc:272
unsigned short bloby1
Definition: sip.h:75
unsigned char motors_enabled
Definition: sip.h:63
unsigned short rawxpos
Definition: sip.h:65
ArmJoint * armJoints
Definition: sip.h:90
void ParseSERAUX(unsigned char *buffer)
Definition: sip.cc:500
short rvel
Definition: sip.h:67
unsigned char analog
Definition: sip.h:64
void ParseStandard(unsigned char *buffer)
Definition: sip.cc:349
void PrintArm()
Definition: sip.cc:332
unsigned char sonarreadings
Definition: sip.h:64
SIP(int idx)
Definition: sip.h:114
short angle
Definition: sip.h:67
unsigned short rawypos
Definition: sip.h:66
int ypos
Definition: sip.h:69
char speed
Definition: sip.h:33
int param_idx
Definition: sip.h:58
int32_t gyro_rate
Definition: sip.h:80
int PositionChange(unsigned short, unsigned short)
Definition: sip.cc:251
unsigned short timer
Definition: sip.h:65
PlayerGripperStates
Definition: sip.h:41
unsigned char max
Definition: sip.h:37
unsigned short blobconf
Definition: sip.h:76
int y_offset
Definition: sip.h:70
unsigned short frontbumpers
Definition: sip.h:66
unsigned char ticksPer90
Definition: sip.h:38
void FillStandard(ros_p2os_data_t *data)
Definition: sip.cc:38
Definition: sip.h:54
unsigned short blobarea
Definition: sip.h:76
unsigned char min
Definition: sip.h:35
struct ArmJoint ArmJoint
void PrintSonars()
Definition: sip.cc:321
PlayerActArrayStates
Definition: sip.h:48
unsigned char battery
Definition: sip.h:64
bool lwstall
Definition: sip.h:62
Definition: sip.h:31
unsigned char armNumJoints
Definition: sip.h:89
bool armConnected
Definition: sip.h:83
bool armPowerOn
Definition: sip.h:83
bool armJointMoving[6]
Definition: sip.h:84
~SIP(void)
Definition: sip.h:132
unsigned short ptu
Definition: sip.h:65
int x_offset
Definition: sip.h:70
unsigned char armJointTargetPos[6]
Definition: sip.h:87
int angle_offset
Definition: sip.h:70
unsigned int blobcolor
Definition: sip.h:77
void ParseArm(unsigned char *buffer)
Definition: sip.cc:622
void PrintArmInfo()
Definition: sip.cc:340
unsigned short blobx2
Definition: sip.h:75
unsigned short rearbumpers
Definition: sip.h:66
unsigned short * sonars
Definition: sip.h:68
unsigned char digin
Definition: sip.h:64
unsigned short bloby2
Definition: sip.h:75
double armJointPosRads[6]
Definition: sip.h:86


p2os_driver
Author(s): Hunter Allen , David Feil-Seifer , Aris Synodinos , Brian Gerkey, Kasper Stoy, Richard Vaughan, Andrew Howard, Tucker Hermans, ActivMedia Robotics LLC, MobileRobots Inc.
autogenerated on Wed Jun 25 2014 09:37:15