catchrobo2022 mbed LPC1768 メインプログラム

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GetType.h Source File

GetType.h

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