Personal fork
Fork of rosserial_mbed_lib by
nav_msgs/GridCells.h@3:1cf99502f396, 2011-11-12 (annotated)
- Committer:
- nucho
- Date:
- Sat Nov 12 23:54:45 2011 +0000
- Revision:
- 3:1cf99502f396
- Parent:
- 1:ff0ec969dad1
This program supported the revision of 167 of rosserial.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nucho | 3:1cf99502f396 | 1 | #ifndef _ROS_nav_msgs_GridCells_h |
nucho | 3:1cf99502f396 | 2 | #define _ROS_nav_msgs_GridCells_h |
nucho | 0:77afd7560544 | 3 | |
nucho | 0:77afd7560544 | 4 | #include <stdint.h> |
nucho | 0:77afd7560544 | 5 | #include <string.h> |
nucho | 0:77afd7560544 | 6 | #include <stdlib.h> |
nucho | 3:1cf99502f396 | 7 | #include "ros/msg.h" |
nucho | 0:77afd7560544 | 8 | #include "std_msgs/Header.h" |
nucho | 0:77afd7560544 | 9 | #include "geometry_msgs/Point.h" |
nucho | 0:77afd7560544 | 10 | |
nucho | 0:77afd7560544 | 11 | namespace nav_msgs |
nucho | 0:77afd7560544 | 12 | { |
nucho | 0:77afd7560544 | 13 | |
nucho | 0:77afd7560544 | 14 | class GridCells : public ros::Msg |
nucho | 0:77afd7560544 | 15 | { |
nucho | 0:77afd7560544 | 16 | public: |
nucho | 0:77afd7560544 | 17 | std_msgs::Header header; |
nucho | 0:77afd7560544 | 18 | float cell_width; |
nucho | 0:77afd7560544 | 19 | float cell_height; |
nucho | 3:1cf99502f396 | 20 | uint8_t cells_length; |
nucho | 0:77afd7560544 | 21 | geometry_msgs::Point st_cells; |
nucho | 0:77afd7560544 | 22 | geometry_msgs::Point * cells; |
nucho | 0:77afd7560544 | 23 | |
nucho | 3:1cf99502f396 | 24 | virtual int serialize(unsigned char *outbuffer) const |
nucho | 0:77afd7560544 | 25 | { |
nucho | 0:77afd7560544 | 26 | int offset = 0; |
nucho | 0:77afd7560544 | 27 | offset += this->header.serialize(outbuffer + offset); |
nucho | 0:77afd7560544 | 28 | union { |
nucho | 0:77afd7560544 | 29 | float real; |
nucho | 3:1cf99502f396 | 30 | uint32_t base; |
nucho | 0:77afd7560544 | 31 | } u_cell_width; |
nucho | 0:77afd7560544 | 32 | u_cell_width.real = this->cell_width; |
nucho | 0:77afd7560544 | 33 | *(outbuffer + offset + 0) = (u_cell_width.base >> (8 * 0)) & 0xFF; |
nucho | 0:77afd7560544 | 34 | *(outbuffer + offset + 1) = (u_cell_width.base >> (8 * 1)) & 0xFF; |
nucho | 0:77afd7560544 | 35 | *(outbuffer + offset + 2) = (u_cell_width.base >> (8 * 2)) & 0xFF; |
nucho | 0:77afd7560544 | 36 | *(outbuffer + offset + 3) = (u_cell_width.base >> (8 * 3)) & 0xFF; |
nucho | 0:77afd7560544 | 37 | offset += sizeof(this->cell_width); |
nucho | 0:77afd7560544 | 38 | union { |
nucho | 0:77afd7560544 | 39 | float real; |
nucho | 3:1cf99502f396 | 40 | uint32_t base; |
nucho | 0:77afd7560544 | 41 | } u_cell_height; |
nucho | 0:77afd7560544 | 42 | u_cell_height.real = this->cell_height; |
nucho | 0:77afd7560544 | 43 | *(outbuffer + offset + 0) = (u_cell_height.base >> (8 * 0)) & 0xFF; |
nucho | 0:77afd7560544 | 44 | *(outbuffer + offset + 1) = (u_cell_height.base >> (8 * 1)) & 0xFF; |
nucho | 0:77afd7560544 | 45 | *(outbuffer + offset + 2) = (u_cell_height.base >> (8 * 2)) & 0xFF; |
nucho | 0:77afd7560544 | 46 | *(outbuffer + offset + 3) = (u_cell_height.base >> (8 * 3)) & 0xFF; |
nucho | 0:77afd7560544 | 47 | offset += sizeof(this->cell_height); |
nucho | 0:77afd7560544 | 48 | *(outbuffer + offset++) = cells_length; |
nucho | 0:77afd7560544 | 49 | *(outbuffer + offset++) = 0; |
nucho | 0:77afd7560544 | 50 | *(outbuffer + offset++) = 0; |
nucho | 0:77afd7560544 | 51 | *(outbuffer + offset++) = 0; |
nucho | 3:1cf99502f396 | 52 | for( uint8_t i = 0; i < cells_length; i++){ |
nucho | 0:77afd7560544 | 53 | offset += this->cells[i].serialize(outbuffer + offset); |
nucho | 0:77afd7560544 | 54 | } |
nucho | 0:77afd7560544 | 55 | return offset; |
nucho | 0:77afd7560544 | 56 | } |
nucho | 0:77afd7560544 | 57 | |
nucho | 0:77afd7560544 | 58 | virtual int deserialize(unsigned char *inbuffer) |
nucho | 0:77afd7560544 | 59 | { |
nucho | 0:77afd7560544 | 60 | int offset = 0; |
nucho | 0:77afd7560544 | 61 | offset += this->header.deserialize(inbuffer + offset); |
nucho | 0:77afd7560544 | 62 | union { |
nucho | 0:77afd7560544 | 63 | float real; |
nucho | 3:1cf99502f396 | 64 | uint32_t base; |
nucho | 0:77afd7560544 | 65 | } u_cell_width; |
nucho | 0:77afd7560544 | 66 | u_cell_width.base = 0; |
nucho | 3:1cf99502f396 | 67 | u_cell_width.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 3:1cf99502f396 | 68 | u_cell_width.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
nucho | 3:1cf99502f396 | 69 | u_cell_width.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
nucho | 3:1cf99502f396 | 70 | u_cell_width.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
nucho | 0:77afd7560544 | 71 | this->cell_width = u_cell_width.real; |
nucho | 0:77afd7560544 | 72 | offset += sizeof(this->cell_width); |
nucho | 0:77afd7560544 | 73 | union { |
nucho | 0:77afd7560544 | 74 | float real; |
nucho | 3:1cf99502f396 | 75 | uint32_t base; |
nucho | 0:77afd7560544 | 76 | } u_cell_height; |
nucho | 0:77afd7560544 | 77 | u_cell_height.base = 0; |
nucho | 3:1cf99502f396 | 78 | u_cell_height.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 3:1cf99502f396 | 79 | u_cell_height.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
nucho | 3:1cf99502f396 | 80 | u_cell_height.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
nucho | 3:1cf99502f396 | 81 | u_cell_height.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
nucho | 0:77afd7560544 | 82 | this->cell_height = u_cell_height.real; |
nucho | 0:77afd7560544 | 83 | offset += sizeof(this->cell_height); |
nucho | 3:1cf99502f396 | 84 | uint8_t cells_lengthT = *(inbuffer + offset++); |
nucho | 0:77afd7560544 | 85 | if(cells_lengthT > cells_length) |
nucho | 0:77afd7560544 | 86 | this->cells = (geometry_msgs::Point*)realloc(this->cells, cells_lengthT * sizeof(geometry_msgs::Point)); |
nucho | 0:77afd7560544 | 87 | offset += 3; |
nucho | 0:77afd7560544 | 88 | cells_length = cells_lengthT; |
nucho | 3:1cf99502f396 | 89 | for( uint8_t i = 0; i < cells_length; i++){ |
nucho | 0:77afd7560544 | 90 | offset += this->st_cells.deserialize(inbuffer + offset); |
nucho | 0:77afd7560544 | 91 | memcpy( &(this->cells[i]), &(this->st_cells), sizeof(geometry_msgs::Point)); |
nucho | 0:77afd7560544 | 92 | } |
nucho | 0:77afd7560544 | 93 | return offset; |
nucho | 0:77afd7560544 | 94 | } |
nucho | 0:77afd7560544 | 95 | |
nucho | 3:1cf99502f396 | 96 | virtual const char * getType(){ return "nav_msgs/GridCells"; }; |
nucho | 3:1cf99502f396 | 97 | virtual const char * getMD5(){ return "b9e4f5df6d28e272ebde00a3994830f5"; }; |
nucho | 0:77afd7560544 | 98 | |
nucho | 0:77afd7560544 | 99 | }; |
nucho | 0:77afd7560544 | 100 | |
nucho | 0:77afd7560544 | 101 | } |
nucho | 0:77afd7560544 | 102 | #endif |