annop niponsiritham / ros_lib_kinetic

Dependencies:   BufferedSerial

Dependents:   mobile_robot mobile_robot_ver2

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MapMetaData.h Source File

MapMetaData.h

00001 #ifndef _ROS_nav_msgs_MapMetaData_h
00002 #define _ROS_nav_msgs_MapMetaData_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "ros/time.h"
00009 #include "geometry_msgs/Pose.h"
00010 
00011 namespace nav_msgs
00012 {
00013 
00014   class MapMetaData : public ros::Msg
00015   {
00016     public:
00017       typedef ros::Time _map_load_time_type;
00018       _map_load_time_type map_load_time;
00019       typedef float _resolution_type;
00020       _resolution_type resolution;
00021       typedef uint32_t _width_type;
00022       _width_type width;
00023       typedef uint32_t _height_type;
00024       _height_type height;
00025       typedef geometry_msgs::Pose _origin_type;
00026       _origin_type origin;
00027 
00028     MapMetaData():
00029       map_load_time(),
00030       resolution(0),
00031       width(0),
00032       height(0),
00033       origin()
00034     {
00035     }
00036 
00037     virtual int serialize(unsigned char *outbuffer) const
00038     {
00039       int offset = 0;
00040       *(outbuffer + offset + 0) = (this->map_load_time.sec >> (8 * 0)) & 0xFF;
00041       *(outbuffer + offset + 1) = (this->map_load_time.sec >> (8 * 1)) & 0xFF;
00042       *(outbuffer + offset + 2) = (this->map_load_time.sec >> (8 * 2)) & 0xFF;
00043       *(outbuffer + offset + 3) = (this->map_load_time.sec >> (8 * 3)) & 0xFF;
00044       offset += sizeof(this->map_load_time.sec);
00045       *(outbuffer + offset + 0) = (this->map_load_time.nsec >> (8 * 0)) & 0xFF;
00046       *(outbuffer + offset + 1) = (this->map_load_time.nsec >> (8 * 1)) & 0xFF;
00047       *(outbuffer + offset + 2) = (this->map_load_time.nsec >> (8 * 2)) & 0xFF;
00048       *(outbuffer + offset + 3) = (this->map_load_time.nsec >> (8 * 3)) & 0xFF;
00049       offset += sizeof(this->map_load_time.nsec);
00050       union {
00051         float real;
00052         uint32_t base;
00053       } u_resolution;
00054       u_resolution.real = this->resolution;
00055       *(outbuffer + offset + 0) = (u_resolution.base >> (8 * 0)) & 0xFF;
00056       *(outbuffer + offset + 1) = (u_resolution.base >> (8 * 1)) & 0xFF;
00057       *(outbuffer + offset + 2) = (u_resolution.base >> (8 * 2)) & 0xFF;
00058       *(outbuffer + offset + 3) = (u_resolution.base >> (8 * 3)) & 0xFF;
00059       offset += sizeof(this->resolution);
00060       *(outbuffer + offset + 0) = (this->width >> (8 * 0)) & 0xFF;
00061       *(outbuffer + offset + 1) = (this->width >> (8 * 1)) & 0xFF;
00062       *(outbuffer + offset + 2) = (this->width >> (8 * 2)) & 0xFF;
00063       *(outbuffer + offset + 3) = (this->width >> (8 * 3)) & 0xFF;
00064       offset += sizeof(this->width);
00065       *(outbuffer + offset + 0) = (this->height >> (8 * 0)) & 0xFF;
00066       *(outbuffer + offset + 1) = (this->height >> (8 * 1)) & 0xFF;
00067       *(outbuffer + offset + 2) = (this->height >> (8 * 2)) & 0xFF;
00068       *(outbuffer + offset + 3) = (this->height >> (8 * 3)) & 0xFF;
00069       offset += sizeof(this->height);
00070       offset += this->origin.serialize(outbuffer + offset);
00071       return offset;
00072     }
00073 
00074     virtual int deserialize(unsigned char *inbuffer)
00075     {
00076       int offset = 0;
00077       this->map_load_time.sec =  ((uint32_t) (*(inbuffer + offset)));
00078       this->map_load_time.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00079       this->map_load_time.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00080       this->map_load_time.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00081       offset += sizeof(this->map_load_time.sec);
00082       this->map_load_time.nsec =  ((uint32_t) (*(inbuffer + offset)));
00083       this->map_load_time.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00084       this->map_load_time.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00085       this->map_load_time.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00086       offset += sizeof(this->map_load_time.nsec);
00087       union {
00088         float real;
00089         uint32_t base;
00090       } u_resolution;
00091       u_resolution.base = 0;
00092       u_resolution.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00093       u_resolution.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00094       u_resolution.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00095       u_resolution.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00096       this->resolution = u_resolution.real;
00097       offset += sizeof(this->resolution);
00098       this->width =  ((uint32_t) (*(inbuffer + offset)));
00099       this->width |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00100       this->width |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00101       this->width |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00102       offset += sizeof(this->width);
00103       this->height =  ((uint32_t) (*(inbuffer + offset)));
00104       this->height |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00105       this->height |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00106       this->height |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00107       offset += sizeof(this->height);
00108       offset += this->origin.deserialize(inbuffer + offset);
00109      return offset;
00110     }
00111 
00112     const char * getType(){ return "nav_msgs/MapMetaData"; };
00113     const char * getMD5(){ return "10cfc8a2818024d3248802c00c95f11b"; };
00114 
00115   };
00116 
00117 }
00118 #endif