root / quad2 / arduino / src / ros_lib / std_msgs / MultiArrayLayout.h @ c1426757
History | View | Annotate | Download (2.18 KB)
1 | c1426757 | Tom Mullins | #ifndef _ROS_std_msgs_MultiArrayLayout_h
|
---|---|---|---|
2 | #define _ROS_std_msgs_MultiArrayLayout_h
|
||
3 | |||
4 | #include <stdint.h> |
||
5 | #include <string.h> |
||
6 | #include <stdlib.h> |
||
7 | #include "ros/msg.h" |
||
8 | #include "std_msgs/MultiArrayDimension.h" |
||
9 | |||
10 | namespace std_msgs |
||
11 | { |
||
12 | |||
13 | class MultiArrayLayout : public ros::Msg |
||
14 | { |
||
15 | public:
|
||
16 | uint8_t dim_length; |
||
17 | std_msgs::MultiArrayDimension st_dim; |
||
18 | std_msgs::MultiArrayDimension * dim; |
||
19 | uint32_t data_offset; |
||
20 | |||
21 | virtual int serialize(unsigned char *outbuffer) const |
||
22 | { |
||
23 | int offset = 0; |
||
24 | *(outbuffer + offset++) = dim_length; |
||
25 | *(outbuffer + offset++) = 0;
|
||
26 | *(outbuffer + offset++) = 0;
|
||
27 | *(outbuffer + offset++) = 0;
|
||
28 | for( uint8_t i = 0; i < dim_length; i++){ |
||
29 | offset += this->dim[i].serialize(outbuffer + offset); |
||
30 | } |
||
31 | *(outbuffer + offset + 0) = (this->data_offset >> (8 * 0)) & 0xFF; |
||
32 | *(outbuffer + offset + 1) = (this->data_offset >> (8 * 1)) & 0xFF; |
||
33 | *(outbuffer + offset + 2) = (this->data_offset >> (8 * 2)) & 0xFF; |
||
34 | *(outbuffer + offset + 3) = (this->data_offset >> (8 * 3)) & 0xFF; |
||
35 | offset += sizeof(this->data_offset);
|
||
36 | return offset;
|
||
37 | } |
||
38 | |||
39 | virtual int deserialize(unsigned char *inbuffer) |
||
40 | { |
||
41 | int offset = 0; |
||
42 | uint8_t dim_lengthT = *(inbuffer + offset++); |
||
43 | if(dim_lengthT > dim_length)
|
||
44 | this->dim = (std_msgs::MultiArrayDimension*)realloc(this->dim, dim_lengthT * sizeof(std_msgs::MultiArrayDimension));
|
||
45 | offset += 3;
|
||
46 | dim_length = dim_lengthT; |
||
47 | for( uint8_t i = 0; i < dim_length; i++){ |
||
48 | offset += this->st_dim.deserialize(inbuffer + offset); |
||
49 | memcpy( &(this->dim[i]), &(this->st_dim), sizeof(std_msgs::MultiArrayDimension));
|
||
50 | } |
||
51 | this->data_offset |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
||
52 | this->data_offset |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
||
53 | this->data_offset |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
||
54 | this->data_offset |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
||
55 | offset += sizeof(this->data_offset);
|
||
56 | return offset;
|
||
57 | } |
||
58 | |||
59 | const char * getType(){ return "std_msgs/MultiArrayLayout"; }; |
||
60 | const char * getMD5(){ return "0fed2a11c13e11c5571b4e2a995a91a3"; }; |
||
61 | |||
62 | }; |
||
63 | |||
64 | } |
||
65 | #endif |