Statistics
| Branch: | Revision:

root / quad2 / arduino / src / ros_lib / sensor_msgs / NavSatFix.h @ c1426757

History | View | Annotate | Download (7.61 KB)

1
#ifndef _ROS_sensor_msgs_NavSatFix_h
2
#define _ROS_sensor_msgs_NavSatFix_h
3

    
4
#include <stdint.h>
5
#include <string.h>
6
#include <stdlib.h>
7
#include "ros/msg.h"
8
#include "std_msgs/Header.h"
9
#include "sensor_msgs/NavSatStatus.h"
10

    
11
namespace sensor_msgs
12
{
13

    
14
  class NavSatFix : public ros::Msg
15
  {
16
    public:
17
      std_msgs::Header header;
18
      sensor_msgs::NavSatStatus status;
19
      float latitude;
20
      float longitude;
21
      float altitude;
22
      float position_covariance[9];
23
      uint8_t position_covariance_type;
24
      enum { COVARIANCE_TYPE_UNKNOWN =  0 };
25
      enum { COVARIANCE_TYPE_APPROXIMATED =  1 };
26
      enum { COVARIANCE_TYPE_DIAGONAL_KNOWN =  2 };
27
      enum { COVARIANCE_TYPE_KNOWN =  3 };
28

    
29
    virtual int serialize(unsigned char *outbuffer) const
30
    {
31
      int offset = 0;
32
      offset += this->header.serialize(outbuffer + offset);
33
      offset += this->status.serialize(outbuffer + offset);
34
      int32_t * val_latitude = (long *) &(this->latitude);
35
      int32_t exp_latitude = (((*val_latitude)>>23)&255);
36
      if(exp_latitude != 0)
37
        exp_latitude += 1023-127;
38
      int32_t sig_latitude = *val_latitude;
39
      *(outbuffer + offset++) = 0;
40
      *(outbuffer + offset++) = 0;
41
      *(outbuffer + offset++) = 0;
42
      *(outbuffer + offset++) = (sig_latitude<<5) & 0xff;
43
      *(outbuffer + offset++) = (sig_latitude>>3) & 0xff;
44
      *(outbuffer + offset++) = (sig_latitude>>11) & 0xff;
45
      *(outbuffer + offset++) = ((exp_latitude<<4) & 0xF0) | ((sig_latitude>>19)&0x0F);
46
      *(outbuffer + offset++) = (exp_latitude>>4) & 0x7F;
47
      if(this->latitude < 0) *(outbuffer + offset -1) |= 0x80;
48
      int32_t * val_longitude = (long *) &(this->longitude);
49
      int32_t exp_longitude = (((*val_longitude)>>23)&255);
50
      if(exp_longitude != 0)
51
        exp_longitude += 1023-127;
52
      int32_t sig_longitude = *val_longitude;
53
      *(outbuffer + offset++) = 0;
54
      *(outbuffer + offset++) = 0;
55
      *(outbuffer + offset++) = 0;
56
      *(outbuffer + offset++) = (sig_longitude<<5) & 0xff;
57
      *(outbuffer + offset++) = (sig_longitude>>3) & 0xff;
58
      *(outbuffer + offset++) = (sig_longitude>>11) & 0xff;
59
      *(outbuffer + offset++) = ((exp_longitude<<4) & 0xF0) | ((sig_longitude>>19)&0x0F);
60
      *(outbuffer + offset++) = (exp_longitude>>4) & 0x7F;
61
      if(this->longitude < 0) *(outbuffer + offset -1) |= 0x80;
62
      int32_t * val_altitude = (long *) &(this->altitude);
63
      int32_t exp_altitude = (((*val_altitude)>>23)&255);
64
      if(exp_altitude != 0)
65
        exp_altitude += 1023-127;
66
      int32_t sig_altitude = *val_altitude;
67
      *(outbuffer + offset++) = 0;
68
      *(outbuffer + offset++) = 0;
69
      *(outbuffer + offset++) = 0;
70
      *(outbuffer + offset++) = (sig_altitude<<5) & 0xff;
71
      *(outbuffer + offset++) = (sig_altitude>>3) & 0xff;
72
      *(outbuffer + offset++) = (sig_altitude>>11) & 0xff;
73
      *(outbuffer + offset++) = ((exp_altitude<<4) & 0xF0) | ((sig_altitude>>19)&0x0F);
74
      *(outbuffer + offset++) = (exp_altitude>>4) & 0x7F;
75
      if(this->altitude < 0) *(outbuffer + offset -1) |= 0x80;
76
      unsigned char * position_covariance_val = (unsigned char *) this->position_covariance;
77
      for( uint8_t i = 0; i < 9; i++){
78
      int32_t * val_position_covariancei = (long *) &(this->position_covariance[i]);
79
      int32_t exp_position_covariancei = (((*val_position_covariancei)>>23)&255);
80
      if(exp_position_covariancei != 0)
81
        exp_position_covariancei += 1023-127;
82
      int32_t sig_position_covariancei = *val_position_covariancei;
83
      *(outbuffer + offset++) = 0;
84
      *(outbuffer + offset++) = 0;
85
      *(outbuffer + offset++) = 0;
86
      *(outbuffer + offset++) = (sig_position_covariancei<<5) & 0xff;
87
      *(outbuffer + offset++) = (sig_position_covariancei>>3) & 0xff;
88
      *(outbuffer + offset++) = (sig_position_covariancei>>11) & 0xff;
89
      *(outbuffer + offset++) = ((exp_position_covariancei<<4) & 0xF0) | ((sig_position_covariancei>>19)&0x0F);
90
      *(outbuffer + offset++) = (exp_position_covariancei>>4) & 0x7F;
91
      if(this->position_covariance[i] < 0) *(outbuffer + offset -1) |= 0x80;
92
      }
93
      *(outbuffer + offset + 0) = (this->position_covariance_type >> (8 * 0)) & 0xFF;
94
      offset += sizeof(this->position_covariance_type);
95
      return offset;
96
    }
97

    
98
    virtual int deserialize(unsigned char *inbuffer)
99
    {
100
      int offset = 0;
101
      offset += this->header.deserialize(inbuffer + offset);
102
      offset += this->status.deserialize(inbuffer + offset);
103
      uint32_t * val_latitude = (uint32_t*) &(this->latitude);
104
      offset += 3;
105
      *val_latitude = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
106
      *val_latitude |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
107
      *val_latitude |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
108
      *val_latitude |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
109
      uint32_t exp_latitude = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
110
      exp_latitude |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
111
      if(exp_latitude !=0)
112
        *val_latitude |= ((exp_latitude)-1023+127)<<23;
113
      if( ((*(inbuffer+offset++)) & 0x80) > 0) this->latitude = -this->latitude;
114
      uint32_t * val_longitude = (uint32_t*) &(this->longitude);
115
      offset += 3;
116
      *val_longitude = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
117
      *val_longitude |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
118
      *val_longitude |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
119
      *val_longitude |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
120
      uint32_t exp_longitude = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
121
      exp_longitude |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
122
      if(exp_longitude !=0)
123
        *val_longitude |= ((exp_longitude)-1023+127)<<23;
124
      if( ((*(inbuffer+offset++)) & 0x80) > 0) this->longitude = -this->longitude;
125
      uint32_t * val_altitude = (uint32_t*) &(this->altitude);
126
      offset += 3;
127
      *val_altitude = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
128
      *val_altitude |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
129
      *val_altitude |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
130
      *val_altitude |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
131
      uint32_t exp_altitude = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
132
      exp_altitude |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
133
      if(exp_altitude !=0)
134
        *val_altitude |= ((exp_altitude)-1023+127)<<23;
135
      if( ((*(inbuffer+offset++)) & 0x80) > 0) this->altitude = -this->altitude;
136
      uint8_t * position_covariance_val = (uint8_t*) this->position_covariance;
137
      for( uint8_t i = 0; i < 9; i++){
138
      uint32_t * val_position_covariancei = (uint32_t*) &(this->position_covariance[i]);
139
      offset += 3;
140
      *val_position_covariancei = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
141
      *val_position_covariancei |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
142
      *val_position_covariancei |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
143
      *val_position_covariancei |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
144
      uint32_t exp_position_covariancei = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
145
      exp_position_covariancei |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
146
      if(exp_position_covariancei !=0)
147
        *val_position_covariancei |= ((exp_position_covariancei)-1023+127)<<23;
148
      if( ((*(inbuffer+offset++)) & 0x80) > 0) this->position_covariance[i] = -this->position_covariance[i];
149
      }
150
      this->position_covariance_type |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
151
      offset += sizeof(this->position_covariance_type);
152
     return offset;
153
    }
154

    
155
    const char * getType(){ return "sensor_msgs/NavSatFix"; };
156
    const char * getMD5(){ return "2d3a8cd499b9b4a0249fb98fd05cfa48"; };
157

    
158
  };
159

    
160
}
161
#endif