It has only one change from original one. I added robotfeedback message on it.
Dependents: RobotFeedback mobileRobotITU
Fork of ros_lib_indigo by
map_msgs/OccupancyGridUpdate.h@4:80d9bee5079a, 2017-03-04 (annotated)
- Committer:
- randalthor
- Date:
- Sat Mar 04 14:07:56 2017 +0000
- Revision:
- 4:80d9bee5079a
- Parent:
- 0:fd24f7ca9688
fatih
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
garyservin | 0:fd24f7ca9688 | 1 | #ifndef _ROS_map_msgs_OccupancyGridUpdate_h |
garyservin | 0:fd24f7ca9688 | 2 | #define _ROS_map_msgs_OccupancyGridUpdate_h |
garyservin | 0:fd24f7ca9688 | 3 | |
garyservin | 0:fd24f7ca9688 | 4 | #include <stdint.h> |
garyservin | 0:fd24f7ca9688 | 5 | #include <string.h> |
garyservin | 0:fd24f7ca9688 | 6 | #include <stdlib.h> |
garyservin | 0:fd24f7ca9688 | 7 | #include "ros/msg.h" |
garyservin | 0:fd24f7ca9688 | 8 | #include "std_msgs/Header.h" |
garyservin | 0:fd24f7ca9688 | 9 | |
garyservin | 0:fd24f7ca9688 | 10 | namespace map_msgs |
garyservin | 0:fd24f7ca9688 | 11 | { |
garyservin | 0:fd24f7ca9688 | 12 | |
garyservin | 0:fd24f7ca9688 | 13 | class OccupancyGridUpdate : public ros::Msg |
garyservin | 0:fd24f7ca9688 | 14 | { |
garyservin | 0:fd24f7ca9688 | 15 | public: |
garyservin | 0:fd24f7ca9688 | 16 | std_msgs::Header header; |
garyservin | 0:fd24f7ca9688 | 17 | int32_t x; |
garyservin | 0:fd24f7ca9688 | 18 | int32_t y; |
garyservin | 0:fd24f7ca9688 | 19 | uint32_t width; |
garyservin | 0:fd24f7ca9688 | 20 | uint32_t height; |
garyservin | 0:fd24f7ca9688 | 21 | uint8_t data_length; |
garyservin | 0:fd24f7ca9688 | 22 | int8_t st_data; |
garyservin | 0:fd24f7ca9688 | 23 | int8_t * data; |
garyservin | 0:fd24f7ca9688 | 24 | |
garyservin | 0:fd24f7ca9688 | 25 | OccupancyGridUpdate(): |
garyservin | 0:fd24f7ca9688 | 26 | header(), |
garyservin | 0:fd24f7ca9688 | 27 | x(0), |
garyservin | 0:fd24f7ca9688 | 28 | y(0), |
garyservin | 0:fd24f7ca9688 | 29 | width(0), |
garyservin | 0:fd24f7ca9688 | 30 | height(0), |
garyservin | 0:fd24f7ca9688 | 31 | data_length(0), data(NULL) |
garyservin | 0:fd24f7ca9688 | 32 | { |
garyservin | 0:fd24f7ca9688 | 33 | } |
garyservin | 0:fd24f7ca9688 | 34 | |
garyservin | 0:fd24f7ca9688 | 35 | virtual int serialize(unsigned char *outbuffer) const |
garyservin | 0:fd24f7ca9688 | 36 | { |
garyservin | 0:fd24f7ca9688 | 37 | int offset = 0; |
garyservin | 0:fd24f7ca9688 | 38 | offset += this->header.serialize(outbuffer + offset); |
garyservin | 0:fd24f7ca9688 | 39 | union { |
garyservin | 0:fd24f7ca9688 | 40 | int32_t real; |
garyservin | 0:fd24f7ca9688 | 41 | uint32_t base; |
garyservin | 0:fd24f7ca9688 | 42 | } u_x; |
garyservin | 0:fd24f7ca9688 | 43 | u_x.real = this->x; |
garyservin | 0:fd24f7ca9688 | 44 | *(outbuffer + offset + 0) = (u_x.base >> (8 * 0)) & 0xFF; |
garyservin | 0:fd24f7ca9688 | 45 | *(outbuffer + offset + 1) = (u_x.base >> (8 * 1)) & 0xFF; |
garyservin | 0:fd24f7ca9688 | 46 | *(outbuffer + offset + 2) = (u_x.base >> (8 * 2)) & 0xFF; |
garyservin | 0:fd24f7ca9688 | 47 | *(outbuffer + offset + 3) = (u_x.base >> (8 * 3)) & 0xFF; |
garyservin | 0:fd24f7ca9688 | 48 | offset += sizeof(this->x); |
garyservin | 0:fd24f7ca9688 | 49 | union { |
garyservin | 0:fd24f7ca9688 | 50 | int32_t real; |
garyservin | 0:fd24f7ca9688 | 51 | uint32_t base; |
garyservin | 0:fd24f7ca9688 | 52 | } u_y; |
garyservin | 0:fd24f7ca9688 | 53 | u_y.real = this->y; |
garyservin | 0:fd24f7ca9688 | 54 | *(outbuffer + offset + 0) = (u_y.base >> (8 * 0)) & 0xFF; |
garyservin | 0:fd24f7ca9688 | 55 | *(outbuffer + offset + 1) = (u_y.base >> (8 * 1)) & 0xFF; |
garyservin | 0:fd24f7ca9688 | 56 | *(outbuffer + offset + 2) = (u_y.base >> (8 * 2)) & 0xFF; |
garyservin | 0:fd24f7ca9688 | 57 | *(outbuffer + offset + 3) = (u_y.base >> (8 * 3)) & 0xFF; |
garyservin | 0:fd24f7ca9688 | 58 | offset += sizeof(this->y); |
garyservin | 0:fd24f7ca9688 | 59 | *(outbuffer + offset + 0) = (this->width >> (8 * 0)) & 0xFF; |
garyservin | 0:fd24f7ca9688 | 60 | *(outbuffer + offset + 1) = (this->width >> (8 * 1)) & 0xFF; |
garyservin | 0:fd24f7ca9688 | 61 | *(outbuffer + offset + 2) = (this->width >> (8 * 2)) & 0xFF; |
garyservin | 0:fd24f7ca9688 | 62 | *(outbuffer + offset + 3) = (this->width >> (8 * 3)) & 0xFF; |
garyservin | 0:fd24f7ca9688 | 63 | offset += sizeof(this->width); |
garyservin | 0:fd24f7ca9688 | 64 | *(outbuffer + offset + 0) = (this->height >> (8 * 0)) & 0xFF; |
garyservin | 0:fd24f7ca9688 | 65 | *(outbuffer + offset + 1) = (this->height >> (8 * 1)) & 0xFF; |
garyservin | 0:fd24f7ca9688 | 66 | *(outbuffer + offset + 2) = (this->height >> (8 * 2)) & 0xFF; |
garyservin | 0:fd24f7ca9688 | 67 | *(outbuffer + offset + 3) = (this->height >> (8 * 3)) & 0xFF; |
garyservin | 0:fd24f7ca9688 | 68 | offset += sizeof(this->height); |
garyservin | 0:fd24f7ca9688 | 69 | *(outbuffer + offset++) = data_length; |
garyservin | 0:fd24f7ca9688 | 70 | *(outbuffer + offset++) = 0; |
garyservin | 0:fd24f7ca9688 | 71 | *(outbuffer + offset++) = 0; |
garyservin | 0:fd24f7ca9688 | 72 | *(outbuffer + offset++) = 0; |
garyservin | 0:fd24f7ca9688 | 73 | for( uint8_t i = 0; i < data_length; i++){ |
garyservin | 0:fd24f7ca9688 | 74 | union { |
garyservin | 0:fd24f7ca9688 | 75 | int8_t real; |
garyservin | 0:fd24f7ca9688 | 76 | uint8_t base; |
garyservin | 0:fd24f7ca9688 | 77 | } u_datai; |
garyservin | 0:fd24f7ca9688 | 78 | u_datai.real = this->data[i]; |
garyservin | 0:fd24f7ca9688 | 79 | *(outbuffer + offset + 0) = (u_datai.base >> (8 * 0)) & 0xFF; |
garyservin | 0:fd24f7ca9688 | 80 | offset += sizeof(this->data[i]); |
garyservin | 0:fd24f7ca9688 | 81 | } |
garyservin | 0:fd24f7ca9688 | 82 | return offset; |
garyservin | 0:fd24f7ca9688 | 83 | } |
garyservin | 0:fd24f7ca9688 | 84 | |
garyservin | 0:fd24f7ca9688 | 85 | virtual int deserialize(unsigned char *inbuffer) |
garyservin | 0:fd24f7ca9688 | 86 | { |
garyservin | 0:fd24f7ca9688 | 87 | int offset = 0; |
garyservin | 0:fd24f7ca9688 | 88 | offset += this->header.deserialize(inbuffer + offset); |
garyservin | 0:fd24f7ca9688 | 89 | union { |
garyservin | 0:fd24f7ca9688 | 90 | int32_t real; |
garyservin | 0:fd24f7ca9688 | 91 | uint32_t base; |
garyservin | 0:fd24f7ca9688 | 92 | } u_x; |
garyservin | 0:fd24f7ca9688 | 93 | u_x.base = 0; |
garyservin | 0:fd24f7ca9688 | 94 | u_x.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
garyservin | 0:fd24f7ca9688 | 95 | u_x.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:fd24f7ca9688 | 96 | u_x.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:fd24f7ca9688 | 97 | u_x.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:fd24f7ca9688 | 98 | this->x = u_x.real; |
garyservin | 0:fd24f7ca9688 | 99 | offset += sizeof(this->x); |
garyservin | 0:fd24f7ca9688 | 100 | union { |
garyservin | 0:fd24f7ca9688 | 101 | int32_t real; |
garyservin | 0:fd24f7ca9688 | 102 | uint32_t base; |
garyservin | 0:fd24f7ca9688 | 103 | } u_y; |
garyservin | 0:fd24f7ca9688 | 104 | u_y.base = 0; |
garyservin | 0:fd24f7ca9688 | 105 | u_y.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
garyservin | 0:fd24f7ca9688 | 106 | u_y.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:fd24f7ca9688 | 107 | u_y.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:fd24f7ca9688 | 108 | u_y.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:fd24f7ca9688 | 109 | this->y = u_y.real; |
garyservin | 0:fd24f7ca9688 | 110 | offset += sizeof(this->y); |
garyservin | 0:fd24f7ca9688 | 111 | this->width = ((uint32_t) (*(inbuffer + offset))); |
garyservin | 0:fd24f7ca9688 | 112 | this->width |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:fd24f7ca9688 | 113 | this->width |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:fd24f7ca9688 | 114 | this->width |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:fd24f7ca9688 | 115 | offset += sizeof(this->width); |
garyservin | 0:fd24f7ca9688 | 116 | this->height = ((uint32_t) (*(inbuffer + offset))); |
garyservin | 0:fd24f7ca9688 | 117 | this->height |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:fd24f7ca9688 | 118 | this->height |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:fd24f7ca9688 | 119 | this->height |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:fd24f7ca9688 | 120 | offset += sizeof(this->height); |
garyservin | 0:fd24f7ca9688 | 121 | uint8_t data_lengthT = *(inbuffer + offset++); |
garyservin | 0:fd24f7ca9688 | 122 | if(data_lengthT > data_length) |
garyservin | 0:fd24f7ca9688 | 123 | this->data = (int8_t*)realloc(this->data, data_lengthT * sizeof(int8_t)); |
garyservin | 0:fd24f7ca9688 | 124 | offset += 3; |
garyservin | 0:fd24f7ca9688 | 125 | data_length = data_lengthT; |
garyservin | 0:fd24f7ca9688 | 126 | for( uint8_t i = 0; i < data_length; i++){ |
garyservin | 0:fd24f7ca9688 | 127 | union { |
garyservin | 0:fd24f7ca9688 | 128 | int8_t real; |
garyservin | 0:fd24f7ca9688 | 129 | uint8_t base; |
garyservin | 0:fd24f7ca9688 | 130 | } u_st_data; |
garyservin | 0:fd24f7ca9688 | 131 | u_st_data.base = 0; |
garyservin | 0:fd24f7ca9688 | 132 | u_st_data.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); |
garyservin | 0:fd24f7ca9688 | 133 | this->st_data = u_st_data.real; |
garyservin | 0:fd24f7ca9688 | 134 | offset += sizeof(this->st_data); |
garyservin | 0:fd24f7ca9688 | 135 | memcpy( &(this->data[i]), &(this->st_data), sizeof(int8_t)); |
garyservin | 0:fd24f7ca9688 | 136 | } |
garyservin | 0:fd24f7ca9688 | 137 | return offset; |
garyservin | 0:fd24f7ca9688 | 138 | } |
garyservin | 0:fd24f7ca9688 | 139 | |
garyservin | 0:fd24f7ca9688 | 140 | const char * getType(){ return "map_msgs/OccupancyGridUpdate"; }; |
garyservin | 0:fd24f7ca9688 | 141 | const char * getMD5(){ return "b295be292b335c34718bd939deebe1c9"; }; |
garyservin | 0:fd24f7ca9688 | 142 | |
garyservin | 0:fd24f7ca9688 | 143 | }; |
garyservin | 0:fd24f7ca9688 | 144 | |
garyservin | 0:fd24f7ca9688 | 145 | } |
garyservin | 0:fd24f7ca9688 | 146 | #endif |