Go to the documentation of this file.00001 #ifndef _ROS_control_msgs_GripperCommandResult_h
00002 #define _ROS_control_msgs_GripperCommandResult_h
00003
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008
00009 namespace control_msgs
00010 {
00011
00012 class GripperCommandResult : public ros::Msg
00013 {
00014 public:
00015 float position;
00016 float effort;
00017 bool stalled;
00018 bool reached_goal;
00019
00020 virtual int serialize(unsigned char *outbuffer) const
00021 {
00022 int offset = 0;
00023 int32_t * val_position = (int32_t *) &(this->position);
00024 int32_t exp_position = (((*val_position)>>23)&255);
00025 if(exp_position != 0)
00026 exp_position += 1023-127;
00027 int32_t sig_position = *val_position;
00028 *(outbuffer + offset++) = 0;
00029 *(outbuffer + offset++) = 0;
00030 *(outbuffer + offset++) = 0;
00031 *(outbuffer + offset++) = (sig_position<<5) & 0xff;
00032 *(outbuffer + offset++) = (sig_position>>3) & 0xff;
00033 *(outbuffer + offset++) = (sig_position>>11) & 0xff;
00034 *(outbuffer + offset++) = ((exp_position<<4) & 0xF0) | ((sig_position>>19)&0x0F);
00035 *(outbuffer + offset++) = (exp_position>>4) & 0x7F;
00036 if(this->position < 0) *(outbuffer + offset -1) |= 0x80;
00037 int32_t * val_effort = (int32_t *) &(this->effort);
00038 int32_t exp_effort = (((*val_effort)>>23)&255);
00039 if(exp_effort != 0)
00040 exp_effort += 1023-127;
00041 int32_t sig_effort = *val_effort;
00042 *(outbuffer + offset++) = 0;
00043 *(outbuffer + offset++) = 0;
00044 *(outbuffer + offset++) = 0;
00045 *(outbuffer + offset++) = (sig_effort<<5) & 0xff;
00046 *(outbuffer + offset++) = (sig_effort>>3) & 0xff;
00047 *(outbuffer + offset++) = (sig_effort>>11) & 0xff;
00048 *(outbuffer + offset++) = ((exp_effort<<4) & 0xF0) | ((sig_effort>>19)&0x0F);
00049 *(outbuffer + offset++) = (exp_effort>>4) & 0x7F;
00050 if(this->effort < 0) *(outbuffer + offset -1) |= 0x80;
00051 union {
00052 bool real;
00053 uint8_t base;
00054 } u_stalled;
00055 u_stalled.real = this->stalled;
00056 *(outbuffer + offset + 0) = (u_stalled.base >> (8 * 0)) & 0xFF;
00057 offset += sizeof(this->stalled);
00058 union {
00059 bool real;
00060 uint8_t base;
00061 } u_reached_goal;
00062 u_reached_goal.real = this->reached_goal;
00063 *(outbuffer + offset + 0) = (u_reached_goal.base >> (8 * 0)) & 0xFF;
00064 offset += sizeof(this->reached_goal);
00065 return offset;
00066 }
00067
00068 virtual int deserialize(unsigned char *inbuffer)
00069 {
00070 int offset = 0;
00071 uint32_t * val_position = (uint32_t*) &(this->position);
00072 offset += 3;
00073 *val_position = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
00074 *val_position |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
00075 *val_position |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
00076 *val_position |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
00077 uint32_t exp_position = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
00078 exp_position |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
00079 if(exp_position !=0)
00080 *val_position |= ((exp_position)-1023+127)<<23;
00081 if( ((*(inbuffer+offset++)) & 0x80) > 0) this->position = -this->position;
00082 uint32_t * val_effort = (uint32_t*) &(this->effort);
00083 offset += 3;
00084 *val_effort = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
00085 *val_effort |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
00086 *val_effort |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
00087 *val_effort |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
00088 uint32_t exp_effort = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
00089 exp_effort |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
00090 if(exp_effort !=0)
00091 *val_effort |= ((exp_effort)-1023+127)<<23;
00092 if( ((*(inbuffer+offset++)) & 0x80) > 0) this->effort = -this->effort;
00093 union {
00094 bool real;
00095 uint8_t base;
00096 } u_stalled;
00097 u_stalled.base = 0;
00098 u_stalled.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
00099 this->stalled = u_stalled.real;
00100 offset += sizeof(this->stalled);
00101 union {
00102 bool real;
00103 uint8_t base;
00104 } u_reached_goal;
00105 u_reached_goal.base = 0;
00106 u_reached_goal.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
00107 this->reached_goal = u_reached_goal.real;
00108 offset += sizeof(this->reached_goal);
00109 return offset;
00110 }
00111
00112 const char * getType(){ return "control_msgs/GripperCommandResult"; };
00113 const char * getMD5(){ return "e4cbff56d3562bcf113da5a5adeef91f"; };
00114
00115 };
00116
00117 }
00118 #endif