catchrobo2022 / Mbed 2 deprecated catchrobo2022_mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers YesNo.h Source File

YesNo.h

00001 #ifndef _ROS_SERVICE_YesNo_h
00002 #define _ROS_SERVICE_YesNo_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 YESNO[] = "jsk_gui_msgs/YesNo";
00012 
00013   class YesNoRequest : public ros::Msg
00014   {
00015     public:
00016       typedef const char* _message_type;
00017       _message_type message;
00018 
00019     YesNoRequest():
00020       message("")
00021     {
00022     }
00023 
00024     virtual int serialize(unsigned char *outbuffer) const
00025     {
00026       int offset = 0;
00027       uint32_t length_message = strlen(this->message);
00028       varToArr(outbuffer + offset, length_message);
00029       offset += 4;
00030       memcpy(outbuffer + offset, this->message, length_message);
00031       offset += length_message;
00032       return offset;
00033     }
00034 
00035     virtual int deserialize(unsigned char *inbuffer)
00036     {
00037       int offset = 0;
00038       uint32_t length_message;
00039       arrToVar(length_message, (inbuffer + offset));
00040       offset += 4;
00041       for(unsigned int k= offset; k< offset+length_message; ++k){
00042           inbuffer[k-1]=inbuffer[k];
00043       }
00044       inbuffer[offset+length_message-1]=0;
00045       this->message = (char *)(inbuffer + offset-1);
00046       offset += length_message;
00047      return offset;
00048     }
00049 
00050     virtual const char * getType(){ return YESNO; };
00051     virtual const char * getMD5(){ return "5f003d6bcc824cbd51361d66d8e4f76c"; };
00052 
00053   };
00054 
00055   class YesNoResponse : public ros::Msg
00056   {
00057     public:
00058       typedef bool _yes_type;
00059       _yes_type yes;
00060 
00061     YesNoResponse():
00062       yes(0)
00063     {
00064     }
00065 
00066     virtual int serialize(unsigned char *outbuffer) const
00067     {
00068       int offset = 0;
00069       union {
00070         bool real;
00071         uint8_t base;
00072       } u_yes;
00073       u_yes.real = this->yes;
00074       *(outbuffer + offset + 0) = (u_yes.base >> (8 * 0)) & 0xFF;
00075       offset += sizeof(this->yes);
00076       return offset;
00077     }
00078 
00079     virtual int deserialize(unsigned char *inbuffer)
00080     {
00081       int offset = 0;
00082       union {
00083         bool real;
00084         uint8_t base;
00085       } u_yes;
00086       u_yes.base = 0;
00087       u_yes.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
00088       this->yes = u_yes.real;
00089       offset += sizeof(this->yes);
00090      return offset;
00091     }
00092 
00093     virtual const char * getType(){ return YESNO; };
00094     virtual const char * getMD5(){ return "aa7d186fb6268a501cd4c0c274f480ff"; };
00095 
00096   };
00097 
00098   class YesNo {
00099     public:
00100     typedef YesNoRequest Request;
00101     typedef YesNoResponse Response;
00102   };
00103 
00104 }
00105 #endif