Project

General

Profile

Statistics
| Branch: | Revision:

root / quad2 / arduino / src / ros_lib / geometry_msgs / PoseWithCovariance.h @ c1426757

History | View | Annotate | Download (2.51 KB)

1
#ifndef _ROS_geometry_msgs_PoseWithCovariance_h
2
#define _ROS_geometry_msgs_PoseWithCovariance_h
3

    
4
#include <stdint.h>
5
#include <string.h>
6
#include <stdlib.h>
7
#include "ros/msg.h"
8
#include "geometry_msgs/Pose.h"
9

    
10
namespace geometry_msgs
11
{
12

    
13
  class PoseWithCovariance : public ros::Msg
14
  {
15
    public:
16
      geometry_msgs::Pose pose;
17
      float covariance[36];
18

    
19
    virtual int serialize(unsigned char *outbuffer) const
20
    {
21
      int offset = 0;
22
      offset += this->pose.serialize(outbuffer + offset);
23
      unsigned char * covariance_val = (unsigned char *) this->covariance;
24
      for( uint8_t i = 0; i < 36; i++){
25
      int32_t * val_covariancei = (long *) &(this->covariance[i]);
26
      int32_t exp_covariancei = (((*val_covariancei)>>23)&255);
27
      if(exp_covariancei != 0)
28
        exp_covariancei += 1023-127;
29
      int32_t sig_covariancei = *val_covariancei;
30
      *(outbuffer + offset++) = 0;
31
      *(outbuffer + offset++) = 0;
32
      *(outbuffer + offset++) = 0;
33
      *(outbuffer + offset++) = (sig_covariancei<<5) & 0xff;
34
      *(outbuffer + offset++) = (sig_covariancei>>3) & 0xff;
35
      *(outbuffer + offset++) = (sig_covariancei>>11) & 0xff;
36
      *(outbuffer + offset++) = ((exp_covariancei<<4) & 0xF0) | ((sig_covariancei>>19)&0x0F);
37
      *(outbuffer + offset++) = (exp_covariancei>>4) & 0x7F;
38
      if(this->covariance[i] < 0) *(outbuffer + offset -1) |= 0x80;
39
      }
40
      return offset;
41
    }
42

    
43
    virtual int deserialize(unsigned char *inbuffer)
44
    {
45
      int offset = 0;
46
      offset += this->pose.deserialize(inbuffer + offset);
47
      uint8_t * covariance_val = (uint8_t*) this->covariance;
48
      for( uint8_t i = 0; i < 36; i++){
49
      uint32_t * val_covariancei = (uint32_t*) &(this->covariance[i]);
50
      offset += 3;
51
      *val_covariancei = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
52
      *val_covariancei |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
53
      *val_covariancei |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
54
      *val_covariancei |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
55
      uint32_t exp_covariancei = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
56
      exp_covariancei |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
57
      if(exp_covariancei !=0)
58
        *val_covariancei |= ((exp_covariancei)-1023+127)<<23;
59
      if( ((*(inbuffer+offset++)) & 0x80) > 0) this->covariance[i] = -this->covariance[i];
60
      }
61
     return offset;
62
    }
63

    
64
    const char * getType(){ return "geometry_msgs/PoseWithCovariance"; };
65
    const char * getMD5(){ return "c23e848cf1b7533a8d7c259073a97e6f"; };
66

    
67
  };
68

    
69
}
70
#endif