Go to the documentation of this file.00001 #ifndef _ROS_wiimote_IrSourceInfo_h
00002 #define _ROS_wiimote_IrSourceInfo_h
00003
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008
00009 namespace wiimote
00010 {
00011
00012 class IrSourceInfo : public ros::Msg
00013 {
00014 public:
00015 float x;
00016 float y;
00017 int64_t ir_size;
00018
00019 virtual int serialize(unsigned char *outbuffer) const
00020 {
00021 int offset = 0;
00022 int32_t * val_x = (int32_t *) &(this->x);
00023 int32_t exp_x = (((*val_x)>>23)&255);
00024 if(exp_x != 0)
00025 exp_x += 1023-127;
00026 int32_t 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 int32_t * val_y = (int32_t *) &(this->y);
00037 int32_t exp_y = (((*val_y)>>23)&255);
00038 if(exp_y != 0)
00039 exp_y += 1023-127;
00040 int32_t 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 union {
00051 int64_t real;
00052 uint64_t base;
00053 } u_ir_size;
00054 u_ir_size.real = this->ir_size;
00055 *(outbuffer + offset + 0) = (u_ir_size.base >> (8 * 0)) & 0xFF;
00056 *(outbuffer + offset + 1) = (u_ir_size.base >> (8 * 1)) & 0xFF;
00057 *(outbuffer + offset + 2) = (u_ir_size.base >> (8 * 2)) & 0xFF;
00058 *(outbuffer + offset + 3) = (u_ir_size.base >> (8 * 3)) & 0xFF;
00059 *(outbuffer + offset + 4) = (u_ir_size.base >> (8 * 4)) & 0xFF;
00060 *(outbuffer + offset + 5) = (u_ir_size.base >> (8 * 5)) & 0xFF;
00061 *(outbuffer + offset + 6) = (u_ir_size.base >> (8 * 6)) & 0xFF;
00062 *(outbuffer + offset + 7) = (u_ir_size.base >> (8 * 7)) & 0xFF;
00063 offset += sizeof(this->ir_size);
00064 return offset;
00065 }
00066
00067 virtual int deserialize(unsigned char *inbuffer)
00068 {
00069 int offset = 0;
00070 uint32_t * val_x = (uint32_t*) &(this->x);
00071 offset += 3;
00072 *val_x = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
00073 *val_x |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
00074 *val_x |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
00075 *val_x |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
00076 uint32_t exp_x = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
00077 exp_x |= ((uint32_t)(*(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 uint32_t * val_y = (uint32_t*) &(this->y);
00082 offset += 3;
00083 *val_y = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
00084 *val_y |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
00085 *val_y |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
00086 *val_y |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
00087 uint32_t exp_y = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
00088 exp_y |= ((uint32_t)(*(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 union {
00093 int64_t real;
00094 uint64_t base;
00095 } u_ir_size;
00096 u_ir_size.base = 0;
00097 u_ir_size.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00098 u_ir_size.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00099 u_ir_size.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00100 u_ir_size.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00101 u_ir_size.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00102 u_ir_size.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00103 u_ir_size.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00104 u_ir_size.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00105 this->ir_size = u_ir_size.real;
00106 offset += sizeof(this->ir_size);
00107 return offset;
00108 }
00109
00110 const char * getType(){ return "wiimote/IrSourceInfo"; };
00111 const char * getMD5(){ return "95274ca88b9f008b99984b9a61d2772e"; };
00112
00113 };
00114
00115 }
00116 #endif