make changes on buffer serial

Dependencies:   BufferedSerial

Dependents:  

Committer:
Gary Servin
Date:
Fri Nov 08 14:38:09 2019 -0300
Revision:
0:04ac6be8229a
Initial commit, generated based on a clean melodic-desktop-full

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Gary Servin 0:04ac6be8229a 1 #ifndef _ROS_nav_msgs_GridCells_h
Gary Servin 0:04ac6be8229a 2 #define _ROS_nav_msgs_GridCells_h
Gary Servin 0:04ac6be8229a 3
Gary Servin 0:04ac6be8229a 4 #include <stdint.h>
Gary Servin 0:04ac6be8229a 5 #include <string.h>
Gary Servin 0:04ac6be8229a 6 #include <stdlib.h>
Gary Servin 0:04ac6be8229a 7 #include "ros/msg.h"
Gary Servin 0:04ac6be8229a 8 #include "std_msgs/Header.h"
Gary Servin 0:04ac6be8229a 9 #include "geometry_msgs/Point.h"
Gary Servin 0:04ac6be8229a 10
Gary Servin 0:04ac6be8229a 11 namespace nav_msgs
Gary Servin 0:04ac6be8229a 12 {
Gary Servin 0:04ac6be8229a 13
Gary Servin 0:04ac6be8229a 14 class GridCells : public ros::Msg
Gary Servin 0:04ac6be8229a 15 {
Gary Servin 0:04ac6be8229a 16 public:
Gary Servin 0:04ac6be8229a 17 typedef std_msgs::Header _header_type;
Gary Servin 0:04ac6be8229a 18 _header_type header;
Gary Servin 0:04ac6be8229a 19 typedef float _cell_width_type;
Gary Servin 0:04ac6be8229a 20 _cell_width_type cell_width;
Gary Servin 0:04ac6be8229a 21 typedef float _cell_height_type;
Gary Servin 0:04ac6be8229a 22 _cell_height_type cell_height;
Gary Servin 0:04ac6be8229a 23 uint32_t cells_length;
Gary Servin 0:04ac6be8229a 24 typedef geometry_msgs::Point _cells_type;
Gary Servin 0:04ac6be8229a 25 _cells_type st_cells;
Gary Servin 0:04ac6be8229a 26 _cells_type * cells;
Gary Servin 0:04ac6be8229a 27
Gary Servin 0:04ac6be8229a 28 GridCells():
Gary Servin 0:04ac6be8229a 29 header(),
Gary Servin 0:04ac6be8229a 30 cell_width(0),
Gary Servin 0:04ac6be8229a 31 cell_height(0),
Gary Servin 0:04ac6be8229a 32 cells_length(0), cells(NULL)
Gary Servin 0:04ac6be8229a 33 {
Gary Servin 0:04ac6be8229a 34 }
Gary Servin 0:04ac6be8229a 35
Gary Servin 0:04ac6be8229a 36 virtual int serialize(unsigned char *outbuffer) const
Gary Servin 0:04ac6be8229a 37 {
Gary Servin 0:04ac6be8229a 38 int offset = 0;
Gary Servin 0:04ac6be8229a 39 offset += this->header.serialize(outbuffer + offset);
Gary Servin 0:04ac6be8229a 40 union {
Gary Servin 0:04ac6be8229a 41 float real;
Gary Servin 0:04ac6be8229a 42 uint32_t base;
Gary Servin 0:04ac6be8229a 43 } u_cell_width;
Gary Servin 0:04ac6be8229a 44 u_cell_width.real = this->cell_width;
Gary Servin 0:04ac6be8229a 45 *(outbuffer + offset + 0) = (u_cell_width.base >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 46 *(outbuffer + offset + 1) = (u_cell_width.base >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 47 *(outbuffer + offset + 2) = (u_cell_width.base >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 48 *(outbuffer + offset + 3) = (u_cell_width.base >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 49 offset += sizeof(this->cell_width);
Gary Servin 0:04ac6be8229a 50 union {
Gary Servin 0:04ac6be8229a 51 float real;
Gary Servin 0:04ac6be8229a 52 uint32_t base;
Gary Servin 0:04ac6be8229a 53 } u_cell_height;
Gary Servin 0:04ac6be8229a 54 u_cell_height.real = this->cell_height;
Gary Servin 0:04ac6be8229a 55 *(outbuffer + offset + 0) = (u_cell_height.base >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 56 *(outbuffer + offset + 1) = (u_cell_height.base >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 57 *(outbuffer + offset + 2) = (u_cell_height.base >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 58 *(outbuffer + offset + 3) = (u_cell_height.base >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 59 offset += sizeof(this->cell_height);
Gary Servin 0:04ac6be8229a 60 *(outbuffer + offset + 0) = (this->cells_length >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 61 *(outbuffer + offset + 1) = (this->cells_length >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 62 *(outbuffer + offset + 2) = (this->cells_length >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 63 *(outbuffer + offset + 3) = (this->cells_length >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 64 offset += sizeof(this->cells_length);
Gary Servin 0:04ac6be8229a 65 for( uint32_t i = 0; i < cells_length; i++){
Gary Servin 0:04ac6be8229a 66 offset += this->cells[i].serialize(outbuffer + offset);
Gary Servin 0:04ac6be8229a 67 }
Gary Servin 0:04ac6be8229a 68 return offset;
Gary Servin 0:04ac6be8229a 69 }
Gary Servin 0:04ac6be8229a 70
Gary Servin 0:04ac6be8229a 71 virtual int deserialize(unsigned char *inbuffer)
Gary Servin 0:04ac6be8229a 72 {
Gary Servin 0:04ac6be8229a 73 int offset = 0;
Gary Servin 0:04ac6be8229a 74 offset += this->header.deserialize(inbuffer + offset);
Gary Servin 0:04ac6be8229a 75 union {
Gary Servin 0:04ac6be8229a 76 float real;
Gary Servin 0:04ac6be8229a 77 uint32_t base;
Gary Servin 0:04ac6be8229a 78 } u_cell_width;
Gary Servin 0:04ac6be8229a 79 u_cell_width.base = 0;
Gary Servin 0:04ac6be8229a 80 u_cell_width.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
Gary Servin 0:04ac6be8229a 81 u_cell_width.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 82 u_cell_width.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 83 u_cell_width.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 84 this->cell_width = u_cell_width.real;
Gary Servin 0:04ac6be8229a 85 offset += sizeof(this->cell_width);
Gary Servin 0:04ac6be8229a 86 union {
Gary Servin 0:04ac6be8229a 87 float real;
Gary Servin 0:04ac6be8229a 88 uint32_t base;
Gary Servin 0:04ac6be8229a 89 } u_cell_height;
Gary Servin 0:04ac6be8229a 90 u_cell_height.base = 0;
Gary Servin 0:04ac6be8229a 91 u_cell_height.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
Gary Servin 0:04ac6be8229a 92 u_cell_height.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 93 u_cell_height.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 94 u_cell_height.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 95 this->cell_height = u_cell_height.real;
Gary Servin 0:04ac6be8229a 96 offset += sizeof(this->cell_height);
Gary Servin 0:04ac6be8229a 97 uint32_t cells_lengthT = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 98 cells_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 99 cells_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 100 cells_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 101 offset += sizeof(this->cells_length);
Gary Servin 0:04ac6be8229a 102 if(cells_lengthT > cells_length)
Gary Servin 0:04ac6be8229a 103 this->cells = (geometry_msgs::Point*)realloc(this->cells, cells_lengthT * sizeof(geometry_msgs::Point));
Gary Servin 0:04ac6be8229a 104 cells_length = cells_lengthT;
Gary Servin 0:04ac6be8229a 105 for( uint32_t i = 0; i < cells_length; i++){
Gary Servin 0:04ac6be8229a 106 offset += this->st_cells.deserialize(inbuffer + offset);
Gary Servin 0:04ac6be8229a 107 memcpy( &(this->cells[i]), &(this->st_cells), sizeof(geometry_msgs::Point));
Gary Servin 0:04ac6be8229a 108 }
Gary Servin 0:04ac6be8229a 109 return offset;
Gary Servin 0:04ac6be8229a 110 }
Gary Servin 0:04ac6be8229a 111
Gary Servin 0:04ac6be8229a 112 const char * getType(){ return "nav_msgs/GridCells"; };
Gary Servin 0:04ac6be8229a 113 const char * getMD5(){ return "b9e4f5df6d28e272ebde00a3994830f5"; };
Gary Servin 0:04ac6be8229a 114
Gary Servin 0:04ac6be8229a 115 };
Gary Servin 0:04ac6be8229a 116
Gary Servin 0:04ac6be8229a 117 }
Gary Servin 0:04ac6be8229a 118 #endif