rosserial for Hydro

Dependencies:   MODSERIAL

Fork of rosserial_mbed_lib by nucho

Committer:
nucho
Date:
Fri Aug 19 09:06:30 2011 +0000
Revision:
0:77afd7560544
Child:
3:1cf99502f396

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nucho 0:77afd7560544 1 #ifndef ros_SERVICE_FrameGraph_h
nucho 0:77afd7560544 2 #define ros_SERVICE_FrameGraph_h
nucho 0:77afd7560544 3 #include <stdint.h>
nucho 0:77afd7560544 4 #include <string.h>
nucho 0:77afd7560544 5 #include <stdlib.h>
nucho 0:77afd7560544 6 #include "../ros/msg.h"
nucho 0:77afd7560544 7
nucho 0:77afd7560544 8 namespace tf
nucho 0:77afd7560544 9 {
nucho 0:77afd7560544 10
nucho 0:77afd7560544 11 static const char FRAMEGRAPH[] = "tf/FrameGraph";
nucho 0:77afd7560544 12
nucho 0:77afd7560544 13 class FrameGraphRequest : public ros::Msg
nucho 0:77afd7560544 14 {
nucho 0:77afd7560544 15 public:
nucho 0:77afd7560544 16
nucho 0:77afd7560544 17 virtual int serialize(unsigned char *outbuffer)
nucho 0:77afd7560544 18 {
nucho 0:77afd7560544 19 int offset = 0;
nucho 0:77afd7560544 20 return offset;
nucho 0:77afd7560544 21 }
nucho 0:77afd7560544 22
nucho 0:77afd7560544 23 virtual int deserialize(unsigned char *inbuffer)
nucho 0:77afd7560544 24 {
nucho 0:77afd7560544 25 int offset = 0;
nucho 0:77afd7560544 26 return offset;
nucho 0:77afd7560544 27 }
nucho 0:77afd7560544 28
nucho 0:77afd7560544 29 const char * getType(){ return FRAMEGRAPH; };
nucho 0:77afd7560544 30
nucho 0:77afd7560544 31 };
nucho 0:77afd7560544 32
nucho 0:77afd7560544 33 class FrameGraphResponse : public ros::Msg
nucho 0:77afd7560544 34 {
nucho 0:77afd7560544 35 public:
nucho 0:77afd7560544 36 char * dot_graph;
nucho 0:77afd7560544 37
nucho 0:77afd7560544 38 virtual int serialize(unsigned char *outbuffer)
nucho 0:77afd7560544 39 {
nucho 0:77afd7560544 40 int offset = 0;
nucho 0:77afd7560544 41 long * length_dot_graph = (long *)(outbuffer + offset);
nucho 0:77afd7560544 42 *length_dot_graph = strlen( (const char*) this->dot_graph);
nucho 0:77afd7560544 43 offset += 4;
nucho 0:77afd7560544 44 memcpy(outbuffer + offset, this->dot_graph, *length_dot_graph);
nucho 0:77afd7560544 45 offset += *length_dot_graph;
nucho 0:77afd7560544 46 return offset;
nucho 0:77afd7560544 47 }
nucho 0:77afd7560544 48
nucho 0:77afd7560544 49 virtual int deserialize(unsigned char *inbuffer)
nucho 0:77afd7560544 50 {
nucho 0:77afd7560544 51 int offset = 0;
nucho 0:77afd7560544 52 uint32_t length_dot_graph = *(uint32_t *)(inbuffer + offset);
nucho 0:77afd7560544 53 offset += 4;
nucho 0:77afd7560544 54 for(unsigned int k= offset; k< offset+length_dot_graph; ++k){
nucho 0:77afd7560544 55 inbuffer[k-1]=inbuffer[k];
nucho 0:77afd7560544 56 }
nucho 0:77afd7560544 57 inbuffer[offset+length_dot_graph-1]=0;
nucho 0:77afd7560544 58 this->dot_graph = (char *)(inbuffer + offset-1);
nucho 0:77afd7560544 59 offset += length_dot_graph;
nucho 0:77afd7560544 60 return offset;
nucho 0:77afd7560544 61 }
nucho 0:77afd7560544 62
nucho 0:77afd7560544 63 const char * getType(){ return FRAMEGRAPH; };
nucho 0:77afd7560544 64
nucho 0:77afd7560544 65 };
nucho 0:77afd7560544 66
nucho 0:77afd7560544 67 }
nucho 0:77afd7560544 68 #endif