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