SolidPrimitive.h
Go to the documentation of this file.
00001 #ifndef _ROS_shape_msgs_SolidPrimitive_h
00002 #define _ROS_shape_msgs_SolidPrimitive_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 
00009 namespace shape_msgs
00010 {
00011 
00012   class SolidPrimitive : public ros::Msg
00013   {
00014     public:
00015       uint8_t type;
00016       uint8_t dimensions_length;
00017       float st_dimensions;
00018       float * dimensions;
00019       enum { BOX = 1 };
00020       enum { SPHERE = 2 };
00021       enum { CYLINDER = 3 };
00022       enum { CONE = 4 };
00023       enum { BOX_X = 0 };
00024       enum { BOX_Y = 1 };
00025       enum { BOX_Z = 2 };
00026       enum { SPHERE_RADIUS = 0 };
00027       enum { CYLINDER_HEIGHT = 0 };
00028       enum { CYLINDER_RADIUS = 1 };
00029       enum { CONE_HEIGHT = 0 };
00030       enum { CONE_RADIUS = 1 };
00031 
00032     virtual int serialize(unsigned char *outbuffer) const
00033     {
00034       int offset = 0;
00035       *(outbuffer + offset + 0) = (this->type >> (8 * 0)) & 0xFF;
00036       offset += sizeof(this->type);
00037       *(outbuffer + offset++) = dimensions_length;
00038       *(outbuffer + offset++) = 0;
00039       *(outbuffer + offset++) = 0;
00040       *(outbuffer + offset++) = 0;
00041       for( uint8_t i = 0; i < dimensions_length; i++){
00042       int32_t * val_dimensionsi = (int32_t *) &(this->dimensions[i]);
00043       int32_t exp_dimensionsi = (((*val_dimensionsi)>>23)&255);
00044       if(exp_dimensionsi != 0)
00045         exp_dimensionsi += 1023-127;
00046       int32_t sig_dimensionsi = *val_dimensionsi;
00047       *(outbuffer + offset++) = 0;
00048       *(outbuffer + offset++) = 0;
00049       *(outbuffer + offset++) = 0;
00050       *(outbuffer + offset++) = (sig_dimensionsi<<5) & 0xff;
00051       *(outbuffer + offset++) = (sig_dimensionsi>>3) & 0xff;
00052       *(outbuffer + offset++) = (sig_dimensionsi>>11) & 0xff;
00053       *(outbuffer + offset++) = ((exp_dimensionsi<<4) & 0xF0) | ((sig_dimensionsi>>19)&0x0F);
00054       *(outbuffer + offset++) = (exp_dimensionsi>>4) & 0x7F;
00055       if(this->dimensions[i] < 0) *(outbuffer + offset -1) |= 0x80;
00056       }
00057       return offset;
00058     }
00059 
00060     virtual int deserialize(unsigned char *inbuffer)
00061     {
00062       int offset = 0;
00063       this->type =  ((uint8_t) (*(inbuffer + offset)));
00064       offset += sizeof(this->type);
00065       uint8_t dimensions_lengthT = *(inbuffer + offset++);
00066       if(dimensions_lengthT > dimensions_length)
00067         this->dimensions = (float*)realloc(this->dimensions, dimensions_lengthT * sizeof(float));
00068       offset += 3;
00069       dimensions_length = dimensions_lengthT;
00070       for( uint8_t i = 0; i < dimensions_length; i++){
00071       uint32_t * val_st_dimensions = (uint32_t*) &(this->st_dimensions);
00072       offset += 3;
00073       *val_st_dimensions = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
00074       *val_st_dimensions |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
00075       *val_st_dimensions |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
00076       *val_st_dimensions |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
00077       uint32_t exp_st_dimensions = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
00078       exp_st_dimensions |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
00079       if(exp_st_dimensions !=0)
00080         *val_st_dimensions |= ((exp_st_dimensions)-1023+127)<<23;
00081       if( ((*(inbuffer+offset++)) & 0x80) > 0) this->st_dimensions = -this->st_dimensions;
00082         memcpy( &(this->dimensions[i]), &(this->st_dimensions), sizeof(float));
00083       }
00084      return offset;
00085     }
00086 
00087     const char * getType(){ return "shape_msgs/SolidPrimitive"; };
00088     const char * getMD5(){ return "d8f8cbc74c5ff283fca29569ccefb45d"; };
00089 
00090   };
00091 
00092 }
00093 #endif


ric_mc
Author(s): RoboTiCan
autogenerated on Fri May 20 2016 03:48:56