Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: RobotFeedback mobileRobotITU
Fork of ros_lib_indigo by
nav_msgs/OccupancyGrid.h@0:fd24f7ca9688, 2016-03-31 (annotated)
- Committer:
- garyservin
- Date:
- Thu Mar 31 14:22:59 2016 +0000
- Revision:
- 0:fd24f7ca9688
Initial commit, generated based on a clean indigo-desktop-full
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| garyservin | 0:fd24f7ca9688 | 1 | #ifndef _ROS_nav_msgs_OccupancyGrid_h |
| garyservin | 0:fd24f7ca9688 | 2 | #define _ROS_nav_msgs_OccupancyGrid_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 | #include "nav_msgs/MapMetaData.h" |
| garyservin | 0:fd24f7ca9688 | 10 | |
| garyservin | 0:fd24f7ca9688 | 11 | namespace nav_msgs |
| garyservin | 0:fd24f7ca9688 | 12 | { |
| garyservin | 0:fd24f7ca9688 | 13 | |
| garyservin | 0:fd24f7ca9688 | 14 | class OccupancyGrid : public ros::Msg |
| garyservin | 0:fd24f7ca9688 | 15 | { |
| garyservin | 0:fd24f7ca9688 | 16 | public: |
| garyservin | 0:fd24f7ca9688 | 17 | std_msgs::Header header; |
| garyservin | 0:fd24f7ca9688 | 18 | nav_msgs::MapMetaData info; |
| garyservin | 0:fd24f7ca9688 | 19 | uint8_t data_length; |
| garyservin | 0:fd24f7ca9688 | 20 | int8_t st_data; |
| garyservin | 0:fd24f7ca9688 | 21 | int8_t * data; |
| garyservin | 0:fd24f7ca9688 | 22 | |
| garyservin | 0:fd24f7ca9688 | 23 | OccupancyGrid(): |
| garyservin | 0:fd24f7ca9688 | 24 | header(), |
| garyservin | 0:fd24f7ca9688 | 25 | info(), |
| garyservin | 0:fd24f7ca9688 | 26 | data_length(0), data(NULL) |
| garyservin | 0:fd24f7ca9688 | 27 | { |
| garyservin | 0:fd24f7ca9688 | 28 | } |
| garyservin | 0:fd24f7ca9688 | 29 | |
| garyservin | 0:fd24f7ca9688 | 30 | virtual int serialize(unsigned char *outbuffer) const |
| garyservin | 0:fd24f7ca9688 | 31 | { |
| garyservin | 0:fd24f7ca9688 | 32 | int offset = 0; |
| garyservin | 0:fd24f7ca9688 | 33 | offset += this->header.serialize(outbuffer + offset); |
| garyservin | 0:fd24f7ca9688 | 34 | offset += this->info.serialize(outbuffer + offset); |
| garyservin | 0:fd24f7ca9688 | 35 | *(outbuffer + offset++) = data_length; |
| garyservin | 0:fd24f7ca9688 | 36 | *(outbuffer + offset++) = 0; |
| garyservin | 0:fd24f7ca9688 | 37 | *(outbuffer + offset++) = 0; |
| garyservin | 0:fd24f7ca9688 | 38 | *(outbuffer + offset++) = 0; |
| garyservin | 0:fd24f7ca9688 | 39 | for( uint8_t i = 0; i < data_length; i++){ |
| garyservin | 0:fd24f7ca9688 | 40 | union { |
| garyservin | 0:fd24f7ca9688 | 41 | int8_t real; |
| garyservin | 0:fd24f7ca9688 | 42 | uint8_t base; |
| garyservin | 0:fd24f7ca9688 | 43 | } u_datai; |
| garyservin | 0:fd24f7ca9688 | 44 | u_datai.real = this->data[i]; |
| garyservin | 0:fd24f7ca9688 | 45 | *(outbuffer + offset + 0) = (u_datai.base >> (8 * 0)) & 0xFF; |
| garyservin | 0:fd24f7ca9688 | 46 | offset += sizeof(this->data[i]); |
| garyservin | 0:fd24f7ca9688 | 47 | } |
| garyservin | 0:fd24f7ca9688 | 48 | return offset; |
| garyservin | 0:fd24f7ca9688 | 49 | } |
| garyservin | 0:fd24f7ca9688 | 50 | |
| garyservin | 0:fd24f7ca9688 | 51 | virtual int deserialize(unsigned char *inbuffer) |
| garyservin | 0:fd24f7ca9688 | 52 | { |
| garyservin | 0:fd24f7ca9688 | 53 | int offset = 0; |
| garyservin | 0:fd24f7ca9688 | 54 | offset += this->header.deserialize(inbuffer + offset); |
| garyservin | 0:fd24f7ca9688 | 55 | offset += this->info.deserialize(inbuffer + offset); |
| garyservin | 0:fd24f7ca9688 | 56 | uint8_t data_lengthT = *(inbuffer + offset++); |
| garyservin | 0:fd24f7ca9688 | 57 | if(data_lengthT > data_length) |
| garyservin | 0:fd24f7ca9688 | 58 | this->data = (int8_t*)realloc(this->data, data_lengthT * sizeof(int8_t)); |
| garyservin | 0:fd24f7ca9688 | 59 | offset += 3; |
| garyservin | 0:fd24f7ca9688 | 60 | data_length = data_lengthT; |
| garyservin | 0:fd24f7ca9688 | 61 | for( uint8_t i = 0; i < data_length; i++){ |
| garyservin | 0:fd24f7ca9688 | 62 | union { |
| garyservin | 0:fd24f7ca9688 | 63 | int8_t real; |
| garyservin | 0:fd24f7ca9688 | 64 | uint8_t base; |
| garyservin | 0:fd24f7ca9688 | 65 | } u_st_data; |
| garyservin | 0:fd24f7ca9688 | 66 | u_st_data.base = 0; |
| garyservin | 0:fd24f7ca9688 | 67 | u_st_data.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); |
| garyservin | 0:fd24f7ca9688 | 68 | this->st_data = u_st_data.real; |
| garyservin | 0:fd24f7ca9688 | 69 | offset += sizeof(this->st_data); |
| garyservin | 0:fd24f7ca9688 | 70 | memcpy( &(this->data[i]), &(this->st_data), sizeof(int8_t)); |
| garyservin | 0:fd24f7ca9688 | 71 | } |
| garyservin | 0:fd24f7ca9688 | 72 | return offset; |
| garyservin | 0:fd24f7ca9688 | 73 | } |
| garyservin | 0:fd24f7ca9688 | 74 | |
| garyservin | 0:fd24f7ca9688 | 75 | const char * getType(){ return "nav_msgs/OccupancyGrid"; }; |
| garyservin | 0:fd24f7ca9688 | 76 | const char * getMD5(){ return "3381f2d731d4076ec5c71b0759edbe4e"; }; |
| garyservin | 0:fd24f7ca9688 | 77 | |
| garyservin | 0:fd24f7ca9688 | 78 | }; |
| garyservin | 0:fd24f7ca9688 | 79 | |
| garyservin | 0:fd24f7ca9688 | 80 | } |
| garyservin | 0:fd24f7ca9688 | 81 | #endif |
