rosserial library for mbed Inspired by nucho's rosserial library This library is still under development
Dependents: mbed_roshydro_test
Library still under development!
dynamic_reconfigure/Group.h
- Committer:
- akashvibhute
- Date:
- 2015-02-15
- Revision:
- 0:30537dec6e0b
File content as of revision 0:30537dec6e0b:
#ifndef _ROS_dynamic_reconfigure_Group_h #define _ROS_dynamic_reconfigure_Group_h #include <stdint.h> #include <string.h> #include <stdlib.h> #include "ros/msg.h" #include "dynamic_reconfigure/ParamDescription.h" namespace dynamic_reconfigure { class Group : public ros::Msg { public: const char* name; const char* type; uint8_t parameters_length; dynamic_reconfigure::ParamDescription st_parameters; dynamic_reconfigure::ParamDescription * parameters; int32_t parent; int32_t id; Group(): name(""), type(""), parameters_length(0), parameters(NULL), parent(0), id(0) { } virtual int serialize(unsigned char *outbuffer) const { int offset = 0; uint32_t length_name = strlen(this->name); memcpy(outbuffer + offset, &length_name, sizeof(uint32_t)); offset += 4; memcpy(outbuffer + offset, this->name, length_name); offset += length_name; uint32_t length_type = strlen(this->type); memcpy(outbuffer + offset, &length_type, sizeof(uint32_t)); offset += 4; memcpy(outbuffer + offset, this->type, length_type); offset += length_type; *(outbuffer + offset++) = parameters_length; *(outbuffer + offset++) = 0; *(outbuffer + offset++) = 0; *(outbuffer + offset++) = 0; for( uint8_t i = 0; i < parameters_length; i++){ offset += this->parameters[i].serialize(outbuffer + offset); } union { int32_t real; uint32_t base; } u_parent; u_parent.real = this->parent; *(outbuffer + offset + 0) = (u_parent.base >> (8 * 0)) & 0xFF; *(outbuffer + offset + 1) = (u_parent.base >> (8 * 1)) & 0xFF; *(outbuffer + offset + 2) = (u_parent.base >> (8 * 2)) & 0xFF; *(outbuffer + offset + 3) = (u_parent.base >> (8 * 3)) & 0xFF; offset += sizeof(this->parent); union { int32_t real; uint32_t base; } u_id; u_id.real = this->id; *(outbuffer + offset + 0) = (u_id.base >> (8 * 0)) & 0xFF; *(outbuffer + offset + 1) = (u_id.base >> (8 * 1)) & 0xFF; *(outbuffer + offset + 2) = (u_id.base >> (8 * 2)) & 0xFF; *(outbuffer + offset + 3) = (u_id.base >> (8 * 3)) & 0xFF; offset += sizeof(this->id); return offset; } virtual int deserialize(unsigned char *inbuffer) { int offset = 0; uint32_t length_name; memcpy(&length_name, (inbuffer + offset), sizeof(uint32_t)); offset += 4; for(unsigned int k= offset; k< offset+length_name; ++k){ inbuffer[k-1]=inbuffer[k]; } inbuffer[offset+length_name-1]=0; this->name = (char *)(inbuffer + offset-1); offset += length_name; uint32_t length_type; memcpy(&length_type, (inbuffer + offset), sizeof(uint32_t)); offset += 4; for(unsigned int k= offset; k< offset+length_type; ++k){ inbuffer[k-1]=inbuffer[k]; } inbuffer[offset+length_type-1]=0; this->type = (char *)(inbuffer + offset-1); offset += length_type; uint8_t parameters_lengthT = *(inbuffer + offset++); if(parameters_lengthT > parameters_length) this->parameters = (dynamic_reconfigure::ParamDescription*)realloc(this->parameters, parameters_lengthT * sizeof(dynamic_reconfigure::ParamDescription)); offset += 3; parameters_length = parameters_lengthT; for( uint8_t i = 0; i < parameters_length; i++){ offset += this->st_parameters.deserialize(inbuffer + offset); memcpy( &(this->parameters[i]), &(this->st_parameters), sizeof(dynamic_reconfigure::ParamDescription)); } union { int32_t real; uint32_t base; } u_parent; u_parent.base = 0; u_parent.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); u_parent.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); u_parent.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); u_parent.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); this->parent = u_parent.real; offset += sizeof(this->parent); union { int32_t real; uint32_t base; } u_id; u_id.base = 0; u_id.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); u_id.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); u_id.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); u_id.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); this->id = u_id.real; offset += sizeof(this->id); return offset; } const char * getType(){ return "dynamic_reconfigure/Group"; }; const char * getMD5(){ return "9e8cd9e9423c94823db3614dd8b1cf7a"; }; }; } #endif