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

Dependencies:   BufferedSerial

Dependents:   rosserial_mbed_hello_world_publisher rtos_base_control rosserial_mbed_F64MA ROS-RTOS ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PointCloud.h Source File

PointCloud.h

00001 #ifndef _ROS_sensor_msgs_PointCloud_h
00002 #define _ROS_sensor_msgs_PointCloud_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "std_msgs/Header.h"
00009 #include "geometry_msgs/Point32.h"
00010 #include "sensor_msgs/ChannelFloat32.h"
00011 
00012 namespace sensor_msgs
00013 {
00014 
00015   class PointCloud : public ros::Msg
00016   {
00017     public:
00018       std_msgs::Header header;
00019       uint8_t points_length;
00020       geometry_msgs::Point32 st_points;
00021       geometry_msgs::Point32 * points;
00022       uint8_t channels_length;
00023       sensor_msgs::ChannelFloat32 st_channels;
00024       sensor_msgs::ChannelFloat32 * channels;
00025 
00026     PointCloud():
00027       header(),
00028       points_length(0), points(NULL),
00029       channels_length(0), channels(NULL)
00030     {
00031     }
00032 
00033     virtual int serialize(unsigned char *outbuffer) const
00034     {
00035       int offset = 0;
00036       offset += this->header.serialize(outbuffer + offset);
00037       *(outbuffer + offset++) = points_length;
00038       *(outbuffer + offset++) = 0;
00039       *(outbuffer + offset++) = 0;
00040       *(outbuffer + offset++) = 0;
00041       for( uint8_t i = 0; i < points_length; i++){
00042       offset += this->points[i].serialize(outbuffer + offset);
00043       }
00044       *(outbuffer + offset++) = channels_length;
00045       *(outbuffer + offset++) = 0;
00046       *(outbuffer + offset++) = 0;
00047       *(outbuffer + offset++) = 0;
00048       for( uint8_t i = 0; i < channels_length; i++){
00049       offset += this->channels[i].serialize(outbuffer + offset);
00050       }
00051       return offset;
00052     }
00053 
00054     virtual int deserialize(unsigned char *inbuffer)
00055     {
00056       int offset = 0;
00057       offset += this->header.deserialize(inbuffer + offset);
00058       uint8_t points_lengthT = *(inbuffer + offset++);
00059       if(points_lengthT > points_length)
00060         this->points = (geometry_msgs::Point32*)realloc(this->points, points_lengthT * sizeof(geometry_msgs::Point32));
00061       offset += 3;
00062       points_length = points_lengthT;
00063       for( uint8_t i = 0; i < points_length; i++){
00064       offset += this->st_points.deserialize(inbuffer + offset);
00065         memcpy( &(this->points[i]), &(this->st_points), sizeof(geometry_msgs::Point32));
00066       }
00067       uint8_t channels_lengthT = *(inbuffer + offset++);
00068       if(channels_lengthT > channels_length)
00069         this->channels = (sensor_msgs::ChannelFloat32*)realloc(this->channels, channels_lengthT * sizeof(sensor_msgs::ChannelFloat32));
00070       offset += 3;
00071       channels_length = channels_lengthT;
00072       for( uint8_t i = 0; i < channels_length; i++){
00073       offset += this->st_channels.deserialize(inbuffer + offset);
00074         memcpy( &(this->channels[i]), &(this->st_channels), sizeof(sensor_msgs::ChannelFloat32));
00075       }
00076      return offset;
00077     }
00078 
00079     const char * getType(){ return "sensor_msgs/PointCloud"; };
00080     const char * getMD5(){ return "d8e9c3f5afbdd8a130fd1d2763945fca"; };
00081 
00082   };
00083 
00084 }
00085 #endif