rosserial library for mbed Inspired by nucho's rosserial library This library is still under development
Dependents: mbed_roshydro_test
Library still under development!
sensor_msgs/PointCloud2.h@0:30537dec6e0b, 2015-02-15 (annotated)
- Committer:
- akashvibhute
- Date:
- Sun Feb 15 10:53:43 2015 +0000
- Revision:
- 0:30537dec6e0b
First commit; Library still need to be debugged, compilation issues with new mbed and modserial updates.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
akashvibhute | 0:30537dec6e0b | 1 | #ifndef _ROS_sensor_msgs_PointCloud2_h |
akashvibhute | 0:30537dec6e0b | 2 | #define _ROS_sensor_msgs_PointCloud2_h |
akashvibhute | 0:30537dec6e0b | 3 | |
akashvibhute | 0:30537dec6e0b | 4 | #include <stdint.h> |
akashvibhute | 0:30537dec6e0b | 5 | #include <string.h> |
akashvibhute | 0:30537dec6e0b | 6 | #include <stdlib.h> |
akashvibhute | 0:30537dec6e0b | 7 | #include "ros/msg.h" |
akashvibhute | 0:30537dec6e0b | 8 | #include "std_msgs/Header.h" |
akashvibhute | 0:30537dec6e0b | 9 | #include "sensor_msgs/PointField.h" |
akashvibhute | 0:30537dec6e0b | 10 | |
akashvibhute | 0:30537dec6e0b | 11 | namespace sensor_msgs |
akashvibhute | 0:30537dec6e0b | 12 | { |
akashvibhute | 0:30537dec6e0b | 13 | |
akashvibhute | 0:30537dec6e0b | 14 | class PointCloud2 : public ros::Msg |
akashvibhute | 0:30537dec6e0b | 15 | { |
akashvibhute | 0:30537dec6e0b | 16 | public: |
akashvibhute | 0:30537dec6e0b | 17 | std_msgs::Header header; |
akashvibhute | 0:30537dec6e0b | 18 | uint32_t height; |
akashvibhute | 0:30537dec6e0b | 19 | uint32_t width; |
akashvibhute | 0:30537dec6e0b | 20 | uint8_t fields_length; |
akashvibhute | 0:30537dec6e0b | 21 | sensor_msgs::PointField st_fields; |
akashvibhute | 0:30537dec6e0b | 22 | sensor_msgs::PointField * fields; |
akashvibhute | 0:30537dec6e0b | 23 | bool is_bigendian; |
akashvibhute | 0:30537dec6e0b | 24 | uint32_t point_step; |
akashvibhute | 0:30537dec6e0b | 25 | uint32_t row_step; |
akashvibhute | 0:30537dec6e0b | 26 | uint8_t data_length; |
akashvibhute | 0:30537dec6e0b | 27 | uint8_t st_data; |
akashvibhute | 0:30537dec6e0b | 28 | uint8_t * data; |
akashvibhute | 0:30537dec6e0b | 29 | bool is_dense; |
akashvibhute | 0:30537dec6e0b | 30 | |
akashvibhute | 0:30537dec6e0b | 31 | virtual int serialize(unsigned char *outbuffer) const |
akashvibhute | 0:30537dec6e0b | 32 | { |
akashvibhute | 0:30537dec6e0b | 33 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 34 | offset += this->header.serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 35 | *(outbuffer + offset + 0) = (this->height >> (8 * 0)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 36 | *(outbuffer + offset + 1) = (this->height >> (8 * 1)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 37 | *(outbuffer + offset + 2) = (this->height >> (8 * 2)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 38 | *(outbuffer + offset + 3) = (this->height >> (8 * 3)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 39 | offset += sizeof(this->height); |
akashvibhute | 0:30537dec6e0b | 40 | *(outbuffer + offset + 0) = (this->width >> (8 * 0)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 41 | *(outbuffer + offset + 1) = (this->width >> (8 * 1)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 42 | *(outbuffer + offset + 2) = (this->width >> (8 * 2)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 43 | *(outbuffer + offset + 3) = (this->width >> (8 * 3)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 44 | offset += sizeof(this->width); |
akashvibhute | 0:30537dec6e0b | 45 | *(outbuffer + offset++) = fields_length; |
akashvibhute | 0:30537dec6e0b | 46 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 47 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 48 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 49 | for( uint8_t i = 0; i < fields_length; i++){ |
akashvibhute | 0:30537dec6e0b | 50 | offset += this->fields[i].serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 51 | } |
akashvibhute | 0:30537dec6e0b | 52 | union { |
akashvibhute | 0:30537dec6e0b | 53 | bool real; |
akashvibhute | 0:30537dec6e0b | 54 | uint8_t base; |
akashvibhute | 0:30537dec6e0b | 55 | } u_is_bigendian; |
akashvibhute | 0:30537dec6e0b | 56 | u_is_bigendian.real = this->is_bigendian; |
akashvibhute | 0:30537dec6e0b | 57 | *(outbuffer + offset + 0) = (u_is_bigendian.base >> (8 * 0)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 58 | offset += sizeof(this->is_bigendian); |
akashvibhute | 0:30537dec6e0b | 59 | *(outbuffer + offset + 0) = (this->point_step >> (8 * 0)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 60 | *(outbuffer + offset + 1) = (this->point_step >> (8 * 1)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 61 | *(outbuffer + offset + 2) = (this->point_step >> (8 * 2)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 62 | *(outbuffer + offset + 3) = (this->point_step >> (8 * 3)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 63 | offset += sizeof(this->point_step); |
akashvibhute | 0:30537dec6e0b | 64 | *(outbuffer + offset + 0) = (this->row_step >> (8 * 0)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 65 | *(outbuffer + offset + 1) = (this->row_step >> (8 * 1)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 66 | *(outbuffer + offset + 2) = (this->row_step >> (8 * 2)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 67 | *(outbuffer + offset + 3) = (this->row_step >> (8 * 3)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 68 | offset += sizeof(this->row_step); |
akashvibhute | 0:30537dec6e0b | 69 | *(outbuffer + offset++) = data_length; |
akashvibhute | 0:30537dec6e0b | 70 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 71 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 72 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 73 | for( uint8_t i = 0; i < data_length; i++){ |
akashvibhute | 0:30537dec6e0b | 74 | *(outbuffer + offset + 0) = (this->data[i] >> (8 * 0)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 75 | offset += sizeof(this->data[i]); |
akashvibhute | 0:30537dec6e0b | 76 | } |
akashvibhute | 0:30537dec6e0b | 77 | union { |
akashvibhute | 0:30537dec6e0b | 78 | bool real; |
akashvibhute | 0:30537dec6e0b | 79 | uint8_t base; |
akashvibhute | 0:30537dec6e0b | 80 | } u_is_dense; |
akashvibhute | 0:30537dec6e0b | 81 | u_is_dense.real = this->is_dense; |
akashvibhute | 0:30537dec6e0b | 82 | *(outbuffer + offset + 0) = (u_is_dense.base >> (8 * 0)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 83 | offset += sizeof(this->is_dense); |
akashvibhute | 0:30537dec6e0b | 84 | return offset; |
akashvibhute | 0:30537dec6e0b | 85 | } |
akashvibhute | 0:30537dec6e0b | 86 | |
akashvibhute | 0:30537dec6e0b | 87 | virtual int deserialize(unsigned char *inbuffer) |
akashvibhute | 0:30537dec6e0b | 88 | { |
akashvibhute | 0:30537dec6e0b | 89 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 90 | offset += this->header.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 91 | this->height |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
akashvibhute | 0:30537dec6e0b | 92 | this->height |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
akashvibhute | 0:30537dec6e0b | 93 | this->height |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
akashvibhute | 0:30537dec6e0b | 94 | this->height |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
akashvibhute | 0:30537dec6e0b | 95 | offset += sizeof(this->height); |
akashvibhute | 0:30537dec6e0b | 96 | this->width |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
akashvibhute | 0:30537dec6e0b | 97 | this->width |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
akashvibhute | 0:30537dec6e0b | 98 | this->width |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
akashvibhute | 0:30537dec6e0b | 99 | this->width |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
akashvibhute | 0:30537dec6e0b | 100 | offset += sizeof(this->width); |
akashvibhute | 0:30537dec6e0b | 101 | uint8_t fields_lengthT = *(inbuffer + offset++); |
akashvibhute | 0:30537dec6e0b | 102 | if(fields_lengthT > fields_length) |
akashvibhute | 0:30537dec6e0b | 103 | this->fields = (sensor_msgs::PointField*)realloc(this->fields, fields_lengthT * sizeof(sensor_msgs::PointField)); |
akashvibhute | 0:30537dec6e0b | 104 | offset += 3; |
akashvibhute | 0:30537dec6e0b | 105 | fields_length = fields_lengthT; |
akashvibhute | 0:30537dec6e0b | 106 | for( uint8_t i = 0; i < fields_length; i++){ |
akashvibhute | 0:30537dec6e0b | 107 | offset += this->st_fields.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 108 | memcpy( &(this->fields[i]), &(this->st_fields), sizeof(sensor_msgs::PointField)); |
akashvibhute | 0:30537dec6e0b | 109 | } |
akashvibhute | 0:30537dec6e0b | 110 | union { |
akashvibhute | 0:30537dec6e0b | 111 | bool real; |
akashvibhute | 0:30537dec6e0b | 112 | uint8_t base; |
akashvibhute | 0:30537dec6e0b | 113 | } u_is_bigendian; |
akashvibhute | 0:30537dec6e0b | 114 | u_is_bigendian.base = 0; |
akashvibhute | 0:30537dec6e0b | 115 | u_is_bigendian.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); |
akashvibhute | 0:30537dec6e0b | 116 | this->is_bigendian = u_is_bigendian.real; |
akashvibhute | 0:30537dec6e0b | 117 | offset += sizeof(this->is_bigendian); |
akashvibhute | 0:30537dec6e0b | 118 | this->point_step |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
akashvibhute | 0:30537dec6e0b | 119 | this->point_step |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
akashvibhute | 0:30537dec6e0b | 120 | this->point_step |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
akashvibhute | 0:30537dec6e0b | 121 | this->point_step |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
akashvibhute | 0:30537dec6e0b | 122 | offset += sizeof(this->point_step); |
akashvibhute | 0:30537dec6e0b | 123 | this->row_step |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
akashvibhute | 0:30537dec6e0b | 124 | this->row_step |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
akashvibhute | 0:30537dec6e0b | 125 | this->row_step |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
akashvibhute | 0:30537dec6e0b | 126 | this->row_step |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
akashvibhute | 0:30537dec6e0b | 127 | offset += sizeof(this->row_step); |
akashvibhute | 0:30537dec6e0b | 128 | uint8_t data_lengthT = *(inbuffer + offset++); |
akashvibhute | 0:30537dec6e0b | 129 | if(data_lengthT > data_length) |
akashvibhute | 0:30537dec6e0b | 130 | this->data = (uint8_t*)realloc(this->data, data_lengthT * sizeof(uint8_t)); |
akashvibhute | 0:30537dec6e0b | 131 | offset += 3; |
akashvibhute | 0:30537dec6e0b | 132 | data_length = data_lengthT; |
akashvibhute | 0:30537dec6e0b | 133 | for( uint8_t i = 0; i < data_length; i++){ |
akashvibhute | 0:30537dec6e0b | 134 | this->st_data |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); |
akashvibhute | 0:30537dec6e0b | 135 | offset += sizeof(this->st_data); |
akashvibhute | 0:30537dec6e0b | 136 | memcpy( &(this->data[i]), &(this->st_data), sizeof(uint8_t)); |
akashvibhute | 0:30537dec6e0b | 137 | } |
akashvibhute | 0:30537dec6e0b | 138 | union { |
akashvibhute | 0:30537dec6e0b | 139 | bool real; |
akashvibhute | 0:30537dec6e0b | 140 | uint8_t base; |
akashvibhute | 0:30537dec6e0b | 141 | } u_is_dense; |
akashvibhute | 0:30537dec6e0b | 142 | u_is_dense.base = 0; |
akashvibhute | 0:30537dec6e0b | 143 | u_is_dense.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); |
akashvibhute | 0:30537dec6e0b | 144 | this->is_dense = u_is_dense.real; |
akashvibhute | 0:30537dec6e0b | 145 | offset += sizeof(this->is_dense); |
akashvibhute | 0:30537dec6e0b | 146 | return offset; |
akashvibhute | 0:30537dec6e0b | 147 | } |
akashvibhute | 0:30537dec6e0b | 148 | |
akashvibhute | 0:30537dec6e0b | 149 | virtual const char * getType(){ return "sensor_msgs/PointCloud2"; }; |
akashvibhute | 0:30537dec6e0b | 150 | virtual const char * getMD5(){ return "1158d486dd51d683ce2f1be655c3c181"; }; |
akashvibhute | 0:30537dec6e0b | 151 | |
akashvibhute | 0:30537dec6e0b | 152 | }; |
akashvibhute | 0:30537dec6e0b | 153 | |
akashvibhute | 0:30537dec6e0b | 154 | } |
akashvibhute | 0:30537dec6e0b | 155 | #endif |