CartesianGains.h
Go to the documentation of this file.
00001 #ifndef _ROS_manipulation_msgs_CartesianGains_h
00002 #define _ROS_manipulation_msgs_CartesianGains_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 manipulation_msgs
00011 {
00012 
00013   class CartesianGains : public ros::Msg
00014   {
00015     public:
00016       std_msgs::Header header;
00017       uint8_t gains_length;
00018       float st_gains;
00019       float * gains;
00020       uint8_t fixed_frame_length;
00021       float st_fixed_frame;
00022       float * fixed_frame;
00023 
00024     virtual int serialize(unsigned char *outbuffer) const
00025     {
00026       int offset = 0;
00027       offset += this->header.serialize(outbuffer + offset);
00028       *(outbuffer + offset++) = gains_length;
00029       *(outbuffer + offset++) = 0;
00030       *(outbuffer + offset++) = 0;
00031       *(outbuffer + offset++) = 0;
00032       for( uint8_t i = 0; i < gains_length; i++){
00033       int32_t * val_gainsi = (int32_t *) &(this->gains[i]);
00034       int32_t exp_gainsi = (((*val_gainsi)>>23)&255);
00035       if(exp_gainsi != 0)
00036         exp_gainsi += 1023-127;
00037       int32_t sig_gainsi = *val_gainsi;
00038       *(outbuffer + offset++) = 0;
00039       *(outbuffer + offset++) = 0;
00040       *(outbuffer + offset++) = 0;
00041       *(outbuffer + offset++) = (sig_gainsi<<5) & 0xff;
00042       *(outbuffer + offset++) = (sig_gainsi>>3) & 0xff;
00043       *(outbuffer + offset++) = (sig_gainsi>>11) & 0xff;
00044       *(outbuffer + offset++) = ((exp_gainsi<<4) & 0xF0) | ((sig_gainsi>>19)&0x0F);
00045       *(outbuffer + offset++) = (exp_gainsi>>4) & 0x7F;
00046       if(this->gains[i] < 0) *(outbuffer + offset -1) |= 0x80;
00047       }
00048       *(outbuffer + offset++) = fixed_frame_length;
00049       *(outbuffer + offset++) = 0;
00050       *(outbuffer + offset++) = 0;
00051       *(outbuffer + offset++) = 0;
00052       for( uint8_t i = 0; i < fixed_frame_length; i++){
00053       int32_t * val_fixed_framei = (int32_t *) &(this->fixed_frame[i]);
00054       int32_t exp_fixed_framei = (((*val_fixed_framei)>>23)&255);
00055       if(exp_fixed_framei != 0)
00056         exp_fixed_framei += 1023-127;
00057       int32_t sig_fixed_framei = *val_fixed_framei;
00058       *(outbuffer + offset++) = 0;
00059       *(outbuffer + offset++) = 0;
00060       *(outbuffer + offset++) = 0;
00061       *(outbuffer + offset++) = (sig_fixed_framei<<5) & 0xff;
00062       *(outbuffer + offset++) = (sig_fixed_framei>>3) & 0xff;
00063       *(outbuffer + offset++) = (sig_fixed_framei>>11) & 0xff;
00064       *(outbuffer + offset++) = ((exp_fixed_framei<<4) & 0xF0) | ((sig_fixed_framei>>19)&0x0F);
00065       *(outbuffer + offset++) = (exp_fixed_framei>>4) & 0x7F;
00066       if(this->fixed_frame[i] < 0) *(outbuffer + offset -1) |= 0x80;
00067       }
00068       return offset;
00069     }
00070 
00071     virtual int deserialize(unsigned char *inbuffer)
00072     {
00073       int offset = 0;
00074       offset += this->header.deserialize(inbuffer + offset);
00075       uint8_t gains_lengthT = *(inbuffer + offset++);
00076       if(gains_lengthT > gains_length)
00077         this->gains = (float*)realloc(this->gains, gains_lengthT * sizeof(float));
00078       offset += 3;
00079       gains_length = gains_lengthT;
00080       for( uint8_t i = 0; i < gains_length; i++){
00081       uint32_t * val_st_gains = (uint32_t*) &(this->st_gains);
00082       offset += 3;
00083       *val_st_gains = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
00084       *val_st_gains |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
00085       *val_st_gains |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
00086       *val_st_gains |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
00087       uint32_t exp_st_gains = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
00088       exp_st_gains |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
00089       if(exp_st_gains !=0)
00090         *val_st_gains |= ((exp_st_gains)-1023+127)<<23;
00091       if( ((*(inbuffer+offset++)) & 0x80) > 0) this->st_gains = -this->st_gains;
00092         memcpy( &(this->gains[i]), &(this->st_gains), sizeof(float));
00093       }
00094       uint8_t fixed_frame_lengthT = *(inbuffer + offset++);
00095       if(fixed_frame_lengthT > fixed_frame_length)
00096         this->fixed_frame = (float*)realloc(this->fixed_frame, fixed_frame_lengthT * sizeof(float));
00097       offset += 3;
00098       fixed_frame_length = fixed_frame_lengthT;
00099       for( uint8_t i = 0; i < fixed_frame_length; i++){
00100       uint32_t * val_st_fixed_frame = (uint32_t*) &(this->st_fixed_frame);
00101       offset += 3;
00102       *val_st_fixed_frame = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
00103       *val_st_fixed_frame |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
00104       *val_st_fixed_frame |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
00105       *val_st_fixed_frame |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
00106       uint32_t exp_st_fixed_frame = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
00107       exp_st_fixed_frame |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
00108       if(exp_st_fixed_frame !=0)
00109         *val_st_fixed_frame |= ((exp_st_fixed_frame)-1023+127)<<23;
00110       if( ((*(inbuffer+offset++)) & 0x80) > 0) this->st_fixed_frame = -this->st_fixed_frame;
00111         memcpy( &(this->fixed_frame[i]), &(this->st_fixed_frame), sizeof(float));
00112       }
00113      return offset;
00114     }
00115 
00116     const char * getType(){ return "manipulation_msgs/CartesianGains"; };
00117     const char * getMD5(){ return "ab347f046ca5736a156ec424cbb63635"; };
00118 
00119   };
00120 
00121 }
00122 #endif


ric_mc
Author(s): RoboTiCan
autogenerated on Thu Aug 27 2015 14:39:49