catchrobo2022 / Mbed 2 deprecated catchrobo2022_mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Query.h Source File

Query.h

00001 #ifndef _ROS_SERVICE_Query_h
00002 #define _ROS_SERVICE_Query_h
00003 #include <stdint.h>
00004 #include <string.h>
00005 #include <stdlib.h>
00006 #include "ros/msg.h"
00007 
00008 namespace jsk_gui_msgs
00009 {
00010 
00011 static const char QUERY[] = "jsk_gui_msgs/Query";
00012 
00013   class QueryRequest : public ros::Msg
00014   {
00015     public:
00016       typedef int32_t _id_type;
00017       _id_type id;
00018 
00019     QueryRequest():
00020       id(0)
00021     {
00022     }
00023 
00024     virtual int serialize(unsigned char *outbuffer) const
00025     {
00026       int offset = 0;
00027       union {
00028         int32_t real;
00029         uint32_t base;
00030       } u_id;
00031       u_id.real = this->id;
00032       *(outbuffer + offset + 0) = (u_id.base >> (8 * 0)) & 0xFF;
00033       *(outbuffer + offset + 1) = (u_id.base >> (8 * 1)) & 0xFF;
00034       *(outbuffer + offset + 2) = (u_id.base >> (8 * 2)) & 0xFF;
00035       *(outbuffer + offset + 3) = (u_id.base >> (8 * 3)) & 0xFF;
00036       offset += sizeof(this->id);
00037       return offset;
00038     }
00039 
00040     virtual int deserialize(unsigned char *inbuffer)
00041     {
00042       int offset = 0;
00043       union {
00044         int32_t real;
00045         uint32_t base;
00046       } u_id;
00047       u_id.base = 0;
00048       u_id.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00049       u_id.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00050       u_id.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00051       u_id.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00052       this->id = u_id.real;
00053       offset += sizeof(this->id);
00054      return offset;
00055     }
00056 
00057     virtual const char * getType(){ return QUERY; };
00058     virtual const char * getMD5(){ return "c5e4a7d59c68f74eabcec876a00216aa"; };
00059 
00060   };
00061 
00062   class QueryResponse : public ros::Msg
00063   {
00064     public:
00065       typedef const char* _res_type;
00066       _res_type res;
00067 
00068     QueryResponse():
00069       res("")
00070     {
00071     }
00072 
00073     virtual int serialize(unsigned char *outbuffer) const
00074     {
00075       int offset = 0;
00076       uint32_t length_res = strlen(this->res);
00077       varToArr(outbuffer + offset, length_res);
00078       offset += 4;
00079       memcpy(outbuffer + offset, this->res, length_res);
00080       offset += length_res;
00081       return offset;
00082     }
00083 
00084     virtual int deserialize(unsigned char *inbuffer)
00085     {
00086       int offset = 0;
00087       uint32_t length_res;
00088       arrToVar(length_res, (inbuffer + offset));
00089       offset += 4;
00090       for(unsigned int k= offset; k< offset+length_res; ++k){
00091           inbuffer[k-1]=inbuffer[k];
00092       }
00093       inbuffer[offset+length_res-1]=0;
00094       this->res = (char *)(inbuffer + offset-1);
00095       offset += length_res;
00096      return offset;
00097     }
00098 
00099     virtual const char * getType(){ return QUERY; };
00100     virtual const char * getMD5(){ return "53af918a2a4a2a182c184142fff49b0c"; };
00101 
00102   };
00103 
00104   class Query {
00105     public:
00106     typedef QueryRequest Request;
00107     typedef QueryResponse Response;
00108   };
00109 
00110 }
00111 #endif