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


p2os_driver
Author(s): Hunter L. Allen , David Feil-Seifer , Aris Synodinos , Brian Gerkey, Kasper Stoy, Richard Vaughan, Andrew Howard, Tucker Hermans, ActivMedia Robotics LLC, MobileRobots Inc.
autogenerated on Sat Jun 20 2020 03:29:42