rosserial library for mbed Inspired by nucho's rosserial library This library is still under development

Dependencies:   MODSERIAL mbed

Dependents:   mbed_roshydro_test

Library still under development!

Committer:
akashvibhute
Date:
Sun Feb 15 10:53:43 2015 +0000
Revision:
0:30537dec6e0b
First commit; Library still need to be debugged, compilation issues with new mbed and modserial updates.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
akashvibhute 0:30537dec6e0b 1 #ifndef _ROS_controller_manager_msgs_ControllerState_h
akashvibhute 0:30537dec6e0b 2 #define _ROS_controller_manager_msgs_ControllerState_h
akashvibhute 0:30537dec6e0b 3
akashvibhute 0:30537dec6e0b 4 #include <stdint.h>
akashvibhute 0:30537dec6e0b 5 #include <string.h>
akashvibhute 0:30537dec6e0b 6 #include <stdlib.h>
akashvibhute 0:30537dec6e0b 7 #include "ros/msg.h"
akashvibhute 0:30537dec6e0b 8
akashvibhute 0:30537dec6e0b 9 namespace controller_manager_msgs
akashvibhute 0:30537dec6e0b 10 {
akashvibhute 0:30537dec6e0b 11
akashvibhute 0:30537dec6e0b 12 class ControllerState : public ros::Msg
akashvibhute 0:30537dec6e0b 13 {
akashvibhute 0:30537dec6e0b 14 public:
akashvibhute 0:30537dec6e0b 15 const char* name;
akashvibhute 0:30537dec6e0b 16 const char* state;
akashvibhute 0:30537dec6e0b 17 const char* type;
akashvibhute 0:30537dec6e0b 18 const char* hardware_interface;
akashvibhute 0:30537dec6e0b 19 uint8_t resources_length;
akashvibhute 0:30537dec6e0b 20 char* st_resources;
akashvibhute 0:30537dec6e0b 21 char* * resources;
akashvibhute 0:30537dec6e0b 22
akashvibhute 0:30537dec6e0b 23 ControllerState():
akashvibhute 0:30537dec6e0b 24 name(""),
akashvibhute 0:30537dec6e0b 25 state(""),
akashvibhute 0:30537dec6e0b 26 type(""),
akashvibhute 0:30537dec6e0b 27 hardware_interface(""),
akashvibhute 0:30537dec6e0b 28 resources_length(0), resources(NULL)
akashvibhute 0:30537dec6e0b 29 {
akashvibhute 0:30537dec6e0b 30 }
akashvibhute 0:30537dec6e0b 31
akashvibhute 0:30537dec6e0b 32 virtual int serialize(unsigned char *outbuffer) const
akashvibhute 0:30537dec6e0b 33 {
akashvibhute 0:30537dec6e0b 34 int offset = 0;
akashvibhute 0:30537dec6e0b 35 uint32_t length_name = strlen(this->name);
akashvibhute 0:30537dec6e0b 36 memcpy(outbuffer + offset, &length_name, sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 37 offset += 4;
akashvibhute 0:30537dec6e0b 38 memcpy(outbuffer + offset, this->name, length_name);
akashvibhute 0:30537dec6e0b 39 offset += length_name;
akashvibhute 0:30537dec6e0b 40 uint32_t length_state = strlen(this->state);
akashvibhute 0:30537dec6e0b 41 memcpy(outbuffer + offset, &length_state, sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 42 offset += 4;
akashvibhute 0:30537dec6e0b 43 memcpy(outbuffer + offset, this->state, length_state);
akashvibhute 0:30537dec6e0b 44 offset += length_state;
akashvibhute 0:30537dec6e0b 45 uint32_t length_type = strlen(this->type);
akashvibhute 0:30537dec6e0b 46 memcpy(outbuffer + offset, &length_type, sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 47 offset += 4;
akashvibhute 0:30537dec6e0b 48 memcpy(outbuffer + offset, this->type, length_type);
akashvibhute 0:30537dec6e0b 49 offset += length_type;
akashvibhute 0:30537dec6e0b 50 uint32_t length_hardware_interface = strlen(this->hardware_interface);
akashvibhute 0:30537dec6e0b 51 memcpy(outbuffer + offset, &length_hardware_interface, sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 52 offset += 4;
akashvibhute 0:30537dec6e0b 53 memcpy(outbuffer + offset, this->hardware_interface, length_hardware_interface);
akashvibhute 0:30537dec6e0b 54 offset += length_hardware_interface;
akashvibhute 0:30537dec6e0b 55 *(outbuffer + offset++) = resources_length;
akashvibhute 0:30537dec6e0b 56 *(outbuffer + offset++) = 0;
akashvibhute 0:30537dec6e0b 57 *(outbuffer + offset++) = 0;
akashvibhute 0:30537dec6e0b 58 *(outbuffer + offset++) = 0;
akashvibhute 0:30537dec6e0b 59 for( uint8_t i = 0; i < resources_length; i++){
akashvibhute 0:30537dec6e0b 60 uint32_t length_resourcesi = strlen(this->resources[i]);
akashvibhute 0:30537dec6e0b 61 memcpy(outbuffer + offset, &length_resourcesi, sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 62 offset += 4;
akashvibhute 0:30537dec6e0b 63 memcpy(outbuffer + offset, this->resources[i], length_resourcesi);
akashvibhute 0:30537dec6e0b 64 offset += length_resourcesi;
akashvibhute 0:30537dec6e0b 65 }
akashvibhute 0:30537dec6e0b 66 return offset;
akashvibhute 0:30537dec6e0b 67 }
akashvibhute 0:30537dec6e0b 68
akashvibhute 0:30537dec6e0b 69 virtual int deserialize(unsigned char *inbuffer)
akashvibhute 0:30537dec6e0b 70 {
akashvibhute 0:30537dec6e0b 71 int offset = 0;
akashvibhute 0:30537dec6e0b 72 uint32_t length_name;
akashvibhute 0:30537dec6e0b 73 memcpy(&length_name, (inbuffer + offset), sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 74 offset += 4;
akashvibhute 0:30537dec6e0b 75 for(unsigned int k= offset; k< offset+length_name; ++k){
akashvibhute 0:30537dec6e0b 76 inbuffer[k-1]=inbuffer[k];
akashvibhute 0:30537dec6e0b 77 }
akashvibhute 0:30537dec6e0b 78 inbuffer[offset+length_name-1]=0;
akashvibhute 0:30537dec6e0b 79 this->name = (char *)(inbuffer + offset-1);
akashvibhute 0:30537dec6e0b 80 offset += length_name;
akashvibhute 0:30537dec6e0b 81 uint32_t length_state;
akashvibhute 0:30537dec6e0b 82 memcpy(&length_state, (inbuffer + offset), sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 83 offset += 4;
akashvibhute 0:30537dec6e0b 84 for(unsigned int k= offset; k< offset+length_state; ++k){
akashvibhute 0:30537dec6e0b 85 inbuffer[k-1]=inbuffer[k];
akashvibhute 0:30537dec6e0b 86 }
akashvibhute 0:30537dec6e0b 87 inbuffer[offset+length_state-1]=0;
akashvibhute 0:30537dec6e0b 88 this->state = (char *)(inbuffer + offset-1);
akashvibhute 0:30537dec6e0b 89 offset += length_state;
akashvibhute 0:30537dec6e0b 90 uint32_t length_type;
akashvibhute 0:30537dec6e0b 91 memcpy(&length_type, (inbuffer + offset), sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 92 offset += 4;
akashvibhute 0:30537dec6e0b 93 for(unsigned int k= offset; k< offset+length_type; ++k){
akashvibhute 0:30537dec6e0b 94 inbuffer[k-1]=inbuffer[k];
akashvibhute 0:30537dec6e0b 95 }
akashvibhute 0:30537dec6e0b 96 inbuffer[offset+length_type-1]=0;
akashvibhute 0:30537dec6e0b 97 this->type = (char *)(inbuffer + offset-1);
akashvibhute 0:30537dec6e0b 98 offset += length_type;
akashvibhute 0:30537dec6e0b 99 uint32_t length_hardware_interface;
akashvibhute 0:30537dec6e0b 100 memcpy(&length_hardware_interface, (inbuffer + offset), sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 101 offset += 4;
akashvibhute 0:30537dec6e0b 102 for(unsigned int k= offset; k< offset+length_hardware_interface; ++k){
akashvibhute 0:30537dec6e0b 103 inbuffer[k-1]=inbuffer[k];
akashvibhute 0:30537dec6e0b 104 }
akashvibhute 0:30537dec6e0b 105 inbuffer[offset+length_hardware_interface-1]=0;
akashvibhute 0:30537dec6e0b 106 this->hardware_interface = (char *)(inbuffer + offset-1);
akashvibhute 0:30537dec6e0b 107 offset += length_hardware_interface;
akashvibhute 0:30537dec6e0b 108 uint8_t resources_lengthT = *(inbuffer + offset++);
akashvibhute 0:30537dec6e0b 109 if(resources_lengthT > resources_length)
akashvibhute 0:30537dec6e0b 110 this->resources = (char**)realloc(this->resources, resources_lengthT * sizeof(char*));
akashvibhute 0:30537dec6e0b 111 offset += 3;
akashvibhute 0:30537dec6e0b 112 resources_length = resources_lengthT;
akashvibhute 0:30537dec6e0b 113 for( uint8_t i = 0; i < resources_length; i++){
akashvibhute 0:30537dec6e0b 114 uint32_t length_st_resources;
akashvibhute 0:30537dec6e0b 115 memcpy(&length_st_resources, (inbuffer + offset), sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 116 offset += 4;
akashvibhute 0:30537dec6e0b 117 for(unsigned int k= offset; k< offset+length_st_resources; ++k){
akashvibhute 0:30537dec6e0b 118 inbuffer[k-1]=inbuffer[k];
akashvibhute 0:30537dec6e0b 119 }
akashvibhute 0:30537dec6e0b 120 inbuffer[offset+length_st_resources-1]=0;
akashvibhute 0:30537dec6e0b 121 this->st_resources = (char *)(inbuffer + offset-1);
akashvibhute 0:30537dec6e0b 122 offset += length_st_resources;
akashvibhute 0:30537dec6e0b 123 memcpy( &(this->resources[i]), &(this->st_resources), sizeof(char*));
akashvibhute 0:30537dec6e0b 124 }
akashvibhute 0:30537dec6e0b 125 return offset;
akashvibhute 0:30537dec6e0b 126 }
akashvibhute 0:30537dec6e0b 127
akashvibhute 0:30537dec6e0b 128 const char * getType(){ return "controller_manager_msgs/ControllerState"; };
akashvibhute 0:30537dec6e0b 129 const char * getMD5(){ return "cac963cc68f4f5836765c108de0fc446"; };
akashvibhute 0:30537dec6e0b 130
akashvibhute 0:30537dec6e0b 131 };
akashvibhute 0:30537dec6e0b 132
akashvibhute 0:30537dec6e0b 133 }
akashvibhute 0:30537dec6e0b 134 #endif