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_pr2_mechanism_msgs_SwitchControllerGoal_h
akashvibhute 0:30537dec6e0b 2 #define _ROS_pr2_mechanism_msgs_SwitchControllerGoal_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 pr2_mechanism_msgs
akashvibhute 0:30537dec6e0b 10 {
akashvibhute 0:30537dec6e0b 11
akashvibhute 0:30537dec6e0b 12 class SwitchControllerGoal : public ros::Msg
akashvibhute 0:30537dec6e0b 13 {
akashvibhute 0:30537dec6e0b 14 public:
akashvibhute 0:30537dec6e0b 15 uint8_t start_controllers_length;
akashvibhute 0:30537dec6e0b 16 char* st_start_controllers;
akashvibhute 0:30537dec6e0b 17 char* * start_controllers;
akashvibhute 0:30537dec6e0b 18 uint8_t stop_controllers_length;
akashvibhute 0:30537dec6e0b 19 char* st_stop_controllers;
akashvibhute 0:30537dec6e0b 20 char* * stop_controllers;
akashvibhute 0:30537dec6e0b 21
akashvibhute 0:30537dec6e0b 22 SwitchControllerGoal():
akashvibhute 0:30537dec6e0b 23 start_controllers_length(0), start_controllers(NULL),
akashvibhute 0:30537dec6e0b 24 stop_controllers_length(0), stop_controllers(NULL)
akashvibhute 0:30537dec6e0b 25 {
akashvibhute 0:30537dec6e0b 26 }
akashvibhute 0:30537dec6e0b 27
akashvibhute 0:30537dec6e0b 28 virtual int serialize(unsigned char *outbuffer) const
akashvibhute 0:30537dec6e0b 29 {
akashvibhute 0:30537dec6e0b 30 int offset = 0;
akashvibhute 0:30537dec6e0b 31 *(outbuffer + offset++) = start_controllers_length;
akashvibhute 0:30537dec6e0b 32 *(outbuffer + offset++) = 0;
akashvibhute 0:30537dec6e0b 33 *(outbuffer + offset++) = 0;
akashvibhute 0:30537dec6e0b 34 *(outbuffer + offset++) = 0;
akashvibhute 0:30537dec6e0b 35 for( uint8_t i = 0; i < start_controllers_length; i++){
akashvibhute 0:30537dec6e0b 36 uint32_t length_start_controllersi = strlen(this->start_controllers[i]);
akashvibhute 0:30537dec6e0b 37 memcpy(outbuffer + offset, &length_start_controllersi, sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 38 offset += 4;
akashvibhute 0:30537dec6e0b 39 memcpy(outbuffer + offset, this->start_controllers[i], length_start_controllersi);
akashvibhute 0:30537dec6e0b 40 offset += length_start_controllersi;
akashvibhute 0:30537dec6e0b 41 }
akashvibhute 0:30537dec6e0b 42 *(outbuffer + offset++) = stop_controllers_length;
akashvibhute 0:30537dec6e0b 43 *(outbuffer + offset++) = 0;
akashvibhute 0:30537dec6e0b 44 *(outbuffer + offset++) = 0;
akashvibhute 0:30537dec6e0b 45 *(outbuffer + offset++) = 0;
akashvibhute 0:30537dec6e0b 46 for( uint8_t i = 0; i < stop_controllers_length; i++){
akashvibhute 0:30537dec6e0b 47 uint32_t length_stop_controllersi = strlen(this->stop_controllers[i]);
akashvibhute 0:30537dec6e0b 48 memcpy(outbuffer + offset, &length_stop_controllersi, sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 49 offset += 4;
akashvibhute 0:30537dec6e0b 50 memcpy(outbuffer + offset, this->stop_controllers[i], length_stop_controllersi);
akashvibhute 0:30537dec6e0b 51 offset += length_stop_controllersi;
akashvibhute 0:30537dec6e0b 52 }
akashvibhute 0:30537dec6e0b 53 return offset;
akashvibhute 0:30537dec6e0b 54 }
akashvibhute 0:30537dec6e0b 55
akashvibhute 0:30537dec6e0b 56 virtual int deserialize(unsigned char *inbuffer)
akashvibhute 0:30537dec6e0b 57 {
akashvibhute 0:30537dec6e0b 58 int offset = 0;
akashvibhute 0:30537dec6e0b 59 uint8_t start_controllers_lengthT = *(inbuffer + offset++);
akashvibhute 0:30537dec6e0b 60 if(start_controllers_lengthT > start_controllers_length)
akashvibhute 0:30537dec6e0b 61 this->start_controllers = (char**)realloc(this->start_controllers, start_controllers_lengthT * sizeof(char*));
akashvibhute 0:30537dec6e0b 62 offset += 3;
akashvibhute 0:30537dec6e0b 63 start_controllers_length = start_controllers_lengthT;
akashvibhute 0:30537dec6e0b 64 for( uint8_t i = 0; i < start_controllers_length; i++){
akashvibhute 0:30537dec6e0b 65 uint32_t length_st_start_controllers;
akashvibhute 0:30537dec6e0b 66 memcpy(&length_st_start_controllers, (inbuffer + offset), sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 67 offset += 4;
akashvibhute 0:30537dec6e0b 68 for(unsigned int k= offset; k< offset+length_st_start_controllers; ++k){
akashvibhute 0:30537dec6e0b 69 inbuffer[k-1]=inbuffer[k];
akashvibhute 0:30537dec6e0b 70 }
akashvibhute 0:30537dec6e0b 71 inbuffer[offset+length_st_start_controllers-1]=0;
akashvibhute 0:30537dec6e0b 72 this->st_start_controllers = (char *)(inbuffer + offset-1);
akashvibhute 0:30537dec6e0b 73 offset += length_st_start_controllers;
akashvibhute 0:30537dec6e0b 74 memcpy( &(this->start_controllers[i]), &(this->st_start_controllers), sizeof(char*));
akashvibhute 0:30537dec6e0b 75 }
akashvibhute 0:30537dec6e0b 76 uint8_t stop_controllers_lengthT = *(inbuffer + offset++);
akashvibhute 0:30537dec6e0b 77 if(stop_controllers_lengthT > stop_controllers_length)
akashvibhute 0:30537dec6e0b 78 this->stop_controllers = (char**)realloc(this->stop_controllers, stop_controllers_lengthT * sizeof(char*));
akashvibhute 0:30537dec6e0b 79 offset += 3;
akashvibhute 0:30537dec6e0b 80 stop_controllers_length = stop_controllers_lengthT;
akashvibhute 0:30537dec6e0b 81 for( uint8_t i = 0; i < stop_controllers_length; i++){
akashvibhute 0:30537dec6e0b 82 uint32_t length_st_stop_controllers;
akashvibhute 0:30537dec6e0b 83 memcpy(&length_st_stop_controllers, (inbuffer + offset), sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 84 offset += 4;
akashvibhute 0:30537dec6e0b 85 for(unsigned int k= offset; k< offset+length_st_stop_controllers; ++k){
akashvibhute 0:30537dec6e0b 86 inbuffer[k-1]=inbuffer[k];
akashvibhute 0:30537dec6e0b 87 }
akashvibhute 0:30537dec6e0b 88 inbuffer[offset+length_st_stop_controllers-1]=0;
akashvibhute 0:30537dec6e0b 89 this->st_stop_controllers = (char *)(inbuffer + offset-1);
akashvibhute 0:30537dec6e0b 90 offset += length_st_stop_controllers;
akashvibhute 0:30537dec6e0b 91 memcpy( &(this->stop_controllers[i]), &(this->st_stop_controllers), sizeof(char*));
akashvibhute 0:30537dec6e0b 92 }
akashvibhute 0:30537dec6e0b 93 return offset;
akashvibhute 0:30537dec6e0b 94 }
akashvibhute 0:30537dec6e0b 95
akashvibhute 0:30537dec6e0b 96 const char * getType(){ return "pr2_mechanism_msgs/SwitchControllerGoal"; };
akashvibhute 0:30537dec6e0b 97 const char * getMD5(){ return "c3f1879cbb2d6cd8732c0e031574dde5"; };
akashvibhute 0:30537dec6e0b 98
akashvibhute 0:30537dec6e0b 99 };
akashvibhute 0:30537dec6e0b 100
akashvibhute 0:30537dec6e0b 101 }
akashvibhute 0:30537dec6e0b 102 #endif