modify for Hydro version
Fork of rosserial_mbed_lib by
sensor_msgs/PointCloud.h@3:1cf99502f396, 2011-11-12 (annotated)
- Committer:
- nucho
- Date:
- Sat Nov 12 23:54:45 2011 +0000
- Revision:
- 3:1cf99502f396
- Parent:
- 0:77afd7560544
This program supported the revision of 167 of rosserial.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nucho | 3:1cf99502f396 | 1 | #ifndef _ROS_sensor_msgs_PointCloud_h |
nucho | 3:1cf99502f396 | 2 | #define _ROS_sensor_msgs_PointCloud_h |
nucho | 0:77afd7560544 | 3 | |
nucho | 0:77afd7560544 | 4 | #include <stdint.h> |
nucho | 0:77afd7560544 | 5 | #include <string.h> |
nucho | 0:77afd7560544 | 6 | #include <stdlib.h> |
nucho | 3:1cf99502f396 | 7 | #include "ros/msg.h" |
nucho | 0:77afd7560544 | 8 | #include "std_msgs/Header.h" |
nucho | 0:77afd7560544 | 9 | #include "geometry_msgs/Point32.h" |
nucho | 0:77afd7560544 | 10 | #include "sensor_msgs/ChannelFloat32.h" |
nucho | 0:77afd7560544 | 11 | |
nucho | 0:77afd7560544 | 12 | namespace sensor_msgs |
nucho | 0:77afd7560544 | 13 | { |
nucho | 0:77afd7560544 | 14 | |
nucho | 0:77afd7560544 | 15 | class PointCloud : public ros::Msg |
nucho | 0:77afd7560544 | 16 | { |
nucho | 0:77afd7560544 | 17 | public: |
nucho | 0:77afd7560544 | 18 | std_msgs::Header header; |
nucho | 3:1cf99502f396 | 19 | uint8_t points_length; |
nucho | 0:77afd7560544 | 20 | geometry_msgs::Point32 st_points; |
nucho | 0:77afd7560544 | 21 | geometry_msgs::Point32 * points; |
nucho | 3:1cf99502f396 | 22 | uint8_t channels_length; |
nucho | 0:77afd7560544 | 23 | sensor_msgs::ChannelFloat32 st_channels; |
nucho | 0:77afd7560544 | 24 | sensor_msgs::ChannelFloat32 * channels; |
nucho | 0:77afd7560544 | 25 | |
nucho | 3:1cf99502f396 | 26 | virtual int serialize(unsigned char *outbuffer) const |
nucho | 0:77afd7560544 | 27 | { |
nucho | 0:77afd7560544 | 28 | int offset = 0; |
nucho | 0:77afd7560544 | 29 | offset += this->header.serialize(outbuffer + offset); |
nucho | 0:77afd7560544 | 30 | *(outbuffer + offset++) = points_length; |
nucho | 0:77afd7560544 | 31 | *(outbuffer + offset++) = 0; |
nucho | 0:77afd7560544 | 32 | *(outbuffer + offset++) = 0; |
nucho | 0:77afd7560544 | 33 | *(outbuffer + offset++) = 0; |
nucho | 3:1cf99502f396 | 34 | for( uint8_t i = 0; i < points_length; i++){ |
nucho | 0:77afd7560544 | 35 | offset += this->points[i].serialize(outbuffer + offset); |
nucho | 0:77afd7560544 | 36 | } |
nucho | 0:77afd7560544 | 37 | *(outbuffer + offset++) = channels_length; |
nucho | 0:77afd7560544 | 38 | *(outbuffer + offset++) = 0; |
nucho | 0:77afd7560544 | 39 | *(outbuffer + offset++) = 0; |
nucho | 0:77afd7560544 | 40 | *(outbuffer + offset++) = 0; |
nucho | 3:1cf99502f396 | 41 | for( uint8_t i = 0; i < channels_length; i++){ |
nucho | 0:77afd7560544 | 42 | offset += this->channels[i].serialize(outbuffer + offset); |
nucho | 0:77afd7560544 | 43 | } |
nucho | 0:77afd7560544 | 44 | return offset; |
nucho | 0:77afd7560544 | 45 | } |
nucho | 0:77afd7560544 | 46 | |
nucho | 0:77afd7560544 | 47 | virtual int deserialize(unsigned char *inbuffer) |
nucho | 0:77afd7560544 | 48 | { |
nucho | 0:77afd7560544 | 49 | int offset = 0; |
nucho | 0:77afd7560544 | 50 | offset += this->header.deserialize(inbuffer + offset); |
nucho | 3:1cf99502f396 | 51 | uint8_t points_lengthT = *(inbuffer + offset++); |
nucho | 0:77afd7560544 | 52 | if(points_lengthT > points_length) |
nucho | 0:77afd7560544 | 53 | this->points = (geometry_msgs::Point32*)realloc(this->points, points_lengthT * sizeof(geometry_msgs::Point32)); |
nucho | 0:77afd7560544 | 54 | offset += 3; |
nucho | 0:77afd7560544 | 55 | points_length = points_lengthT; |
nucho | 3:1cf99502f396 | 56 | for( uint8_t i = 0; i < points_length; i++){ |
nucho | 0:77afd7560544 | 57 | offset += this->st_points.deserialize(inbuffer + offset); |
nucho | 0:77afd7560544 | 58 | memcpy( &(this->points[i]), &(this->st_points), sizeof(geometry_msgs::Point32)); |
nucho | 0:77afd7560544 | 59 | } |
nucho | 3:1cf99502f396 | 60 | uint8_t channels_lengthT = *(inbuffer + offset++); |
nucho | 0:77afd7560544 | 61 | if(channels_lengthT > channels_length) |
nucho | 0:77afd7560544 | 62 | this->channels = (sensor_msgs::ChannelFloat32*)realloc(this->channels, channels_lengthT * sizeof(sensor_msgs::ChannelFloat32)); |
nucho | 0:77afd7560544 | 63 | offset += 3; |
nucho | 0:77afd7560544 | 64 | channels_length = channels_lengthT; |
nucho | 3:1cf99502f396 | 65 | for( uint8_t i = 0; i < channels_length; i++){ |
nucho | 0:77afd7560544 | 66 | offset += this->st_channels.deserialize(inbuffer + offset); |
nucho | 0:77afd7560544 | 67 | memcpy( &(this->channels[i]), &(this->st_channels), sizeof(sensor_msgs::ChannelFloat32)); |
nucho | 0:77afd7560544 | 68 | } |
nucho | 0:77afd7560544 | 69 | return offset; |
nucho | 0:77afd7560544 | 70 | } |
nucho | 0:77afd7560544 | 71 | |
nucho | 3:1cf99502f396 | 72 | virtual const char * getType(){ return "sensor_msgs/PointCloud"; }; |
nucho | 3:1cf99502f396 | 73 | virtual const char * getMD5(){ return "d8e9c3f5afbdd8a130fd1d2763945fca"; }; |
nucho | 0:77afd7560544 | 74 | |
nucho | 0:77afd7560544 | 75 | }; |
nucho | 0:77afd7560544 | 76 | |
nucho | 0:77afd7560544 | 77 | } |
nucho | 0:77afd7560544 | 78 | #endif |