Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (2.08 KB)

1
#ifndef _ROS_sensor_msgs_JoyFeedback_h
2
#define _ROS_sensor_msgs_JoyFeedback_h
3

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

    
9
namespace sensor_msgs
10
{
11

    
12
  class JoyFeedback : public ros::Msg
13
  {
14
    public:
15
      uint8_t type;
16
      uint8_t id;
17
      float intensity;
18
      enum { TYPE_LED =  0 };
19
      enum { TYPE_RUMBLE =  1 };
20
      enum { TYPE_BUZZER =  2 };
21

    
22
    virtual int serialize(unsigned char *outbuffer) const
23
    {
24
      int offset = 0;
25
      *(outbuffer + offset + 0) = (this->type >> (8 * 0)) & 0xFF;
26
      offset += sizeof(this->type);
27
      *(outbuffer + offset + 0) = (this->id >> (8 * 0)) & 0xFF;
28
      offset += sizeof(this->id);
29
      union {
30
        float real;
31
        uint32_t base;
32
      } u_intensity;
33
      u_intensity.real = this->intensity;
34
      *(outbuffer + offset + 0) = (u_intensity.base >> (8 * 0)) & 0xFF;
35
      *(outbuffer + offset + 1) = (u_intensity.base >> (8 * 1)) & 0xFF;
36
      *(outbuffer + offset + 2) = (u_intensity.base >> (8 * 2)) & 0xFF;
37
      *(outbuffer + offset + 3) = (u_intensity.base >> (8 * 3)) & 0xFF;
38
      offset += sizeof(this->intensity);
39
      return offset;
40
    }
41

    
42
    virtual int deserialize(unsigned char *inbuffer)
43
    {
44
      int offset = 0;
45
      this->type |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
46
      offset += sizeof(this->type);
47
      this->id |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
48
      offset += sizeof(this->id);
49
      union {
50
        float real;
51
        uint32_t base;
52
      } u_intensity;
53
      u_intensity.base = 0;
54
      u_intensity.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
55
      u_intensity.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
56
      u_intensity.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
57
      u_intensity.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
58
      this->intensity = u_intensity.real;
59
      offset += sizeof(this->intensity);
60
     return offset;
61
    }
62

    
63
    const char * getType(){ return "sensor_msgs/JoyFeedback"; };
64
    const char * getMD5(){ return "f4dcd73460360d98f36e55ee7f2e46f1"; };
65

    
66
  };
67

    
68
}
69
#endif