Project

General

Profile

Statistics
| Branch: | Revision:

root / quad2 / arduino / src / ros_lib / std_msgs / Float64.h @ c1426757

History | View | Annotate | Download (1.83 KB)

1
#ifndef _ROS_std_msgs_Float64_h
2
#define _ROS_std_msgs_Float64_h
3

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

    
9
namespace std_msgs
10
{
11

    
12
  class Float64 : public ros::Msg
13
  {
14
    public:
15
      float data;
16

    
17
    virtual int serialize(unsigned char *outbuffer) const
18
    {
19
      int offset = 0;
20
      int32_t * val_data = (long *) &(this->data);
21
      int32_t exp_data = (((*val_data)>>23)&255);
22
      if(exp_data != 0)
23
        exp_data += 1023-127;
24
      int32_t sig_data = *val_data;
25
      *(outbuffer + offset++) = 0;
26
      *(outbuffer + offset++) = 0;
27
      *(outbuffer + offset++) = 0;
28
      *(outbuffer + offset++) = (sig_data<<5) & 0xff;
29
      *(outbuffer + offset++) = (sig_data>>3) & 0xff;
30
      *(outbuffer + offset++) = (sig_data>>11) & 0xff;
31
      *(outbuffer + offset++) = ((exp_data<<4) & 0xF0) | ((sig_data>>19)&0x0F);
32
      *(outbuffer + offset++) = (exp_data>>4) & 0x7F;
33
      if(this->data < 0) *(outbuffer + offset -1) |= 0x80;
34
      return offset;
35
    }
36

    
37
    virtual int deserialize(unsigned char *inbuffer)
38
    {
39
      int offset = 0;
40
      uint32_t * val_data = (uint32_t*) &(this->data);
41
      offset += 3;
42
      *val_data = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
43
      *val_data |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
44
      *val_data |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
45
      *val_data |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
46
      uint32_t exp_data = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
47
      exp_data |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
48
      if(exp_data !=0)
49
        *val_data |= ((exp_data)-1023+127)<<23;
50
      if( ((*(inbuffer+offset++)) & 0x80) > 0) this->data = -this->data;
51
     return offset;
52
    }
53

    
54
    const char * getType(){ return "std_msgs/Float64"; };
55
    const char * getMD5(){ return "fdb28210bfa9d7c91146260178d9a584"; };
56

    
57
  };
58

    
59
}
60
#endif