GripperCommand.h
Go to the documentation of this file.
00001 #ifndef _ROS_control_msgs_GripperCommand_h
00002 #define _ROS_control_msgs_GripperCommand_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 GripperCommand : public ros::Msg
00013   {
00014     public:
00015       float position;
00016       float max_effort;
00017 
00018     virtual int serialize(unsigned char *outbuffer) const
00019     {
00020       int offset = 0;
00021       int32_t * val_position = (int32_t *) &(this->position);
00022       int32_t exp_position = (((*val_position)>>23)&255);
00023       if(exp_position != 0)
00024         exp_position += 1023-127;
00025       int32_t sig_position = *val_position;
00026       *(outbuffer + offset++) = 0;
00027       *(outbuffer + offset++) = 0;
00028       *(outbuffer + offset++) = 0;
00029       *(outbuffer + offset++) = (sig_position<<5) & 0xff;
00030       *(outbuffer + offset++) = (sig_position>>3) & 0xff;
00031       *(outbuffer + offset++) = (sig_position>>11) & 0xff;
00032       *(outbuffer + offset++) = ((exp_position<<4) & 0xF0) | ((sig_position>>19)&0x0F);
00033       *(outbuffer + offset++) = (exp_position>>4) & 0x7F;
00034       if(this->position < 0) *(outbuffer + offset -1) |= 0x80;
00035       int32_t * val_max_effort = (int32_t *) &(this->max_effort);
00036       int32_t exp_max_effort = (((*val_max_effort)>>23)&255);
00037       if(exp_max_effort != 0)
00038         exp_max_effort += 1023-127;
00039       int32_t sig_max_effort = *val_max_effort;
00040       *(outbuffer + offset++) = 0;
00041       *(outbuffer + offset++) = 0;
00042       *(outbuffer + offset++) = 0;
00043       *(outbuffer + offset++) = (sig_max_effort<<5) & 0xff;
00044       *(outbuffer + offset++) = (sig_max_effort>>3) & 0xff;
00045       *(outbuffer + offset++) = (sig_max_effort>>11) & 0xff;
00046       *(outbuffer + offset++) = ((exp_max_effort<<4) & 0xF0) | ((sig_max_effort>>19)&0x0F);
00047       *(outbuffer + offset++) = (exp_max_effort>>4) & 0x7F;
00048       if(this->max_effort < 0) *(outbuffer + offset -1) |= 0x80;
00049       return offset;
00050     }
00051 
00052     virtual int deserialize(unsigned char *inbuffer)
00053     {
00054       int offset = 0;
00055       uint32_t * val_position = (uint32_t*) &(this->position);
00056       offset += 3;
00057       *val_position = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
00058       *val_position |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
00059       *val_position |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
00060       *val_position |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
00061       uint32_t exp_position = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
00062       exp_position |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
00063       if(exp_position !=0)
00064         *val_position |= ((exp_position)-1023+127)<<23;
00065       if( ((*(inbuffer+offset++)) & 0x80) > 0) this->position = -this->position;
00066       uint32_t * val_max_effort = (uint32_t*) &(this->max_effort);
00067       offset += 3;
00068       *val_max_effort = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
00069       *val_max_effort |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
00070       *val_max_effort |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
00071       *val_max_effort |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
00072       uint32_t exp_max_effort = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
00073       exp_max_effort |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
00074       if(exp_max_effort !=0)
00075         *val_max_effort |= ((exp_max_effort)-1023+127)<<23;
00076       if( ((*(inbuffer+offset++)) & 0x80) > 0) this->max_effort = -this->max_effort;
00077      return offset;
00078     }
00079 
00080     const char * getType(){ return "control_msgs/GripperCommand"; };
00081     const char * getMD5(){ return "680acaff79486f017132a7f198d40f08"; };
00082 
00083   };
00084 
00085 }
00086 #endif


lizi_arduino
Author(s): RoboTiCan
autogenerated on Wed Aug 26 2015 12:24:22