capstone_finish
Dependencies: BufferedSerial motor_sn7544
sensor_msgs/PointCloud.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_PointCloud_h |
Jeonghoon | 3:2a3664dc6634 | 2 | #define _ROS_sensor_msgs_PointCloud_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 "geometry_msgs/Point32.h" |
Jeonghoon | 3:2a3664dc6634 | 10 | #include "sensor_msgs/ChannelFloat32.h" |
Jeonghoon | 3:2a3664dc6634 | 11 | |
Jeonghoon | 3:2a3664dc6634 | 12 | namespace sensor_msgs |
Jeonghoon | 3:2a3664dc6634 | 13 | { |
Jeonghoon | 3:2a3664dc6634 | 14 | |
Jeonghoon | 3:2a3664dc6634 | 15 | class PointCloud : public ros::Msg |
Jeonghoon | 3:2a3664dc6634 | 16 | { |
Jeonghoon | 3:2a3664dc6634 | 17 | public: |
Jeonghoon | 3:2a3664dc6634 | 18 | typedef std_msgs::Header _header_type; |
Jeonghoon | 3:2a3664dc6634 | 19 | _header_type header; |
Jeonghoon | 3:2a3664dc6634 | 20 | uint32_t points_length; |
Jeonghoon | 3:2a3664dc6634 | 21 | typedef geometry_msgs::Point32 _points_type; |
Jeonghoon | 3:2a3664dc6634 | 22 | _points_type st_points; |
Jeonghoon | 3:2a3664dc6634 | 23 | _points_type * points; |
Jeonghoon | 3:2a3664dc6634 | 24 | uint32_t channels_length; |
Jeonghoon | 3:2a3664dc6634 | 25 | typedef sensor_msgs::ChannelFloat32 _channels_type; |
Jeonghoon | 3:2a3664dc6634 | 26 | _channels_type st_channels; |
Jeonghoon | 3:2a3664dc6634 | 27 | _channels_type * channels; |
Jeonghoon | 3:2a3664dc6634 | 28 | |
Jeonghoon | 3:2a3664dc6634 | 29 | PointCloud(): |
Jeonghoon | 3:2a3664dc6634 | 30 | header(), |
Jeonghoon | 3:2a3664dc6634 | 31 | points_length(0), points(NULL), |
Jeonghoon | 3:2a3664dc6634 | 32 | channels_length(0), channels(NULL) |
Jeonghoon | 3:2a3664dc6634 | 33 | { |
Jeonghoon | 3:2a3664dc6634 | 34 | } |
Jeonghoon | 3:2a3664dc6634 | 35 | |
Jeonghoon | 3:2a3664dc6634 | 36 | virtual int serialize(unsigned char *outbuffer) const |
Jeonghoon | 3:2a3664dc6634 | 37 | { |
Jeonghoon | 3:2a3664dc6634 | 38 | int offset = 0; |
Jeonghoon | 3:2a3664dc6634 | 39 | offset += this->header.serialize(outbuffer + offset); |
Jeonghoon | 3:2a3664dc6634 | 40 | *(outbuffer + offset + 0) = (this->points_length >> (8 * 0)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 41 | *(outbuffer + offset + 1) = (this->points_length >> (8 * 1)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 42 | *(outbuffer + offset + 2) = (this->points_length >> (8 * 2)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 43 | *(outbuffer + offset + 3) = (this->points_length >> (8 * 3)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 44 | offset += sizeof(this->points_length); |
Jeonghoon | 3:2a3664dc6634 | 45 | for( uint32_t i = 0; i < points_length; i++){ |
Jeonghoon | 3:2a3664dc6634 | 46 | offset += this->points[i].serialize(outbuffer + offset); |
Jeonghoon | 3:2a3664dc6634 | 47 | } |
Jeonghoon | 3:2a3664dc6634 | 48 | *(outbuffer + offset + 0) = (this->channels_length >> (8 * 0)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 49 | *(outbuffer + offset + 1) = (this->channels_length >> (8 * 1)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 50 | *(outbuffer + offset + 2) = (this->channels_length >> (8 * 2)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 51 | *(outbuffer + offset + 3) = (this->channels_length >> (8 * 3)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 52 | offset += sizeof(this->channels_length); |
Jeonghoon | 3:2a3664dc6634 | 53 | for( uint32_t i = 0; i < channels_length; i++){ |
Jeonghoon | 3:2a3664dc6634 | 54 | offset += this->channels[i].serialize(outbuffer + offset); |
Jeonghoon | 3:2a3664dc6634 | 55 | } |
Jeonghoon | 3:2a3664dc6634 | 56 | return offset; |
Jeonghoon | 3:2a3664dc6634 | 57 | } |
Jeonghoon | 3:2a3664dc6634 | 58 | |
Jeonghoon | 3:2a3664dc6634 | 59 | virtual int deserialize(unsigned char *inbuffer) |
Jeonghoon | 3:2a3664dc6634 | 60 | { |
Jeonghoon | 3:2a3664dc6634 | 61 | int offset = 0; |
Jeonghoon | 3:2a3664dc6634 | 62 | offset += this->header.deserialize(inbuffer + offset); |
Jeonghoon | 3:2a3664dc6634 | 63 | uint32_t points_lengthT = ((uint32_t) (*(inbuffer + offset))); |
Jeonghoon | 3:2a3664dc6634 | 64 | points_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Jeonghoon | 3:2a3664dc6634 | 65 | points_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Jeonghoon | 3:2a3664dc6634 | 66 | points_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Jeonghoon | 3:2a3664dc6634 | 67 | offset += sizeof(this->points_length); |
Jeonghoon | 3:2a3664dc6634 | 68 | if(points_lengthT > points_length) |
Jeonghoon | 3:2a3664dc6634 | 69 | this->points = (geometry_msgs::Point32*)realloc(this->points, points_lengthT * sizeof(geometry_msgs::Point32)); |
Jeonghoon | 3:2a3664dc6634 | 70 | points_length = points_lengthT; |
Jeonghoon | 3:2a3664dc6634 | 71 | for( uint32_t i = 0; i < points_length; i++){ |
Jeonghoon | 3:2a3664dc6634 | 72 | offset += this->st_points.deserialize(inbuffer + offset); |
Jeonghoon | 3:2a3664dc6634 | 73 | memcpy( &(this->points[i]), &(this->st_points), sizeof(geometry_msgs::Point32)); |
Jeonghoon | 3:2a3664dc6634 | 74 | } |
Jeonghoon | 3:2a3664dc6634 | 75 | uint32_t channels_lengthT = ((uint32_t) (*(inbuffer + offset))); |
Jeonghoon | 3:2a3664dc6634 | 76 | channels_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Jeonghoon | 3:2a3664dc6634 | 77 | channels_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Jeonghoon | 3:2a3664dc6634 | 78 | channels_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Jeonghoon | 3:2a3664dc6634 | 79 | offset += sizeof(this->channels_length); |
Jeonghoon | 3:2a3664dc6634 | 80 | if(channels_lengthT > channels_length) |
Jeonghoon | 3:2a3664dc6634 | 81 | this->channels = (sensor_msgs::ChannelFloat32*)realloc(this->channels, channels_lengthT * sizeof(sensor_msgs::ChannelFloat32)); |
Jeonghoon | 3:2a3664dc6634 | 82 | channels_length = channels_lengthT; |
Jeonghoon | 3:2a3664dc6634 | 83 | for( uint32_t i = 0; i < channels_length; i++){ |
Jeonghoon | 3:2a3664dc6634 | 84 | offset += this->st_channels.deserialize(inbuffer + offset); |
Jeonghoon | 3:2a3664dc6634 | 85 | memcpy( &(this->channels[i]), &(this->st_channels), sizeof(sensor_msgs::ChannelFloat32)); |
Jeonghoon | 3:2a3664dc6634 | 86 | } |
Jeonghoon | 3:2a3664dc6634 | 87 | return offset; |
Jeonghoon | 3:2a3664dc6634 | 88 | } |
Jeonghoon | 3:2a3664dc6634 | 89 | |
Jeonghoon | 3:2a3664dc6634 | 90 | const char * getType(){ return "sensor_msgs/PointCloud"; }; |
Jeonghoon | 3:2a3664dc6634 | 91 | const char * getMD5(){ return "d8e9c3f5afbdd8a130fd1d2763945fca"; }; |
Jeonghoon | 3:2a3664dc6634 | 92 | |
Jeonghoon | 3:2a3664dc6634 | 93 | }; |
Jeonghoon | 3:2a3664dc6634 | 94 | |
Jeonghoon | 3:2a3664dc6634 | 95 | } |
Jeonghoon | 3:2a3664dc6634 | 96 | #endif |