Statistics
| Branch: | Revision:

root / quad2 / arduino / src / ros_lib / std_msgs / MultiArrayDimension.h @ c1426757

History | View | Annotate | Download (2.46 KB)

1
#ifndef _ROS_std_msgs_MultiArrayDimension_h
2
#define _ROS_std_msgs_MultiArrayDimension_h
3

    
4
#include <stdint.h>
5
#include <string.h>
6
#include <stdlib.h>
7
#include "ros/msg.h"
8

    
9
namespace std_msgs
10
{
11

    
12
  class MultiArrayDimension : public ros::Msg
13
  {
14
    public:
15
      char * label;
16
      uint32_t size;
17
      uint32_t stride;
18

    
19
    virtual int serialize(unsigned char *outbuffer) const
20
    {
21
      int offset = 0;
22
      uint32_t * length_label = (uint32_t *)(outbuffer + offset);
23
      *length_label = strlen( (const char*) this->label);
24
      offset += 4;
25
      memcpy(outbuffer + offset, this->label, *length_label);
26
      offset += *length_label;
27
      *(outbuffer + offset + 0) = (this->size >> (8 * 0)) & 0xFF;
28
      *(outbuffer + offset + 1) = (this->size >> (8 * 1)) & 0xFF;
29
      *(outbuffer + offset + 2) = (this->size >> (8 * 2)) & 0xFF;
30
      *(outbuffer + offset + 3) = (this->size >> (8 * 3)) & 0xFF;
31
      offset += sizeof(this->size);
32
      *(outbuffer + offset + 0) = (this->stride >> (8 * 0)) & 0xFF;
33
      *(outbuffer + offset + 1) = (this->stride >> (8 * 1)) & 0xFF;
34
      *(outbuffer + offset + 2) = (this->stride >> (8 * 2)) & 0xFF;
35
      *(outbuffer + offset + 3) = (this->stride >> (8 * 3)) & 0xFF;
36
      offset += sizeof(this->stride);
37
      return offset;
38
    }
39

    
40
    virtual int deserialize(unsigned char *inbuffer)
41
    {
42
      int offset = 0;
43
      uint32_t length_label = *(uint32_t *)(inbuffer + offset);
44
      offset += 4;
45
      for(unsigned int k= offset; k< offset+length_label; ++k){
46
          inbuffer[k-1]=inbuffer[k];
47
      }
48
      inbuffer[offset+length_label-1]=0;
49
      this->label = (char *)(inbuffer + offset-1);
50
      offset += length_label;
51
      this->size |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
52
      this->size |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
53
      this->size |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
54
      this->size |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
55
      offset += sizeof(this->size);
56
      this->stride |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
57
      this->stride |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
58
      this->stride |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
59
      this->stride |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
60
      offset += sizeof(this->stride);
61
     return offset;
62
    }
63

    
64
    const char * getType(){ return "std_msgs/MultiArrayDimension"; };
65
    const char * getMD5(){ return "4cd0c83a8683deae40ecdac60e53bfa8"; };
66

    
67
  };
68

    
69
}
70
#endif