lizi_gps.h
Go to the documentation of this file.
00001 #ifndef _ROS_lizi_lizi_gps_h
00002 #define _ROS_lizi_lizi_gps_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 
00009 namespace lizi
00010 {
00011 
00012   class lizi_gps : public ros::Msg
00013   {
00014     public:
00015       float Lat;
00016       float Lon;
00017       float Alt;
00018       int16_t Sats;
00019       int16_t HDOP;
00020       int16_t Status;
00021 
00022     virtual int serialize(unsigned char *outbuffer) const
00023     {
00024       int offset = 0;
00025       int32_t * val_Lat = (int32_t *) &(this->Lat);
00026       int32_t exp_Lat = (((*val_Lat)>>23)&255);
00027       if(exp_Lat != 0)
00028         exp_Lat += 1023-127;
00029       int32_t sig_Lat = *val_Lat;
00030       *(outbuffer + offset++) = 0;
00031       *(outbuffer + offset++) = 0;
00032       *(outbuffer + offset++) = 0;
00033       *(outbuffer + offset++) = (sig_Lat<<5) & 0xff;
00034       *(outbuffer + offset++) = (sig_Lat>>3) & 0xff;
00035       *(outbuffer + offset++) = (sig_Lat>>11) & 0xff;
00036       *(outbuffer + offset++) = ((exp_Lat<<4) & 0xF0) | ((sig_Lat>>19)&0x0F);
00037       *(outbuffer + offset++) = (exp_Lat>>4) & 0x7F;
00038       if(this->Lat < 0) *(outbuffer + offset -1) |= 0x80;
00039       int32_t * val_Lon = (int32_t *) &(this->Lon);
00040       int32_t exp_Lon = (((*val_Lon)>>23)&255);
00041       if(exp_Lon != 0)
00042         exp_Lon += 1023-127;
00043       int32_t sig_Lon = *val_Lon;
00044       *(outbuffer + offset++) = 0;
00045       *(outbuffer + offset++) = 0;
00046       *(outbuffer + offset++) = 0;
00047       *(outbuffer + offset++) = (sig_Lon<<5) & 0xff;
00048       *(outbuffer + offset++) = (sig_Lon>>3) & 0xff;
00049       *(outbuffer + offset++) = (sig_Lon>>11) & 0xff;
00050       *(outbuffer + offset++) = ((exp_Lon<<4) & 0xF0) | ((sig_Lon>>19)&0x0F);
00051       *(outbuffer + offset++) = (exp_Lon>>4) & 0x7F;
00052       if(this->Lon < 0) *(outbuffer + offset -1) |= 0x80;
00053       union {
00054         float real;
00055         uint32_t base;
00056       } u_Alt;
00057       u_Alt.real = this->Alt;
00058       *(outbuffer + offset + 0) = (u_Alt.base >> (8 * 0)) & 0xFF;
00059       *(outbuffer + offset + 1) = (u_Alt.base >> (8 * 1)) & 0xFF;
00060       *(outbuffer + offset + 2) = (u_Alt.base >> (8 * 2)) & 0xFF;
00061       *(outbuffer + offset + 3) = (u_Alt.base >> (8 * 3)) & 0xFF;
00062       offset += sizeof(this->Alt);
00063       union {
00064         int16_t real;
00065         uint16_t base;
00066       } u_Sats;
00067       u_Sats.real = this->Sats;
00068       *(outbuffer + offset + 0) = (u_Sats.base >> (8 * 0)) & 0xFF;
00069       *(outbuffer + offset + 1) = (u_Sats.base >> (8 * 1)) & 0xFF;
00070       offset += sizeof(this->Sats);
00071       union {
00072         int16_t real;
00073         uint16_t base;
00074       } u_HDOP;
00075       u_HDOP.real = this->HDOP;
00076       *(outbuffer + offset + 0) = (u_HDOP.base >> (8 * 0)) & 0xFF;
00077       *(outbuffer + offset + 1) = (u_HDOP.base >> (8 * 1)) & 0xFF;
00078       offset += sizeof(this->HDOP);
00079       union {
00080         int16_t real;
00081         uint16_t base;
00082       } u_Status;
00083       u_Status.real = this->Status;
00084       *(outbuffer + offset + 0) = (u_Status.base >> (8 * 0)) & 0xFF;
00085       *(outbuffer + offset + 1) = (u_Status.base >> (8 * 1)) & 0xFF;
00086       offset += sizeof(this->Status);
00087       return offset;
00088     }
00089 
00090     virtual int deserialize(unsigned char *inbuffer)
00091     {
00092       int offset = 0;
00093       uint32_t * val_Lat = (uint32_t*) &(this->Lat);
00094       offset += 3;
00095       *val_Lat = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
00096       *val_Lat |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
00097       *val_Lat |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
00098       *val_Lat |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
00099       uint32_t exp_Lat = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
00100       exp_Lat |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
00101       if(exp_Lat !=0)
00102         *val_Lat |= ((exp_Lat)-1023+127)<<23;
00103       if( ((*(inbuffer+offset++)) & 0x80) > 0) this->Lat = -this->Lat;
00104       uint32_t * val_Lon = (uint32_t*) &(this->Lon);
00105       offset += 3;
00106       *val_Lon = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
00107       *val_Lon |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
00108       *val_Lon |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
00109       *val_Lon |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
00110       uint32_t exp_Lon = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
00111       exp_Lon |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
00112       if(exp_Lon !=0)
00113         *val_Lon |= ((exp_Lon)-1023+127)<<23;
00114       if( ((*(inbuffer+offset++)) & 0x80) > 0) this->Lon = -this->Lon;
00115       union {
00116         float real;
00117         uint32_t base;
00118       } u_Alt;
00119       u_Alt.base = 0;
00120       u_Alt.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00121       u_Alt.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00122       u_Alt.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00123       u_Alt.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00124       this->Alt = u_Alt.real;
00125       offset += sizeof(this->Alt);
00126       union {
00127         int16_t real;
00128         uint16_t base;
00129       } u_Sats;
00130       u_Sats.base = 0;
00131       u_Sats.base |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
00132       u_Sats.base |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00133       this->Sats = u_Sats.real;
00134       offset += sizeof(this->Sats);
00135       union {
00136         int16_t real;
00137         uint16_t base;
00138       } u_HDOP;
00139       u_HDOP.base = 0;
00140       u_HDOP.base |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
00141       u_HDOP.base |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00142       this->HDOP = u_HDOP.real;
00143       offset += sizeof(this->HDOP);
00144       union {
00145         int16_t real;
00146         uint16_t base;
00147       } u_Status;
00148       u_Status.base = 0;
00149       u_Status.base |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
00150       u_Status.base |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00151       this->Status = u_Status.real;
00152       offset += sizeof(this->Status);
00153      return offset;
00154     }
00155 
00156     const char * getType(){ return "lizi/lizi_gps"; };
00157     const char * getMD5(){ return "b6b3576ebfcb04caffd96f3cf662f564"; };
00158 
00159   };
00160 
00161 }
00162 #endif


ric_mc
Author(s): RoboTiCan
autogenerated on Thu Aug 27 2015 14:39:49