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_map_msgs_OccupancyGridUpdate_h
Gary Servin 0:04ac6be8229a 2 #define _ROS_map_msgs_OccupancyGridUpdate_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
Gary Servin 0:04ac6be8229a 10 namespace map_msgs
Gary Servin 0:04ac6be8229a 11 {
Gary Servin 0:04ac6be8229a 12
Gary Servin 0:04ac6be8229a 13 class OccupancyGridUpdate : public ros::Msg
Gary Servin 0:04ac6be8229a 14 {
Gary Servin 0:04ac6be8229a 15 public:
Gary Servin 0:04ac6be8229a 16 typedef std_msgs::Header _header_type;
Gary Servin 0:04ac6be8229a 17 _header_type header;
Gary Servin 0:04ac6be8229a 18 typedef int32_t _x_type;
Gary Servin 0:04ac6be8229a 19 _x_type x;
Gary Servin 0:04ac6be8229a 20 typedef int32_t _y_type;
Gary Servin 0:04ac6be8229a 21 _y_type y;
Gary Servin 0:04ac6be8229a 22 typedef uint32_t _width_type;
Gary Servin 0:04ac6be8229a 23 _width_type width;
Gary Servin 0:04ac6be8229a 24 typedef uint32_t _height_type;
Gary Servin 0:04ac6be8229a 25 _height_type height;
Gary Servin 0:04ac6be8229a 26 uint32_t data_length;
Gary Servin 0:04ac6be8229a 27 typedef int8_t _data_type;
Gary Servin 0:04ac6be8229a 28 _data_type st_data;
Gary Servin 0:04ac6be8229a 29 _data_type * data;
Gary Servin 0:04ac6be8229a 30
Gary Servin 0:04ac6be8229a 31 OccupancyGridUpdate():
Gary Servin 0:04ac6be8229a 32 header(),
Gary Servin 0:04ac6be8229a 33 x(0),
Gary Servin 0:04ac6be8229a 34 y(0),
Gary Servin 0:04ac6be8229a 35 width(0),
Gary Servin 0:04ac6be8229a 36 height(0),
Gary Servin 0:04ac6be8229a 37 data_length(0), data(NULL)
Gary Servin 0:04ac6be8229a 38 {
Gary Servin 0:04ac6be8229a 39 }
Gary Servin 0:04ac6be8229a 40
Gary Servin 0:04ac6be8229a 41 virtual int serialize(unsigned char *outbuffer) const
Gary Servin 0:04ac6be8229a 42 {
Gary Servin 0:04ac6be8229a 43 int offset = 0;
Gary Servin 0:04ac6be8229a 44 offset += this->header.serialize(outbuffer + offset);
Gary Servin 0:04ac6be8229a 45 union {
Gary Servin 0:04ac6be8229a 46 int32_t real;
Gary Servin 0:04ac6be8229a 47 uint32_t base;
Gary Servin 0:04ac6be8229a 48 } u_x;
Gary Servin 0:04ac6be8229a 49 u_x.real = this->x;
Gary Servin 0:04ac6be8229a 50 *(outbuffer + offset + 0) = (u_x.base >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 51 *(outbuffer + offset + 1) = (u_x.base >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 52 *(outbuffer + offset + 2) = (u_x.base >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 53 *(outbuffer + offset + 3) = (u_x.base >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 54 offset += sizeof(this->x);
Gary Servin 0:04ac6be8229a 55 union {
Gary Servin 0:04ac6be8229a 56 int32_t real;
Gary Servin 0:04ac6be8229a 57 uint32_t base;
Gary Servin 0:04ac6be8229a 58 } u_y;
Gary Servin 0:04ac6be8229a 59 u_y.real = this->y;
Gary Servin 0:04ac6be8229a 60 *(outbuffer + offset + 0) = (u_y.base >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 61 *(outbuffer + offset + 1) = (u_y.base >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 62 *(outbuffer + offset + 2) = (u_y.base >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 63 *(outbuffer + offset + 3) = (u_y.base >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 64 offset += sizeof(this->y);
Gary Servin 0:04ac6be8229a 65 *(outbuffer + offset + 0) = (this->width >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 66 *(outbuffer + offset + 1) = (this->width >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 67 *(outbuffer + offset + 2) = (this->width >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 68 *(outbuffer + offset + 3) = (this->width >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 69 offset += sizeof(this->width);
Gary Servin 0:04ac6be8229a 70 *(outbuffer + offset + 0) = (this->height >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 71 *(outbuffer + offset + 1) = (this->height >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 72 *(outbuffer + offset + 2) = (this->height >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 73 *(outbuffer + offset + 3) = (this->height >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 74 offset += sizeof(this->height);
Gary Servin 0:04ac6be8229a 75 *(outbuffer + offset + 0) = (this->data_length >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 76 *(outbuffer + offset + 1) = (this->data_length >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 77 *(outbuffer + offset + 2) = (this->data_length >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 78 *(outbuffer + offset + 3) = (this->data_length >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 79 offset += sizeof(this->data_length);
Gary Servin 0:04ac6be8229a 80 for( uint32_t i = 0; i < data_length; i++){
Gary Servin 0:04ac6be8229a 81 union {
Gary Servin 0:04ac6be8229a 82 int8_t real;
Gary Servin 0:04ac6be8229a 83 uint8_t base;
Gary Servin 0:04ac6be8229a 84 } u_datai;
Gary Servin 0:04ac6be8229a 85 u_datai.real = this->data[i];
Gary Servin 0:04ac6be8229a 86 *(outbuffer + offset + 0) = (u_datai.base >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 87 offset += sizeof(this->data[i]);
Gary Servin 0:04ac6be8229a 88 }
Gary Servin 0:04ac6be8229a 89 return offset;
Gary Servin 0:04ac6be8229a 90 }
Gary Servin 0:04ac6be8229a 91
Gary Servin 0:04ac6be8229a 92 virtual int deserialize(unsigned char *inbuffer)
Gary Servin 0:04ac6be8229a 93 {
Gary Servin 0:04ac6be8229a 94 int offset = 0;
Gary Servin 0:04ac6be8229a 95 offset += this->header.deserialize(inbuffer + offset);
Gary Servin 0:04ac6be8229a 96 union {
Gary Servin 0:04ac6be8229a 97 int32_t real;
Gary Servin 0:04ac6be8229a 98 uint32_t base;
Gary Servin 0:04ac6be8229a 99 } u_x;
Gary Servin 0:04ac6be8229a 100 u_x.base = 0;
Gary Servin 0:04ac6be8229a 101 u_x.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
Gary Servin 0:04ac6be8229a 102 u_x.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 103 u_x.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 104 u_x.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 105 this->x = u_x.real;
Gary Servin 0:04ac6be8229a 106 offset += sizeof(this->x);
Gary Servin 0:04ac6be8229a 107 union {
Gary Servin 0:04ac6be8229a 108 int32_t real;
Gary Servin 0:04ac6be8229a 109 uint32_t base;
Gary Servin 0:04ac6be8229a 110 } u_y;
Gary Servin 0:04ac6be8229a 111 u_y.base = 0;
Gary Servin 0:04ac6be8229a 112 u_y.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
Gary Servin 0:04ac6be8229a 113 u_y.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 114 u_y.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 115 u_y.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 116 this->y = u_y.real;
Gary Servin 0:04ac6be8229a 117 offset += sizeof(this->y);
Gary Servin 0:04ac6be8229a 118 this->width = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 119 this->width |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 120 this->width |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 121 this->width |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 122 offset += sizeof(this->width);
Gary Servin 0:04ac6be8229a 123 this->height = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 124 this->height |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 125 this->height |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 126 this->height |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 127 offset += sizeof(this->height);
Gary Servin 0:04ac6be8229a 128 uint32_t data_lengthT = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 129 data_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 130 data_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 131 data_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 132 offset += sizeof(this->data_length);
Gary Servin 0:04ac6be8229a 133 if(data_lengthT > data_length)
Gary Servin 0:04ac6be8229a 134 this->data = (int8_t*)realloc(this->data, data_lengthT * sizeof(int8_t));
Gary Servin 0:04ac6be8229a 135 data_length = data_lengthT;
Gary Servin 0:04ac6be8229a 136 for( uint32_t i = 0; i < data_length; i++){
Gary Servin 0:04ac6be8229a 137 union {
Gary Servin 0:04ac6be8229a 138 int8_t real;
Gary Servin 0:04ac6be8229a 139 uint8_t base;
Gary Servin 0:04ac6be8229a 140 } u_st_data;
Gary Servin 0:04ac6be8229a 141 u_st_data.base = 0;
Gary Servin 0:04ac6be8229a 142 u_st_data.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
Gary Servin 0:04ac6be8229a 143 this->st_data = u_st_data.real;
Gary Servin 0:04ac6be8229a 144 offset += sizeof(this->st_data);
Gary Servin 0:04ac6be8229a 145 memcpy( &(this->data[i]), &(this->st_data), sizeof(int8_t));
Gary Servin 0:04ac6be8229a 146 }
Gary Servin 0:04ac6be8229a 147 return offset;
Gary Servin 0:04ac6be8229a 148 }
Gary Servin 0:04ac6be8229a 149
Gary Servin 0:04ac6be8229a 150 const char * getType(){ return "map_msgs/OccupancyGridUpdate"; };
Gary Servin 0:04ac6be8229a 151 const char * getMD5(){ return "b295be292b335c34718bd939deebe1c9"; };
Gary Servin 0:04ac6be8229a 152
Gary Servin 0:04ac6be8229a 153 };
Gary Servin 0:04ac6be8229a 154
Gary Servin 0:04ac6be8229a 155 }
Gary Servin 0:04ac6be8229a 156 #endif