ROS Serial library for Mbed platforms for ROS Melodic Morenia. Check http://wiki.ros.org/rosserial_mbed/ for more information.

Dependencies:   BufferedSerial

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_sensor_msgs_PointCloud2_h
Gary Servin 0:04ac6be8229a 2 #define _ROS_sensor_msgs_PointCloud2_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 "sensor_msgs/PointField.h"
Gary Servin 0:04ac6be8229a 10
Gary Servin 0:04ac6be8229a 11 namespace sensor_msgs
Gary Servin 0:04ac6be8229a 12 {
Gary Servin 0:04ac6be8229a 13
Gary Servin 0:04ac6be8229a 14 class PointCloud2 : 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 uint32_t _height_type;
Gary Servin 0:04ac6be8229a 20 _height_type height;
Gary Servin 0:04ac6be8229a 21 typedef uint32_t _width_type;
Gary Servin 0:04ac6be8229a 22 _width_type width;
Gary Servin 0:04ac6be8229a 23 uint32_t fields_length;
Gary Servin 0:04ac6be8229a 24 typedef sensor_msgs::PointField _fields_type;
Gary Servin 0:04ac6be8229a 25 _fields_type st_fields;
Gary Servin 0:04ac6be8229a 26 _fields_type * fields;
Gary Servin 0:04ac6be8229a 27 typedef bool _is_bigendian_type;
Gary Servin 0:04ac6be8229a 28 _is_bigendian_type is_bigendian;
Gary Servin 0:04ac6be8229a 29 typedef uint32_t _point_step_type;
Gary Servin 0:04ac6be8229a 30 _point_step_type point_step;
Gary Servin 0:04ac6be8229a 31 typedef uint32_t _row_step_type;
Gary Servin 0:04ac6be8229a 32 _row_step_type row_step;
Gary Servin 0:04ac6be8229a 33 uint32_t data_length;
Gary Servin 0:04ac6be8229a 34 typedef uint8_t _data_type;
Gary Servin 0:04ac6be8229a 35 _data_type st_data;
Gary Servin 0:04ac6be8229a 36 _data_type * data;
Gary Servin 0:04ac6be8229a 37 typedef bool _is_dense_type;
Gary Servin 0:04ac6be8229a 38 _is_dense_type is_dense;
Gary Servin 0:04ac6be8229a 39
Gary Servin 0:04ac6be8229a 40 PointCloud2():
Gary Servin 0:04ac6be8229a 41 header(),
Gary Servin 0:04ac6be8229a 42 height(0),
Gary Servin 0:04ac6be8229a 43 width(0),
Gary Servin 0:04ac6be8229a 44 fields_length(0), fields(NULL),
Gary Servin 0:04ac6be8229a 45 is_bigendian(0),
Gary Servin 0:04ac6be8229a 46 point_step(0),
Gary Servin 0:04ac6be8229a 47 row_step(0),
Gary Servin 0:04ac6be8229a 48 data_length(0), data(NULL),
Gary Servin 0:04ac6be8229a 49 is_dense(0)
Gary Servin 0:04ac6be8229a 50 {
Gary Servin 0:04ac6be8229a 51 }
Gary Servin 0:04ac6be8229a 52
Gary Servin 0:04ac6be8229a 53 virtual int serialize(unsigned char *outbuffer) const
Gary Servin 0:04ac6be8229a 54 {
Gary Servin 0:04ac6be8229a 55 int offset = 0;
Gary Servin 0:04ac6be8229a 56 offset += this->header.serialize(outbuffer + offset);
Gary Servin 0:04ac6be8229a 57 *(outbuffer + offset + 0) = (this->height >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 58 *(outbuffer + offset + 1) = (this->height >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 59 *(outbuffer + offset + 2) = (this->height >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 60 *(outbuffer + offset + 3) = (this->height >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 61 offset += sizeof(this->height);
Gary Servin 0:04ac6be8229a 62 *(outbuffer + offset + 0) = (this->width >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 63 *(outbuffer + offset + 1) = (this->width >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 64 *(outbuffer + offset + 2) = (this->width >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 65 *(outbuffer + offset + 3) = (this->width >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 66 offset += sizeof(this->width);
Gary Servin 0:04ac6be8229a 67 *(outbuffer + offset + 0) = (this->fields_length >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 68 *(outbuffer + offset + 1) = (this->fields_length >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 69 *(outbuffer + offset + 2) = (this->fields_length >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 70 *(outbuffer + offset + 3) = (this->fields_length >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 71 offset += sizeof(this->fields_length);
Gary Servin 0:04ac6be8229a 72 for( uint32_t i = 0; i < fields_length; i++){
Gary Servin 0:04ac6be8229a 73 offset += this->fields[i].serialize(outbuffer + offset);
Gary Servin 0:04ac6be8229a 74 }
Gary Servin 0:04ac6be8229a 75 union {
Gary Servin 0:04ac6be8229a 76 bool real;
Gary Servin 0:04ac6be8229a 77 uint8_t base;
Gary Servin 0:04ac6be8229a 78 } u_is_bigendian;
Gary Servin 0:04ac6be8229a 79 u_is_bigendian.real = this->is_bigendian;
Gary Servin 0:04ac6be8229a 80 *(outbuffer + offset + 0) = (u_is_bigendian.base >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 81 offset += sizeof(this->is_bigendian);
Gary Servin 0:04ac6be8229a 82 *(outbuffer + offset + 0) = (this->point_step >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 83 *(outbuffer + offset + 1) = (this->point_step >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 84 *(outbuffer + offset + 2) = (this->point_step >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 85 *(outbuffer + offset + 3) = (this->point_step >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 86 offset += sizeof(this->point_step);
Gary Servin 0:04ac6be8229a 87 *(outbuffer + offset + 0) = (this->row_step >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 88 *(outbuffer + offset + 1) = (this->row_step >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 89 *(outbuffer + offset + 2) = (this->row_step >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 90 *(outbuffer + offset + 3) = (this->row_step >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 91 offset += sizeof(this->row_step);
Gary Servin 0:04ac6be8229a 92 *(outbuffer + offset + 0) = (this->data_length >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 93 *(outbuffer + offset + 1) = (this->data_length >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 94 *(outbuffer + offset + 2) = (this->data_length >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 95 *(outbuffer + offset + 3) = (this->data_length >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 96 offset += sizeof(this->data_length);
Gary Servin 0:04ac6be8229a 97 for( uint32_t i = 0; i < data_length; i++){
Gary Servin 0:04ac6be8229a 98 *(outbuffer + offset + 0) = (this->data[i] >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 99 offset += sizeof(this->data[i]);
Gary Servin 0:04ac6be8229a 100 }
Gary Servin 0:04ac6be8229a 101 union {
Gary Servin 0:04ac6be8229a 102 bool real;
Gary Servin 0:04ac6be8229a 103 uint8_t base;
Gary Servin 0:04ac6be8229a 104 } u_is_dense;
Gary Servin 0:04ac6be8229a 105 u_is_dense.real = this->is_dense;
Gary Servin 0:04ac6be8229a 106 *(outbuffer + offset + 0) = (u_is_dense.base >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 107 offset += sizeof(this->is_dense);
Gary Servin 0:04ac6be8229a 108 return offset;
Gary Servin 0:04ac6be8229a 109 }
Gary Servin 0:04ac6be8229a 110
Gary Servin 0:04ac6be8229a 111 virtual int deserialize(unsigned char *inbuffer)
Gary Servin 0:04ac6be8229a 112 {
Gary Servin 0:04ac6be8229a 113 int offset = 0;
Gary Servin 0:04ac6be8229a 114 offset += this->header.deserialize(inbuffer + offset);
Gary Servin 0:04ac6be8229a 115 this->height = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 116 this->height |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 117 this->height |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 118 this->height |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 119 offset += sizeof(this->height);
Gary Servin 0:04ac6be8229a 120 this->width = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 121 this->width |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 122 this->width |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 123 this->width |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 124 offset += sizeof(this->width);
Gary Servin 0:04ac6be8229a 125 uint32_t fields_lengthT = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 126 fields_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 127 fields_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 128 fields_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 129 offset += sizeof(this->fields_length);
Gary Servin 0:04ac6be8229a 130 if(fields_lengthT > fields_length)
Gary Servin 0:04ac6be8229a 131 this->fields = (sensor_msgs::PointField*)realloc(this->fields, fields_lengthT * sizeof(sensor_msgs::PointField));
Gary Servin 0:04ac6be8229a 132 fields_length = fields_lengthT;
Gary Servin 0:04ac6be8229a 133 for( uint32_t i = 0; i < fields_length; i++){
Gary Servin 0:04ac6be8229a 134 offset += this->st_fields.deserialize(inbuffer + offset);
Gary Servin 0:04ac6be8229a 135 memcpy( &(this->fields[i]), &(this->st_fields), sizeof(sensor_msgs::PointField));
Gary Servin 0:04ac6be8229a 136 }
Gary Servin 0:04ac6be8229a 137 union {
Gary Servin 0:04ac6be8229a 138 bool real;
Gary Servin 0:04ac6be8229a 139 uint8_t base;
Gary Servin 0:04ac6be8229a 140 } u_is_bigendian;
Gary Servin 0:04ac6be8229a 141 u_is_bigendian.base = 0;
Gary Servin 0:04ac6be8229a 142 u_is_bigendian.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
Gary Servin 0:04ac6be8229a 143 this->is_bigendian = u_is_bigendian.real;
Gary Servin 0:04ac6be8229a 144 offset += sizeof(this->is_bigendian);
Gary Servin 0:04ac6be8229a 145 this->point_step = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 146 this->point_step |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 147 this->point_step |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 148 this->point_step |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 149 offset += sizeof(this->point_step);
Gary Servin 0:04ac6be8229a 150 this->row_step = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 151 this->row_step |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 152 this->row_step |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 153 this->row_step |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 154 offset += sizeof(this->row_step);
Gary Servin 0:04ac6be8229a 155 uint32_t data_lengthT = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 156 data_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 157 data_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 158 data_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 159 offset += sizeof(this->data_length);
Gary Servin 0:04ac6be8229a 160 if(data_lengthT > data_length)
Gary Servin 0:04ac6be8229a 161 this->data = (uint8_t*)realloc(this->data, data_lengthT * sizeof(uint8_t));
Gary Servin 0:04ac6be8229a 162 data_length = data_lengthT;
Gary Servin 0:04ac6be8229a 163 for( uint32_t i = 0; i < data_length; i++){
Gary Servin 0:04ac6be8229a 164 this->st_data = ((uint8_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 165 offset += sizeof(this->st_data);
Gary Servin 0:04ac6be8229a 166 memcpy( &(this->data[i]), &(this->st_data), sizeof(uint8_t));
Gary Servin 0:04ac6be8229a 167 }
Gary Servin 0:04ac6be8229a 168 union {
Gary Servin 0:04ac6be8229a 169 bool real;
Gary Servin 0:04ac6be8229a 170 uint8_t base;
Gary Servin 0:04ac6be8229a 171 } u_is_dense;
Gary Servin 0:04ac6be8229a 172 u_is_dense.base = 0;
Gary Servin 0:04ac6be8229a 173 u_is_dense.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
Gary Servin 0:04ac6be8229a 174 this->is_dense = u_is_dense.real;
Gary Servin 0:04ac6be8229a 175 offset += sizeof(this->is_dense);
Gary Servin 0:04ac6be8229a 176 return offset;
Gary Servin 0:04ac6be8229a 177 }
Gary Servin 0:04ac6be8229a 178
Gary Servin 0:04ac6be8229a 179 const char * getType(){ return "sensor_msgs/PointCloud2"; };
Gary Servin 0:04ac6be8229a 180 const char * getMD5(){ return "1158d486dd51d683ce2f1be655c3c181"; };
Gary Servin 0:04ac6be8229a 181
Gary Servin 0:04ac6be8229a 182 };
Gary Servin 0:04ac6be8229a 183
Gary Servin 0:04ac6be8229a 184 }
Gary Servin 0:04ac6be8229a 185 #endif