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