kitt_platform
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros
CameraInfo.h
Go to the documentation of this file.
1 #ifndef _ROS_sensor_msgs_CameraInfo_h
2 #define _ROS_sensor_msgs_CameraInfo_h
3 
4 #include <stdint.h>
5 #include <string.h>
6 #include <stdlib.h>
7 #include "ros/msg.h"
8 #include "std_msgs/Header.h"
10 
11 namespace sensor_msgs
12 {
13 
14  class CameraInfo : public ros::Msg
15  {
16  public:
18  uint32_t height;
19  uint32_t width;
20  const char* distortion_model;
21  uint8_t D_length;
22  float st_D;
23  float * D;
24  float K[9];
25  float R[9];
26  float P[12];
27  uint32_t binning_x;
28  uint32_t binning_y;
30 
32  header(),
33  height(0),
34  width(0),
35  distortion_model(""),
36  D_length(0), D(NULL),
37  K(),
38  R(),
39  P(),
40  binning_x(0),
41  binning_y(0),
42  roi()
43  {
44  }
45 
46  virtual int serialize(unsigned char *outbuffer) const
47  {
48  int offset = 0;
49  offset += this->header.serialize(outbuffer + offset);
50  *(outbuffer + offset + 0) = (this->height >> (8 * 0)) & 0xFF;
51  *(outbuffer + offset + 1) = (this->height >> (8 * 1)) & 0xFF;
52  *(outbuffer + offset + 2) = (this->height >> (8 * 2)) & 0xFF;
53  *(outbuffer + offset + 3) = (this->height >> (8 * 3)) & 0xFF;
54  offset += sizeof(this->height);
55  *(outbuffer + offset + 0) = (this->width >> (8 * 0)) & 0xFF;
56  *(outbuffer + offset + 1) = (this->width >> (8 * 1)) & 0xFF;
57  *(outbuffer + offset + 2) = (this->width >> (8 * 2)) & 0xFF;
58  *(outbuffer + offset + 3) = (this->width >> (8 * 3)) & 0xFF;
59  offset += sizeof(this->width);
60  uint32_t length_distortion_model = strlen(this->distortion_model);
61  memcpy(outbuffer + offset, &length_distortion_model, sizeof(uint32_t));
62  offset += 4;
63  memcpy(outbuffer + offset, this->distortion_model, length_distortion_model);
64  offset += length_distortion_model;
65  *(outbuffer + offset++) = D_length;
66  *(outbuffer + offset++) = 0;
67  *(outbuffer + offset++) = 0;
68  *(outbuffer + offset++) = 0;
69  for( uint8_t i = 0; i < D_length; i++){
70  offset += serializeAvrFloat64(outbuffer + offset, this->D[i]);
71  }
72  for( uint8_t i = 0; i < 9; i++){
73  offset += serializeAvrFloat64(outbuffer + offset, this->K[i]);
74  }
75  for( uint8_t i = 0; i < 9; i++){
76  offset += serializeAvrFloat64(outbuffer + offset, this->R[i]);
77  }
78  for( uint8_t i = 0; i < 12; i++){
79  offset += serializeAvrFloat64(outbuffer + offset, this->P[i]);
80  }
81  *(outbuffer + offset + 0) = (this->binning_x >> (8 * 0)) & 0xFF;
82  *(outbuffer + offset + 1) = (this->binning_x >> (8 * 1)) & 0xFF;
83  *(outbuffer + offset + 2) = (this->binning_x >> (8 * 2)) & 0xFF;
84  *(outbuffer + offset + 3) = (this->binning_x >> (8 * 3)) & 0xFF;
85  offset += sizeof(this->binning_x);
86  *(outbuffer + offset + 0) = (this->binning_y >> (8 * 0)) & 0xFF;
87  *(outbuffer + offset + 1) = (this->binning_y >> (8 * 1)) & 0xFF;
88  *(outbuffer + offset + 2) = (this->binning_y >> (8 * 2)) & 0xFF;
89  *(outbuffer + offset + 3) = (this->binning_y >> (8 * 3)) & 0xFF;
90  offset += sizeof(this->binning_y);
91  offset += this->roi.serialize(outbuffer + offset);
92  return offset;
93  }
94 
95  virtual int deserialize(unsigned char *inbuffer)
96  {
97  int offset = 0;
98  offset += this->header.deserialize(inbuffer + offset);
99  this->height = ((uint32_t) (*(inbuffer + offset)));
100  this->height |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
101  this->height |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
102  this->height |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
103  offset += sizeof(this->height);
104  this->width = ((uint32_t) (*(inbuffer + offset)));
105  this->width |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
106  this->width |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
107  this->width |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
108  offset += sizeof(this->width);
109  uint32_t length_distortion_model;
110  memcpy(&length_distortion_model, (inbuffer + offset), sizeof(uint32_t));
111  offset += 4;
112  for(unsigned int k= offset; k< offset+length_distortion_model; ++k){
113  inbuffer[k-1]=inbuffer[k];
114  }
115  inbuffer[offset+length_distortion_model-1]=0;
116  this->distortion_model = (char *)(inbuffer + offset-1);
117  offset += length_distortion_model;
118  uint8_t D_lengthT = *(inbuffer + offset++);
119  if(D_lengthT > D_length)
120  this->D = (float*)realloc(this->D, D_lengthT * sizeof(float));
121  offset += 3;
122  D_length = D_lengthT;
123  for( uint8_t i = 0; i < D_length; i++){
124  offset += deserializeAvrFloat64(inbuffer + offset, &(this->st_D));
125  memcpy( &(this->D[i]), &(this->st_D), sizeof(float));
126  }
127  for( uint8_t i = 0; i < 9; i++){
128  offset += deserializeAvrFloat64(inbuffer + offset, &(this->K[i]));
129  }
130  for( uint8_t i = 0; i < 9; i++){
131  offset += deserializeAvrFloat64(inbuffer + offset, &(this->R[i]));
132  }
133  for( uint8_t i = 0; i < 12; i++){
134  offset += deserializeAvrFloat64(inbuffer + offset, &(this->P[i]));
135  }
136  this->binning_x = ((uint32_t) (*(inbuffer + offset)));
137  this->binning_x |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
138  this->binning_x |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
139  this->binning_x |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
140  offset += sizeof(this->binning_x);
141  this->binning_y = ((uint32_t) (*(inbuffer + offset)));
142  this->binning_y |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
143  this->binning_y |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
144  this->binning_y |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
145  offset += sizeof(this->binning_y);
146  offset += this->roi.deserialize(inbuffer + offset);
147  return offset;
148  }
149 
150  const char * getType(){ return "sensor_msgs/CameraInfo"; };
151  const char * getMD5(){ return "c9a58c1b0b154e0e6da7578cb991d214"; };
152 
153  };
154 
155 }
156 #endif
Definition: CameraInfo.h:14
CameraInfo()
Definition: CameraInfo.h:31
const char * getType()
Definition: CameraInfo.h:150
virtual int deserialize(unsigned char *inbuffer)
Definition: Header.h:53
static int serializeAvrFloat64(unsigned char *outbuffer, const float f)
This tricky function handles promoting a 32bit float to a 64bit double, so that AVR can publish messa...
Definition: msg.h:62
uint32_t binning_y
Definition: CameraInfo.h:28
uint32_t width
Definition: CameraInfo.h:19
float P[12]
Definition: CameraInfo.h:26
uint32_t binning_x
Definition: CameraInfo.h:27
virtual int deserialize(unsigned char *inbuffer)
Definition: RegionOfInterest.h:63
virtual int deserialize(unsigned char *inbuffer)
Definition: CameraInfo.h:95
std_msgs::Header header
Definition: CameraInfo.h:17
const char * distortion_model
Definition: CameraInfo.h:20
virtual int serialize(unsigned char *outbuffer) const
Definition: Header.h:27
virtual int serialize(unsigned char *outbuffer) const
Definition: CameraInfo.h:46
uint8_t D_length
Definition: CameraInfo.h:21
float st_D
Definition: CameraInfo.h:22
Definition: RegionOfInterest.h:12
float R[9]
Definition: CameraInfo.h:25
sensor_msgs::RegionOfInterest roi
Definition: CameraInfo.h:29
Definition: Header.h:13
float * D
Definition: CameraInfo.h:23
uint32_t height
Definition: CameraInfo.h:18
virtual int serialize(unsigned char *outbuffer) const
Definition: RegionOfInterest.h:30
Definition: msg.h:43
static int deserializeAvrFloat64(const unsigned char *inbuffer, float *f)
This tricky function handles demoting a 64bit double to a 32bit float, so that AVR can understand mes...
Definition: msg.h:100
float K[9]
Definition: CameraInfo.h:24
const char * getMD5()
Definition: CameraInfo.h:151