Go to the documentation of this file.00001 #ifndef ros_geometry_msgs_Pose2D_h
00002 #define ros_geometry_msgs_Pose2D_h
00003
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "../ros/msg.h"
00008
00009 namespace geometry_msgs
00010 {
00011
00012 class Pose2D : public ros::Msg
00013 {
00014 public:
00015 float x;
00016 float y;
00017 float theta;
00018
00019 virtual int serialize(unsigned char *outbuffer)
00020 {
00021 int offset = 0;
00022 long * val_x = (long *) &(this->x);
00023 long exp_x = (((*val_x)>>23)&255);
00024 if(exp_x != 0)
00025 exp_x += 1023-127;
00026 long sig_x = *val_x;
00027 *(outbuffer + offset++) = 0;
00028 *(outbuffer + offset++) = 0;
00029 *(outbuffer + offset++) = 0;
00030 *(outbuffer + offset++) = (sig_x<<5) & 0xff;
00031 *(outbuffer + offset++) = (sig_x>>3) & 0xff;
00032 *(outbuffer + offset++) = (sig_x>>11) & 0xff;
00033 *(outbuffer + offset++) = ((exp_x<<4) & 0xF0) | ((sig_x>>19)&0x0F);
00034 *(outbuffer + offset++) = (exp_x>>4) & 0x7F;
00035 if(this->x < 0) *(outbuffer + offset -1) |= 0x80;
00036 long * val_y = (long *) &(this->y);
00037 long exp_y = (((*val_y)>>23)&255);
00038 if(exp_y != 0)
00039 exp_y += 1023-127;
00040 long sig_y = *val_y;
00041 *(outbuffer + offset++) = 0;
00042 *(outbuffer + offset++) = 0;
00043 *(outbuffer + offset++) = 0;
00044 *(outbuffer + offset++) = (sig_y<<5) & 0xff;
00045 *(outbuffer + offset++) = (sig_y>>3) & 0xff;
00046 *(outbuffer + offset++) = (sig_y>>11) & 0xff;
00047 *(outbuffer + offset++) = ((exp_y<<4) & 0xF0) | ((sig_y>>19)&0x0F);
00048 *(outbuffer + offset++) = (exp_y>>4) & 0x7F;
00049 if(this->y < 0) *(outbuffer + offset -1) |= 0x80;
00050 long * val_theta = (long *) &(this->theta);
00051 long exp_theta = (((*val_theta)>>23)&255);
00052 if(exp_theta != 0)
00053 exp_theta += 1023-127;
00054 long sig_theta = *val_theta;
00055 *(outbuffer + offset++) = 0;
00056 *(outbuffer + offset++) = 0;
00057 *(outbuffer + offset++) = 0;
00058 *(outbuffer + offset++) = (sig_theta<<5) & 0xff;
00059 *(outbuffer + offset++) = (sig_theta>>3) & 0xff;
00060 *(outbuffer + offset++) = (sig_theta>>11) & 0xff;
00061 *(outbuffer + offset++) = ((exp_theta<<4) & 0xF0) | ((sig_theta>>19)&0x0F);
00062 *(outbuffer + offset++) = (exp_theta>>4) & 0x7F;
00063 if(this->theta < 0) *(outbuffer + offset -1) |= 0x80;
00064 return offset;
00065 }
00066
00067 virtual int deserialize(unsigned char *inbuffer)
00068 {
00069 int offset = 0;
00070 unsigned long * val_x = (unsigned long*) &(this->x);
00071 offset += 3;
00072 *val_x = ((unsigned long)(*(inbuffer + offset++))>>5 & 0x07);
00073 *val_x |= ((unsigned long)(*(inbuffer + offset++)) & 0xff)<<3;
00074 *val_x |= ((unsigned long)(*(inbuffer + offset++)) & 0xff)<<11;
00075 *val_x |= ((unsigned long)(*(inbuffer + offset)) & 0x0f)<<19;
00076 unsigned long exp_x = ((unsigned long)(*(inbuffer + offset++))&0xf0)>>4;
00077 exp_x |= ((unsigned long)(*(inbuffer + offset)) & 0x7f)<<4;
00078 if(exp_x !=0)
00079 *val_x |= ((exp_x)-1023+127)<<23;
00080 if( ((*(inbuffer+offset++)) & 0x80) > 0) this->x = -this->x;
00081 unsigned long * val_y = (unsigned long*) &(this->y);
00082 offset += 3;
00083 *val_y = ((unsigned long)(*(inbuffer + offset++))>>5 & 0x07);
00084 *val_y |= ((unsigned long)(*(inbuffer + offset++)) & 0xff)<<3;
00085 *val_y |= ((unsigned long)(*(inbuffer + offset++)) & 0xff)<<11;
00086 *val_y |= ((unsigned long)(*(inbuffer + offset)) & 0x0f)<<19;
00087 unsigned long exp_y = ((unsigned long)(*(inbuffer + offset++))&0xf0)>>4;
00088 exp_y |= ((unsigned long)(*(inbuffer + offset)) & 0x7f)<<4;
00089 if(exp_y !=0)
00090 *val_y |= ((exp_y)-1023+127)<<23;
00091 if( ((*(inbuffer+offset++)) & 0x80) > 0) this->y = -this->y;
00092 unsigned long * val_theta = (unsigned long*) &(this->theta);
00093 offset += 3;
00094 *val_theta = ((unsigned long)(*(inbuffer + offset++))>>5 & 0x07);
00095 *val_theta |= ((unsigned long)(*(inbuffer + offset++)) & 0xff)<<3;
00096 *val_theta |= ((unsigned long)(*(inbuffer + offset++)) & 0xff)<<11;
00097 *val_theta |= ((unsigned long)(*(inbuffer + offset)) & 0x0f)<<19;
00098 unsigned long exp_theta = ((unsigned long)(*(inbuffer + offset++))&0xf0)>>4;
00099 exp_theta |= ((unsigned long)(*(inbuffer + offset)) & 0x7f)<<4;
00100 if(exp_theta !=0)
00101 *val_theta |= ((exp_theta)-1023+127)<<23;
00102 if( ((*(inbuffer+offset++)) & 0x80) > 0) this->theta = -this->theta;
00103 return offset;
00104 }
00105
00106 const char * getType(){ return "geometry_msgs/Pose2D"; };
00107
00108 };
00109
00110 }
00111 #endif