Go to the documentation of this file.00001 #ifndef ros_sensor_msgs_PointField_h
00002 #define ros_sensor_msgs_PointField_h
00003
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "../ros/msg.h"
00008
00009 namespace sensor_msgs
00010 {
00011
00012 class PointField : public ros::Msg
00013 {
00014 public:
00015 char * name;
00016 unsigned long offset;
00017 unsigned char datatype;
00018 unsigned long count;
00019 enum { INT8 = 1 };
00020 enum { UINT8 = 2 };
00021 enum { INT16 = 3 };
00022 enum { UINT16 = 4 };
00023 enum { INT32 = 5 };
00024 enum { UINT32 = 6 };
00025 enum { FLOAT32 = 7 };
00026 enum { FLOAT64 = 8 };
00027
00028 virtual int serialize(unsigned char *outbuffer)
00029 {
00030 int offset = 0;
00031 long * length_name = (long *)(outbuffer + offset);
00032 *length_name = strlen( (const char*) this->name);
00033 offset += 4;
00034 memcpy(outbuffer + offset, this->name, *length_name);
00035 offset += *length_name;
00036 union {
00037 unsigned long real;
00038 unsigned long base;
00039 } u_offset;
00040 u_offset.real = this->offset;
00041 *(outbuffer + offset + 0) = (u_offset.base >> (8 * 0)) & 0xFF;
00042 *(outbuffer + offset + 1) = (u_offset.base >> (8 * 1)) & 0xFF;
00043 *(outbuffer + offset + 2) = (u_offset.base >> (8 * 2)) & 0xFF;
00044 *(outbuffer + offset + 3) = (u_offset.base >> (8 * 3)) & 0xFF;
00045 offset += sizeof(this->offset);
00046 union {
00047 unsigned char real;
00048 unsigned char base;
00049 } u_datatype;
00050 u_datatype.real = this->datatype;
00051 *(outbuffer + offset + 0) = (u_datatype.base >> (8 * 0)) & 0xFF;
00052 offset += sizeof(this->datatype);
00053 union {
00054 unsigned long real;
00055 unsigned long base;
00056 } u_count;
00057 u_count.real = this->count;
00058 *(outbuffer + offset + 0) = (u_count.base >> (8 * 0)) & 0xFF;
00059 *(outbuffer + offset + 1) = (u_count.base >> (8 * 1)) & 0xFF;
00060 *(outbuffer + offset + 2) = (u_count.base >> (8 * 2)) & 0xFF;
00061 *(outbuffer + offset + 3) = (u_count.base >> (8 * 3)) & 0xFF;
00062 offset += sizeof(this->count);
00063 return offset;
00064 }
00065
00066 virtual int deserialize(unsigned char *inbuffer)
00067 {
00068 int offset = 0;
00069 uint32_t length_name = *(uint32_t *)(inbuffer + offset);
00070 offset += 4;
00071 for(unsigned int k= offset; k< offset+length_name; ++k){
00072 inbuffer[k-1]=inbuffer[k];
00073 }
00074 inbuffer[offset+length_name-1]=0;
00075 this->name = (char *)(inbuffer + offset-1);
00076 offset += length_name;
00077 union {
00078 unsigned long real;
00079 unsigned long base;
00080 } u_offset;
00081 u_offset.base = 0;
00082 u_offset.base |= ((typeof(u_offset.base)) (*(inbuffer + offset + 0))) << (8 * 0);
00083 u_offset.base |= ((typeof(u_offset.base)) (*(inbuffer + offset + 1))) << (8 * 1);
00084 u_offset.base |= ((typeof(u_offset.base)) (*(inbuffer + offset + 2))) << (8 * 2);
00085 u_offset.base |= ((typeof(u_offset.base)) (*(inbuffer + offset + 3))) << (8 * 3);
00086 this->offset = u_offset.real;
00087 offset += sizeof(this->offset);
00088 union {
00089 unsigned char real;
00090 unsigned char base;
00091 } u_datatype;
00092 u_datatype.base = 0;
00093 u_datatype.base |= ((typeof(u_datatype.base)) (*(inbuffer + offset + 0))) << (8 * 0);
00094 this->datatype = u_datatype.real;
00095 offset += sizeof(this->datatype);
00096 union {
00097 unsigned long real;
00098 unsigned long base;
00099 } u_count;
00100 u_count.base = 0;
00101 u_count.base |= ((typeof(u_count.base)) (*(inbuffer + offset + 0))) << (8 * 0);
00102 u_count.base |= ((typeof(u_count.base)) (*(inbuffer + offset + 1))) << (8 * 1);
00103 u_count.base |= ((typeof(u_count.base)) (*(inbuffer + offset + 2))) << (8 * 2);
00104 u_count.base |= ((typeof(u_count.base)) (*(inbuffer + offset + 3))) << (8 * 3);
00105 this->count = u_count.real;
00106 offset += sizeof(this->count);
00107 return offset;
00108 }
00109
00110 const char * getType(){ return "sensor_msgs/PointField"; };
00111
00112 };
00113
00114 }
00115 #endif