Go to the documentation of this file.00001 #ifndef ros_sensor_msgs_Joy_h
00002 #define ros_sensor_msgs_Joy_h
00003
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "../ros/msg.h"
00008 #include "std_msgs/Header.h"
00009
00010 namespace sensor_msgs
00011 {
00012
00013 class Joy : public ros::Msg
00014 {
00015 public:
00016 std_msgs::Header header;
00017 unsigned char axes_length;
00018 float st_axes;
00019 float * axes;
00020 unsigned char buttons_length;
00021 long st_buttons;
00022 long * buttons;
00023
00024 virtual int serialize(unsigned char *outbuffer)
00025 {
00026 int offset = 0;
00027 offset += this->header.serialize(outbuffer + offset);
00028 *(outbuffer + offset++) = axes_length;
00029 *(outbuffer + offset++) = 0;
00030 *(outbuffer + offset++) = 0;
00031 *(outbuffer + offset++) = 0;
00032 for( unsigned char i = 0; i < axes_length; i++){
00033 union {
00034 float real;
00035 unsigned long base;
00036 } u_axesi;
00037 u_axesi.real = this->axes[i];
00038 *(outbuffer + offset + 0) = (u_axesi.base >> (8 * 0)) & 0xFF;
00039 *(outbuffer + offset + 1) = (u_axesi.base >> (8 * 1)) & 0xFF;
00040 *(outbuffer + offset + 2) = (u_axesi.base >> (8 * 2)) & 0xFF;
00041 *(outbuffer + offset + 3) = (u_axesi.base >> (8 * 3)) & 0xFF;
00042 offset += sizeof(this->axes[i]);
00043 }
00044 *(outbuffer + offset++) = buttons_length;
00045 *(outbuffer + offset++) = 0;
00046 *(outbuffer + offset++) = 0;
00047 *(outbuffer + offset++) = 0;
00048 for( unsigned char i = 0; i < buttons_length; i++){
00049 union {
00050 long real;
00051 unsigned long base;
00052 } u_buttonsi;
00053 u_buttonsi.real = this->buttons[i];
00054 *(outbuffer + offset + 0) = (u_buttonsi.base >> (8 * 0)) & 0xFF;
00055 *(outbuffer + offset + 1) = (u_buttonsi.base >> (8 * 1)) & 0xFF;
00056 *(outbuffer + offset + 2) = (u_buttonsi.base >> (8 * 2)) & 0xFF;
00057 *(outbuffer + offset + 3) = (u_buttonsi.base >> (8 * 3)) & 0xFF;
00058 offset += sizeof(this->buttons[i]);
00059 }
00060 return offset;
00061 }
00062
00063 virtual int deserialize(unsigned char *inbuffer)
00064 {
00065 int offset = 0;
00066 offset += this->header.deserialize(inbuffer + offset);
00067 unsigned char axes_lengthT = *(inbuffer + offset++);
00068 if(axes_lengthT > axes_length)
00069 this->axes = (float*)realloc(this->axes, axes_lengthT * sizeof(float));
00070 offset += 3;
00071 axes_length = axes_lengthT;
00072 for( unsigned char i = 0; i < axes_length; i++){
00073 union {
00074 float real;
00075 unsigned long base;
00076 } u_st_axes;
00077 u_st_axes.base = 0;
00078 u_st_axes.base |= ((typeof(u_st_axes.base)) (*(inbuffer + offset + 0))) << (8 * 0);
00079 u_st_axes.base |= ((typeof(u_st_axes.base)) (*(inbuffer + offset + 1))) << (8 * 1);
00080 u_st_axes.base |= ((typeof(u_st_axes.base)) (*(inbuffer + offset + 2))) << (8 * 2);
00081 u_st_axes.base |= ((typeof(u_st_axes.base)) (*(inbuffer + offset + 3))) << (8 * 3);
00082 this->st_axes = u_st_axes.real;
00083 offset += sizeof(this->st_axes);
00084 memcpy( &(this->axes[i]), &(this->st_axes), sizeof(float));
00085 }
00086 unsigned char buttons_lengthT = *(inbuffer + offset++);
00087 if(buttons_lengthT > buttons_length)
00088 this->buttons = (long*)realloc(this->buttons, buttons_lengthT * sizeof(long));
00089 offset += 3;
00090 buttons_length = buttons_lengthT;
00091 for( unsigned char i = 0; i < buttons_length; i++){
00092 union {
00093 long real;
00094 unsigned long base;
00095 } u_st_buttons;
00096 u_st_buttons.base = 0;
00097 u_st_buttons.base |= ((typeof(u_st_buttons.base)) (*(inbuffer + offset + 0))) << (8 * 0);
00098 u_st_buttons.base |= ((typeof(u_st_buttons.base)) (*(inbuffer + offset + 1))) << (8 * 1);
00099 u_st_buttons.base |= ((typeof(u_st_buttons.base)) (*(inbuffer + offset + 2))) << (8 * 2);
00100 u_st_buttons.base |= ((typeof(u_st_buttons.base)) (*(inbuffer + offset + 3))) << (8 * 3);
00101 this->st_buttons = u_st_buttons.real;
00102 offset += sizeof(this->st_buttons);
00103 memcpy( &(this->buttons[i]), &(this->st_buttons), sizeof(long));
00104 }
00105 return offset;
00106 }
00107
00108 const char * getType(){ return "sensor_msgs/Joy"; };
00109
00110 };
00111
00112 }
00113 #endif