Gary Servin / ros_lib_indigo

Dependencies:   BufferedSerial

Dependents:   rosserial_mbed_hello_world_publisher rtos_base_control rosserial_mbed_F64MA ROS-RTOS ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers JoyFeedback.h Source File

JoyFeedback.h

00001 #ifndef _ROS_sensor_msgs_JoyFeedback_h
00002 #define _ROS_sensor_msgs_JoyFeedback_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 
00009 namespace sensor_msgs
00010 {
00011 
00012   class JoyFeedback : public ros::Msg
00013   {
00014     public:
00015       uint8_t type;
00016       uint8_t id;
00017       float intensity;
00018       enum { TYPE_LED =  0 };
00019       enum { TYPE_RUMBLE =  1 };
00020       enum { TYPE_BUZZER =  2 };
00021 
00022     JoyFeedback():
00023       type(0),
00024       id(0),
00025       intensity(0)
00026     {
00027     }
00028 
00029     virtual int serialize(unsigned char *outbuffer) const
00030     {
00031       int offset = 0;
00032       *(outbuffer + offset + 0) = (this->type >> (8 * 0)) & 0xFF;
00033       offset += sizeof(this->type);
00034       *(outbuffer + offset + 0) = (this->id >> (8 * 0)) & 0xFF;
00035       offset += sizeof(this->id);
00036       union {
00037         float real;
00038         uint32_t base;
00039       } u_intensity;
00040       u_intensity.real = this->intensity;
00041       *(outbuffer + offset + 0) = (u_intensity.base >> (8 * 0)) & 0xFF;
00042       *(outbuffer + offset + 1) = (u_intensity.base >> (8 * 1)) & 0xFF;
00043       *(outbuffer + offset + 2) = (u_intensity.base >> (8 * 2)) & 0xFF;
00044       *(outbuffer + offset + 3) = (u_intensity.base >> (8 * 3)) & 0xFF;
00045       offset += sizeof(this->intensity);
00046       return offset;
00047     }
00048 
00049     virtual int deserialize(unsigned char *inbuffer)
00050     {
00051       int offset = 0;
00052       this->type =  ((uint8_t) (*(inbuffer + offset)));
00053       offset += sizeof(this->type);
00054       this->id =  ((uint8_t) (*(inbuffer + offset)));
00055       offset += sizeof(this->id);
00056       union {
00057         float real;
00058         uint32_t base;
00059       } u_intensity;
00060       u_intensity.base = 0;
00061       u_intensity.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00062       u_intensity.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00063       u_intensity.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00064       u_intensity.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00065       this->intensity = u_intensity.real;
00066       offset += sizeof(this->intensity);
00067      return offset;
00068     }
00069 
00070     const char * getType(){ return "sensor_msgs/JoyFeedback"; };
00071     const char * getMD5(){ return "f4dcd73460360d98f36e55ee7f2e46f1"; };
00072 
00073   };
00074 
00075 }
00076 #endif