Working towards recieving twists

Dependencies:   BufferedSerial

Fork of ros_lib_kinetic by Gary Servin

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers IntParameter.h Source File

IntParameter.h

00001 #ifndef _ROS_dynamic_reconfigure_IntParameter_h
00002 #define _ROS_dynamic_reconfigure_IntParameter_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 
00009 namespace dynamic_reconfigure
00010 {
00011 
00012   class IntParameter : public ros::Msg
00013   {
00014     public:
00015       typedef const char* _name_type;
00016       _name_type name;
00017       typedef int32_t _value_type;
00018       _value_type value;
00019 
00020     IntParameter():
00021       name(""),
00022       value(0)
00023     {
00024     }
00025 
00026     virtual int serialize(unsigned char *outbuffer) const
00027     {
00028       int offset = 0;
00029       uint32_t length_name = strlen(this->name);
00030       varToArr(outbuffer + offset, length_name);
00031       offset += 4;
00032       memcpy(outbuffer + offset, this->name, length_name);
00033       offset += length_name;
00034       union {
00035         int32_t real;
00036         uint32_t base;
00037       } u_value;
00038       u_value.real = this->value;
00039       *(outbuffer + offset + 0) = (u_value.base >> (8 * 0)) & 0xFF;
00040       *(outbuffer + offset + 1) = (u_value.base >> (8 * 1)) & 0xFF;
00041       *(outbuffer + offset + 2) = (u_value.base >> (8 * 2)) & 0xFF;
00042       *(outbuffer + offset + 3) = (u_value.base >> (8 * 3)) & 0xFF;
00043       offset += sizeof(this->value);
00044       return offset;
00045     }
00046 
00047     virtual int deserialize(unsigned char *inbuffer)
00048     {
00049       int offset = 0;
00050       uint32_t length_name;
00051       arrToVar(length_name, (inbuffer + offset));
00052       offset += 4;
00053       for(unsigned int k= offset; k< offset+length_name; ++k){
00054           inbuffer[k-1]=inbuffer[k];
00055       }
00056       inbuffer[offset+length_name-1]=0;
00057       this->name = (char *)(inbuffer + offset-1);
00058       offset += length_name;
00059       union {
00060         int32_t real;
00061         uint32_t base;
00062       } u_value;
00063       u_value.base = 0;
00064       u_value.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00065       u_value.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00066       u_value.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00067       u_value.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00068       this->value = u_value.real;
00069       offset += sizeof(this->value);
00070      return offset;
00071     }
00072 
00073     const char * getType(){ return "dynamic_reconfigure/IntParameter"; };
00074     const char * getMD5(){ return "65fedc7a0cbfb8db035e46194a350bf1"; };
00075 
00076   };
00077 
00078 }
00079 #endif