root / quad2 / arduino / src / ros_lib / nav_msgs / OccupancyGrid.h @ c1426757
History | View | Annotate | Download (2.03 KB)
1 | c1426757 | Tom Mullins | #ifndef _ROS_nav_msgs_OccupancyGrid_h
|
---|---|---|---|
2 | #define _ROS_nav_msgs_OccupancyGrid_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 | #include "nav_msgs/MapMetaData.h" |
||
10 | |||
11 | namespace nav_msgs |
||
12 | { |
||
13 | |||
14 | class OccupancyGrid : public ros::Msg |
||
15 | { |
||
16 | public:
|
||
17 | std_msgs::Header header; |
||
18 | nav_msgs::MapMetaData info; |
||
19 | uint8_t data_length; |
||
20 | int8_t st_data; |
||
21 | int8_t * data; |
||
22 | |||
23 | virtual int serialize(unsigned char *outbuffer) const |
||
24 | { |
||
25 | int offset = 0; |
||
26 | offset += this->header.serialize(outbuffer + offset); |
||
27 | offset += this->info.serialize(outbuffer + offset); |
||
28 | *(outbuffer + offset++) = data_length; |
||
29 | *(outbuffer + offset++) = 0;
|
||
30 | *(outbuffer + offset++) = 0;
|
||
31 | *(outbuffer + offset++) = 0;
|
||
32 | for( uint8_t i = 0; i < data_length; i++){ |
||
33 | union {
|
||
34 | int8_t real; |
||
35 | uint8_t base; |
||
36 | } u_datai; |
||
37 | u_datai.real = this->data[i]; |
||
38 | *(outbuffer + offset + 0) = (u_datai.base >> (8 * 0)) & 0xFF; |
||
39 | offset += sizeof(this->data[i]);
|
||
40 | } |
||
41 | return offset;
|
||
42 | } |
||
43 | |||
44 | virtual int deserialize(unsigned char *inbuffer) |
||
45 | { |
||
46 | int offset = 0; |
||
47 | offset += this->header.deserialize(inbuffer + offset); |
||
48 | offset += this->info.deserialize(inbuffer + offset); |
||
49 | uint8_t data_lengthT = *(inbuffer + offset++); |
||
50 | if(data_lengthT > data_length)
|
||
51 | this->data = (int8_t*)realloc(this->data, data_lengthT * sizeof(int8_t));
|
||
52 | offset += 3;
|
||
53 | data_length = data_lengthT; |
||
54 | for( uint8_t i = 0; i < data_length; i++){ |
||
55 | union {
|
||
56 | int8_t real; |
||
57 | uint8_t base; |
||
58 | } u_st_data; |
||
59 | u_st_data.base = 0;
|
||
60 | u_st_data.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); |
||
61 | this->st_data = u_st_data.real; |
||
62 | offset += sizeof(this->st_data);
|
||
63 | memcpy( &(this->data[i]), &(this->st_data), sizeof(int8_t));
|
||
64 | } |
||
65 | return offset;
|
||
66 | } |
||
67 | |||
68 | const char * getType(){ return "nav_msgs/OccupancyGrid"; }; |
||
69 | const char * getMD5(){ return "3381f2d731d4076ec5c71b0759edbe4e"; }; |
||
70 | |||
71 | }; |
||
72 | |||
73 | } |
||
74 | #endif |