Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (2.52 KB)

1
#ifndef _ROS_geometry_msgs_TwistWithCovariance_h
2
#define _ROS_geometry_msgs_TwistWithCovariance_h
3

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

    
10
namespace geometry_msgs
11
{
12

    
13
  class TwistWithCovariance : public ros::Msg
14
  {
15
    public:
16
      geometry_msgs::Twist twist;
17
      float covariance[36];
18

    
19
    virtual int serialize(unsigned char *outbuffer) const
20
    {
21
      int offset = 0;
22
      offset += this->twist.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->twist.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/TwistWithCovariance"; };
65
    const char * getMD5(){ return "1fe8a28e6890a4cc3ae4c3ca5c7d82e6"; };
66

    
67
  };
68

    
69
}
70
#endif