Go to the documentation of this file.00001 #ifndef ros_sensor_msgs_NavSatFix_h
00002 #define ros_sensor_msgs_NavSatFix_h
00003
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "../ros/msg.h"
00008 #include "std_msgs/Header.h"
00009 #include "sensor_msgs/NavSatStatus.h"
00010
00011 namespace sensor_msgs
00012 {
00013
00014 class NavSatFix : public ros::Msg
00015 {
00016 public:
00017 std_msgs::Header header;
00018 sensor_msgs::NavSatStatus status;
00019 float latitude;
00020 float longitude;
00021 float altitude;
00022 float position_covariance[9];
00023 unsigned char position_covariance_type;
00024 enum { COVARIANCE_TYPE_UNKNOWN = 0 };
00025 enum { COVARIANCE_TYPE_APPROXIMATED = 1 };
00026 enum { COVARIANCE_TYPE_DIAGONAL_KNOWN = 2 };
00027 enum { COVARIANCE_TYPE_KNOWN = 3 };
00028
00029 virtual int serialize(unsigned char *outbuffer)
00030 {
00031 int offset = 0;
00032 offset += this->header.serialize(outbuffer + offset);
00033 offset += this->status.serialize(outbuffer + offset);
00034 long * val_latitude = (long *) &(this->latitude);
00035 long exp_latitude = (((*val_latitude)>>23)&255);
00036 if(exp_latitude != 0)
00037 exp_latitude += 1023-127;
00038 long sig_latitude = *val_latitude;
00039 *(outbuffer + offset++) = 0;
00040 *(outbuffer + offset++) = 0;
00041 *(outbuffer + offset++) = 0;
00042 *(outbuffer + offset++) = (sig_latitude<<5) & 0xff;
00043 *(outbuffer + offset++) = (sig_latitude>>3) & 0xff;
00044 *(outbuffer + offset++) = (sig_latitude>>11) & 0xff;
00045 *(outbuffer + offset++) = ((exp_latitude<<4) & 0xF0) | ((sig_latitude>>19)&0x0F);
00046 *(outbuffer + offset++) = (exp_latitude>>4) & 0x7F;
00047 if(this->latitude < 0) *(outbuffer + offset -1) |= 0x80;
00048 long * val_longitude = (long *) &(this->longitude);
00049 long exp_longitude = (((*val_longitude)>>23)&255);
00050 if(exp_longitude != 0)
00051 exp_longitude += 1023-127;
00052 long sig_longitude = *val_longitude;
00053 *(outbuffer + offset++) = 0;
00054 *(outbuffer + offset++) = 0;
00055 *(outbuffer + offset++) = 0;
00056 *(outbuffer + offset++) = (sig_longitude<<5) & 0xff;
00057 *(outbuffer + offset++) = (sig_longitude>>3) & 0xff;
00058 *(outbuffer + offset++) = (sig_longitude>>11) & 0xff;
00059 *(outbuffer + offset++) = ((exp_longitude<<4) & 0xF0) | ((sig_longitude>>19)&0x0F);
00060 *(outbuffer + offset++) = (exp_longitude>>4) & 0x7F;
00061 if(this->longitude < 0) *(outbuffer + offset -1) |= 0x80;
00062 long * val_altitude = (long *) &(this->altitude);
00063 long exp_altitude = (((*val_altitude)>>23)&255);
00064 if(exp_altitude != 0)
00065 exp_altitude += 1023-127;
00066 long sig_altitude = *val_altitude;
00067 *(outbuffer + offset++) = 0;
00068 *(outbuffer + offset++) = 0;
00069 *(outbuffer + offset++) = 0;
00070 *(outbuffer + offset++) = (sig_altitude<<5) & 0xff;
00071 *(outbuffer + offset++) = (sig_altitude>>3) & 0xff;
00072 *(outbuffer + offset++) = (sig_altitude>>11) & 0xff;
00073 *(outbuffer + offset++) = ((exp_altitude<<4) & 0xF0) | ((sig_altitude>>19)&0x0F);
00074 *(outbuffer + offset++) = (exp_altitude>>4) & 0x7F;
00075 if(this->altitude < 0) *(outbuffer + offset -1) |= 0x80;
00076 unsigned char * position_covariance_val = (unsigned char *) this->position_covariance;
00077 for( unsigned char i = 0; i < 9; i++){
00078 long * val_position_covariancei = (long *) &(this->position_covariance[i]);
00079 long exp_position_covariancei = (((*val_position_covariancei)>>23)&255);
00080 if(exp_position_covariancei != 0)
00081 exp_position_covariancei += 1023-127;
00082 long sig_position_covariancei = *val_position_covariancei;
00083 *(outbuffer + offset++) = 0;
00084 *(outbuffer + offset++) = 0;
00085 *(outbuffer + offset++) = 0;
00086 *(outbuffer + offset++) = (sig_position_covariancei<<5) & 0xff;
00087 *(outbuffer + offset++) = (sig_position_covariancei>>3) & 0xff;
00088 *(outbuffer + offset++) = (sig_position_covariancei>>11) & 0xff;
00089 *(outbuffer + offset++) = ((exp_position_covariancei<<4) & 0xF0) | ((sig_position_covariancei>>19)&0x0F);
00090 *(outbuffer + offset++) = (exp_position_covariancei>>4) & 0x7F;
00091 if(this->position_covariance[i] < 0) *(outbuffer + offset -1) |= 0x80;
00092 }
00093 union {
00094 unsigned char real;
00095 unsigned char base;
00096 } u_position_covariance_type;
00097 u_position_covariance_type.real = this->position_covariance_type;
00098 *(outbuffer + offset + 0) = (u_position_covariance_type.base >> (8 * 0)) & 0xFF;
00099 offset += sizeof(this->position_covariance_type);
00100 return offset;
00101 }
00102
00103 virtual int deserialize(unsigned char *inbuffer)
00104 {
00105 int offset = 0;
00106 offset += this->header.deserialize(inbuffer + offset);
00107 offset += this->status.deserialize(inbuffer + offset);
00108 unsigned long * val_latitude = (unsigned long*) &(this->latitude);
00109 offset += 3;
00110 *val_latitude = ((unsigned long)(*(inbuffer + offset++))>>5 & 0x07);
00111 *val_latitude |= ((unsigned long)(*(inbuffer + offset++)) & 0xff)<<3;
00112 *val_latitude |= ((unsigned long)(*(inbuffer + offset++)) & 0xff)<<11;
00113 *val_latitude |= ((unsigned long)(*(inbuffer + offset)) & 0x0f)<<19;
00114 unsigned long exp_latitude = ((unsigned long)(*(inbuffer + offset++))&0xf0)>>4;
00115 exp_latitude |= ((unsigned long)(*(inbuffer + offset)) & 0x7f)<<4;
00116 if(exp_latitude !=0)
00117 *val_latitude |= ((exp_latitude)-1023+127)<<23;
00118 if( ((*(inbuffer+offset++)) & 0x80) > 0) this->latitude = -this->latitude;
00119 unsigned long * val_longitude = (unsigned long*) &(this->longitude);
00120 offset += 3;
00121 *val_longitude = ((unsigned long)(*(inbuffer + offset++))>>5 & 0x07);
00122 *val_longitude |= ((unsigned long)(*(inbuffer + offset++)) & 0xff)<<3;
00123 *val_longitude |= ((unsigned long)(*(inbuffer + offset++)) & 0xff)<<11;
00124 *val_longitude |= ((unsigned long)(*(inbuffer + offset)) & 0x0f)<<19;
00125 unsigned long exp_longitude = ((unsigned long)(*(inbuffer + offset++))&0xf0)>>4;
00126 exp_longitude |= ((unsigned long)(*(inbuffer + offset)) & 0x7f)<<4;
00127 if(exp_longitude !=0)
00128 *val_longitude |= ((exp_longitude)-1023+127)<<23;
00129 if( ((*(inbuffer+offset++)) & 0x80) > 0) this->longitude = -this->longitude;
00130 unsigned long * val_altitude = (unsigned long*) &(this->altitude);
00131 offset += 3;
00132 *val_altitude = ((unsigned long)(*(inbuffer + offset++))>>5 & 0x07);
00133 *val_altitude |= ((unsigned long)(*(inbuffer + offset++)) & 0xff)<<3;
00134 *val_altitude |= ((unsigned long)(*(inbuffer + offset++)) & 0xff)<<11;
00135 *val_altitude |= ((unsigned long)(*(inbuffer + offset)) & 0x0f)<<19;
00136 unsigned long exp_altitude = ((unsigned long)(*(inbuffer + offset++))&0xf0)>>4;
00137 exp_altitude |= ((unsigned long)(*(inbuffer + offset)) & 0x7f)<<4;
00138 if(exp_altitude !=0)
00139 *val_altitude |= ((exp_altitude)-1023+127)<<23;
00140 if( ((*(inbuffer+offset++)) & 0x80) > 0) this->altitude = -this->altitude;
00141 unsigned char * position_covariance_val = (unsigned char *) this->position_covariance;
00142 for( unsigned char i = 0; i < 9; i++){
00143 unsigned long * val_position_covariancei = (unsigned long*) &(this->position_covariance[i]);
00144 offset += 3;
00145 *val_position_covariancei = ((unsigned long)(*(inbuffer + offset++))>>5 & 0x07);
00146 *val_position_covariancei |= ((unsigned long)(*(inbuffer + offset++)) & 0xff)<<3;
00147 *val_position_covariancei |= ((unsigned long)(*(inbuffer + offset++)) & 0xff)<<11;
00148 *val_position_covariancei |= ((unsigned long)(*(inbuffer + offset)) & 0x0f)<<19;
00149 unsigned long exp_position_covariancei = ((unsigned long)(*(inbuffer + offset++))&0xf0)>>4;
00150 exp_position_covariancei |= ((unsigned long)(*(inbuffer + offset)) & 0x7f)<<4;
00151 if(exp_position_covariancei !=0)
00152 *val_position_covariancei |= ((exp_position_covariancei)-1023+127)<<23;
00153 if( ((*(inbuffer+offset++)) & 0x80) > 0) this->position_covariance[i] = -this->position_covariance[i];
00154 }
00155 union {
00156 unsigned char real;
00157 unsigned char base;
00158 } u_position_covariance_type;
00159 u_position_covariance_type.base = 0;
00160 u_position_covariance_type.base |= ((typeof(u_position_covariance_type.base)) (*(inbuffer + offset + 0))) << (8 * 0);
00161 this->position_covariance_type = u_position_covariance_type.real;
00162 offset += sizeof(this->position_covariance_type);
00163 return offset;
00164 }
00165
00166 const char * getType(){ return "sensor_msgs/NavSatFix"; };
00167
00168 };
00169
00170 }
00171 #endif