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 Group.h Source File

Group.h

00001 #ifndef _ROS_dynamic_reconfigure_Group_h
00002 #define _ROS_dynamic_reconfigure_Group_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "dynamic_reconfigure/ParamDescription.h"
00009 
00010 namespace dynamic_reconfigure
00011 {
00012 
00013   class Group : public ros::Msg
00014   {
00015     public:
00016       typedef const char* _name_type;
00017       _name_type name;
00018       typedef const char* _type_type;
00019       _type_type type;
00020       uint32_t parameters_length;
00021       typedef dynamic_reconfigure::ParamDescription _parameters_type;
00022       _parameters_type st_parameters;
00023       _parameters_type * parameters;
00024       typedef int32_t _parent_type;
00025       _parent_type parent;
00026       typedef int32_t _id_type;
00027       _id_type id;
00028 
00029     Group():
00030       name(""),
00031       type(""),
00032       parameters_length(0), parameters(NULL),
00033       parent(0),
00034       id(0)
00035     {
00036     }
00037 
00038     virtual int serialize(unsigned char *outbuffer) const
00039     {
00040       int offset = 0;
00041       uint32_t length_name = strlen(this->name);
00042       varToArr(outbuffer + offset, length_name);
00043       offset += 4;
00044       memcpy(outbuffer + offset, this->name, length_name);
00045       offset += length_name;
00046       uint32_t length_type = strlen(this->type);
00047       varToArr(outbuffer + offset, length_type);
00048       offset += 4;
00049       memcpy(outbuffer + offset, this->type, length_type);
00050       offset += length_type;
00051       *(outbuffer + offset + 0) = (this->parameters_length >> (8 * 0)) & 0xFF;
00052       *(outbuffer + offset + 1) = (this->parameters_length >> (8 * 1)) & 0xFF;
00053       *(outbuffer + offset + 2) = (this->parameters_length >> (8 * 2)) & 0xFF;
00054       *(outbuffer + offset + 3) = (this->parameters_length >> (8 * 3)) & 0xFF;
00055       offset += sizeof(this->parameters_length);
00056       for( uint32_t i = 0; i < parameters_length; i++){
00057       offset += this->parameters[i].serialize(outbuffer + offset);
00058       }
00059       union {
00060         int32_t real;
00061         uint32_t base;
00062       } u_parent;
00063       u_parent.real = this->parent;
00064       *(outbuffer + offset + 0) = (u_parent.base >> (8 * 0)) & 0xFF;
00065       *(outbuffer + offset + 1) = (u_parent.base >> (8 * 1)) & 0xFF;
00066       *(outbuffer + offset + 2) = (u_parent.base >> (8 * 2)) & 0xFF;
00067       *(outbuffer + offset + 3) = (u_parent.base >> (8 * 3)) & 0xFF;
00068       offset += sizeof(this->parent);
00069       union {
00070         int32_t real;
00071         uint32_t base;
00072       } u_id;
00073       u_id.real = this->id;
00074       *(outbuffer + offset + 0) = (u_id.base >> (8 * 0)) & 0xFF;
00075       *(outbuffer + offset + 1) = (u_id.base >> (8 * 1)) & 0xFF;
00076       *(outbuffer + offset + 2) = (u_id.base >> (8 * 2)) & 0xFF;
00077       *(outbuffer + offset + 3) = (u_id.base >> (8 * 3)) & 0xFF;
00078       offset += sizeof(this->id);
00079       return offset;
00080     }
00081 
00082     virtual int deserialize(unsigned char *inbuffer)
00083     {
00084       int offset = 0;
00085       uint32_t length_name;
00086       arrToVar(length_name, (inbuffer + offset));
00087       offset += 4;
00088       for(unsigned int k= offset; k< offset+length_name; ++k){
00089           inbuffer[k-1]=inbuffer[k];
00090       }
00091       inbuffer[offset+length_name-1]=0;
00092       this->name = (char *)(inbuffer + offset-1);
00093       offset += length_name;
00094       uint32_t length_type;
00095       arrToVar(length_type, (inbuffer + offset));
00096       offset += 4;
00097       for(unsigned int k= offset; k< offset+length_type; ++k){
00098           inbuffer[k-1]=inbuffer[k];
00099       }
00100       inbuffer[offset+length_type-1]=0;
00101       this->type = (char *)(inbuffer + offset-1);
00102       offset += length_type;
00103       uint32_t parameters_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00104       parameters_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00105       parameters_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00106       parameters_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00107       offset += sizeof(this->parameters_length);
00108       if(parameters_lengthT > parameters_length)
00109         this->parameters = (dynamic_reconfigure::ParamDescription*)realloc(this->parameters, parameters_lengthT * sizeof(dynamic_reconfigure::ParamDescription));
00110       parameters_length = parameters_lengthT;
00111       for( uint32_t i = 0; i < parameters_length; i++){
00112       offset += this->st_parameters.deserialize(inbuffer + offset);
00113         memcpy( &(this->parameters[i]), &(this->st_parameters), sizeof(dynamic_reconfigure::ParamDescription));
00114       }
00115       union {
00116         int32_t real;
00117         uint32_t base;
00118       } u_parent;
00119       u_parent.base = 0;
00120       u_parent.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00121       u_parent.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00122       u_parent.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00123       u_parent.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00124       this->parent = u_parent.real;
00125       offset += sizeof(this->parent);
00126       union {
00127         int32_t real;
00128         uint32_t base;
00129       } u_id;
00130       u_id.base = 0;
00131       u_id.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00132       u_id.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00133       u_id.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00134       u_id.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00135       this->id = u_id.real;
00136       offset += sizeof(this->id);
00137      return offset;
00138     }
00139 
00140     const char * getType(){ return "dynamic_reconfigure/Group"; };
00141     const char * getMD5(){ return "9e8cd9e9423c94823db3614dd8b1cf7a"; };
00142 
00143   };
00144 
00145 }
00146 #endif