kitt_platform
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros
CompressedImage.h
Go to the documentation of this file.
1 #ifndef _ROS_sensor_msgs_CompressedImage_h
2 #define _ROS_sensor_msgs_CompressedImage_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"
9 
10 namespace sensor_msgs
11 {
12 
13  class CompressedImage : public ros::Msg
14  {
15  public:
17  const char* format;
18  uint8_t data_length;
19  uint8_t st_data;
20  uint8_t * data;
21 
23  header(),
24  format(""),
25  data_length(0), data(NULL)
26  {
27  }
28 
29  virtual int serialize(unsigned char *outbuffer) const
30  {
31  int offset = 0;
32  offset += this->header.serialize(outbuffer + offset);
33  uint32_t length_format = strlen(this->format);
34  memcpy(outbuffer + offset, &length_format, sizeof(uint32_t));
35  offset += 4;
36  memcpy(outbuffer + offset, this->format, length_format);
37  offset += length_format;
38  *(outbuffer + offset++) = data_length;
39  *(outbuffer + offset++) = 0;
40  *(outbuffer + offset++) = 0;
41  *(outbuffer + offset++) = 0;
42  for( uint8_t i = 0; i < data_length; i++){
43  *(outbuffer + offset + 0) = (this->data[i] >> (8 * 0)) & 0xFF;
44  offset += sizeof(this->data[i]);
45  }
46  return offset;
47  }
48 
49  virtual int deserialize(unsigned char *inbuffer)
50  {
51  int offset = 0;
52  offset += this->header.deserialize(inbuffer + offset);
53  uint32_t length_format;
54  memcpy(&length_format, (inbuffer + offset), sizeof(uint32_t));
55  offset += 4;
56  for(unsigned int k= offset; k< offset+length_format; ++k){
57  inbuffer[k-1]=inbuffer[k];
58  }
59  inbuffer[offset+length_format-1]=0;
60  this->format = (char *)(inbuffer + offset-1);
61  offset += length_format;
62  uint8_t data_lengthT = *(inbuffer + offset++);
63  if(data_lengthT > data_length)
64  this->data = (uint8_t*)realloc(this->data, data_lengthT * sizeof(uint8_t));
65  offset += 3;
66  data_length = data_lengthT;
67  for( uint8_t i = 0; i < data_length; i++){
68  this->st_data = ((uint8_t) (*(inbuffer + offset)));
69  offset += sizeof(this->st_data);
70  memcpy( &(this->data[i]), &(this->st_data), sizeof(uint8_t));
71  }
72  return offset;
73  }
74 
75  const char * getType(){ return "sensor_msgs/CompressedImage"; };
76  const char * getMD5(){ return "8f7a12909da2c9d3332d540a0977563f"; };
77 
78  };
79 
80 }
81 #endif
virtual int deserialize(unsigned char *inbuffer)
Definition: Header.h:53
const char * getType()
Definition: CompressedImage.h:75
uint8_t data_length
Definition: CompressedImage.h:18
virtual int serialize(unsigned char *outbuffer) const
Definition: Header.h:27
uint8_t * data
Definition: CompressedImage.h:20
Definition: Header.h:13
virtual int serialize(unsigned char *outbuffer) const
Definition: CompressedImage.h:29
Definition: CompressedImage.h:13
const char * format
Definition: CompressedImage.h:17
uint8_t st_data
Definition: CompressedImage.h:19
CompressedImage()
Definition: CompressedImage.h:22
virtual int deserialize(unsigned char *inbuffer)
Definition: CompressedImage.h:49
const char * getMD5()
Definition: CompressedImage.h:76
Definition: msg.h:43
std_msgs::Header header
Definition: CompressedImage.h:16