Irfan Tito Kurniawan / ros_lib
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GeographicMap.h Source File

GeographicMap.h

00001 #ifndef _ROS_geographic_msgs_GeographicMap_h
00002 #define _ROS_geographic_msgs_GeographicMap_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 "uuid_msgs/UniqueID.h"
00010 #include "geographic_msgs/BoundingBox.h"
00011 #include "geographic_msgs/WayPoint.h"
00012 #include "geographic_msgs/MapFeature.h"
00013 #include "geographic_msgs/KeyValue.h"
00014 
00015 namespace geographic_msgs
00016 {
00017 
00018   class GeographicMap : public ros::Msg
00019   {
00020     public:
00021       typedef std_msgs::Header _header_type;
00022       _header_type header;
00023       typedef uuid_msgs::UniqueID _id_type;
00024       _id_type id;
00025       typedef geographic_msgs::BoundingBox _bounds_type;
00026       _bounds_type bounds;
00027       uint32_t points_length;
00028       typedef geographic_msgs::WayPoint _points_type;
00029       _points_type st_points;
00030       _points_type * points;
00031       uint32_t features_length;
00032       typedef geographic_msgs::MapFeature _features_type;
00033       _features_type st_features;
00034       _features_type * features;
00035       uint32_t props_length;
00036       typedef geographic_msgs::KeyValue _props_type;
00037       _props_type st_props;
00038       _props_type * props;
00039 
00040     GeographicMap():
00041       header(),
00042       id(),
00043       bounds(),
00044       points_length(0), points(NULL),
00045       features_length(0), features(NULL),
00046       props_length(0), props(NULL)
00047     {
00048     }
00049 
00050     virtual int serialize(unsigned char *outbuffer) const
00051     {
00052       int offset = 0;
00053       offset += this->header.serialize(outbuffer + offset);
00054       offset += this->id.serialize(outbuffer + offset);
00055       offset += this->bounds.serialize(outbuffer + offset);
00056       *(outbuffer + offset + 0) = (this->points_length >> (8 * 0)) & 0xFF;
00057       *(outbuffer + offset + 1) = (this->points_length >> (8 * 1)) & 0xFF;
00058       *(outbuffer + offset + 2) = (this->points_length >> (8 * 2)) & 0xFF;
00059       *(outbuffer + offset + 3) = (this->points_length >> (8 * 3)) & 0xFF;
00060       offset += sizeof(this->points_length);
00061       for( uint32_t i = 0; i < points_length; i++){
00062       offset += this->points[i].serialize(outbuffer + offset);
00063       }
00064       *(outbuffer + offset + 0) = (this->features_length >> (8 * 0)) & 0xFF;
00065       *(outbuffer + offset + 1) = (this->features_length >> (8 * 1)) & 0xFF;
00066       *(outbuffer + offset + 2) = (this->features_length >> (8 * 2)) & 0xFF;
00067       *(outbuffer + offset + 3) = (this->features_length >> (8 * 3)) & 0xFF;
00068       offset += sizeof(this->features_length);
00069       for( uint32_t i = 0; i < features_length; i++){
00070       offset += this->features[i].serialize(outbuffer + offset);
00071       }
00072       *(outbuffer + offset + 0) = (this->props_length >> (8 * 0)) & 0xFF;
00073       *(outbuffer + offset + 1) = (this->props_length >> (8 * 1)) & 0xFF;
00074       *(outbuffer + offset + 2) = (this->props_length >> (8 * 2)) & 0xFF;
00075       *(outbuffer + offset + 3) = (this->props_length >> (8 * 3)) & 0xFF;
00076       offset += sizeof(this->props_length);
00077       for( uint32_t i = 0; i < props_length; i++){
00078       offset += this->props[i].serialize(outbuffer + offset);
00079       }
00080       return offset;
00081     }
00082 
00083     virtual int deserialize(unsigned char *inbuffer)
00084     {
00085       int offset = 0;
00086       offset += this->header.deserialize(inbuffer + offset);
00087       offset += this->id.deserialize(inbuffer + offset);
00088       offset += this->bounds.deserialize(inbuffer + offset);
00089       uint32_t points_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00090       points_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00091       points_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00092       points_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00093       offset += sizeof(this->points_length);
00094       if(points_lengthT > points_length)
00095         this->points = (geographic_msgs::WayPoint*)realloc(this->points, points_lengthT * sizeof(geographic_msgs::WayPoint));
00096       points_length = points_lengthT;
00097       for( uint32_t i = 0; i < points_length; i++){
00098       offset += this->st_points.deserialize(inbuffer + offset);
00099         memcpy( &(this->points[i]), &(this->st_points), sizeof(geographic_msgs::WayPoint));
00100       }
00101       uint32_t features_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00102       features_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00103       features_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00104       features_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00105       offset += sizeof(this->features_length);
00106       if(features_lengthT > features_length)
00107         this->features = (geographic_msgs::MapFeature*)realloc(this->features, features_lengthT * sizeof(geographic_msgs::MapFeature));
00108       features_length = features_lengthT;
00109       for( uint32_t i = 0; i < features_length; i++){
00110       offset += this->st_features.deserialize(inbuffer + offset);
00111         memcpy( &(this->features[i]), &(this->st_features), sizeof(geographic_msgs::MapFeature));
00112       }
00113       uint32_t props_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00114       props_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00115       props_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00116       props_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00117       offset += sizeof(this->props_length);
00118       if(props_lengthT > props_length)
00119         this->props = (geographic_msgs::KeyValue*)realloc(this->props, props_lengthT * sizeof(geographic_msgs::KeyValue));
00120       props_length = props_lengthT;
00121       for( uint32_t i = 0; i < props_length; i++){
00122       offset += this->st_props.deserialize(inbuffer + offset);
00123         memcpy( &(this->props[i]), &(this->st_props), sizeof(geographic_msgs::KeyValue));
00124       }
00125      return offset;
00126     }
00127 
00128     const char * getType(){ return "geographic_msgs/GeographicMap"; };
00129     const char * getMD5(){ return "0f4ce6d2ebf9ac9c7c4f3308f6ae0731"; };
00130 
00131   };
00132 
00133 }
00134 #endif