catchrobo2022 mbed LPC1768 メインプログラム
Dependencies: mbed
List.h
00001 #ifndef _ROS_SERVICE_List_h 00002 #define _ROS_SERVICE_List_h 00003 #include <stdint.h> 00004 #include <string.h> 00005 #include <stdlib.h> 00006 #include "ros/msg.h" 00007 00008 namespace jsk_topic_tools 00009 { 00010 00011 static const char LIST[] = "jsk_topic_tools/List"; 00012 00013 class ListRequest : public ros::Msg 00014 { 00015 public: 00016 00017 ListRequest() 00018 { 00019 } 00020 00021 virtual int serialize(unsigned char *outbuffer) const 00022 { 00023 int offset = 0; 00024 return offset; 00025 } 00026 00027 virtual int deserialize(unsigned char *inbuffer) 00028 { 00029 int offset = 0; 00030 return offset; 00031 } 00032 00033 virtual const char * getType(){ return LIST; }; 00034 virtual const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; }; 00035 00036 }; 00037 00038 class ListResponse : public ros::Msg 00039 { 00040 public: 00041 uint32_t topic_names_length; 00042 typedef char* _topic_names_type; 00043 _topic_names_type st_topic_names; 00044 _topic_names_type * topic_names; 00045 00046 ListResponse(): 00047 topic_names_length(0), topic_names(NULL) 00048 { 00049 } 00050 00051 virtual int serialize(unsigned char *outbuffer) const 00052 { 00053 int offset = 0; 00054 *(outbuffer + offset + 0) = (this->topic_names_length >> (8 * 0)) & 0xFF; 00055 *(outbuffer + offset + 1) = (this->topic_names_length >> (8 * 1)) & 0xFF; 00056 *(outbuffer + offset + 2) = (this->topic_names_length >> (8 * 2)) & 0xFF; 00057 *(outbuffer + offset + 3) = (this->topic_names_length >> (8 * 3)) & 0xFF; 00058 offset += sizeof(this->topic_names_length); 00059 for( uint32_t i = 0; i < topic_names_length; i++){ 00060 uint32_t length_topic_namesi = strlen(this->topic_names[i]); 00061 varToArr(outbuffer + offset, length_topic_namesi); 00062 offset += 4; 00063 memcpy(outbuffer + offset, this->topic_names[i], length_topic_namesi); 00064 offset += length_topic_namesi; 00065 } 00066 return offset; 00067 } 00068 00069 virtual int deserialize(unsigned char *inbuffer) 00070 { 00071 int offset = 0; 00072 uint32_t topic_names_lengthT = ((uint32_t) (*(inbuffer + offset))); 00073 topic_names_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00074 topic_names_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00075 topic_names_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00076 offset += sizeof(this->topic_names_length); 00077 if(topic_names_lengthT > topic_names_length) 00078 this->topic_names = (char**)realloc(this->topic_names, topic_names_lengthT * sizeof(char*)); 00079 topic_names_length = topic_names_lengthT; 00080 for( uint32_t i = 0; i < topic_names_length; i++){ 00081 uint32_t length_st_topic_names; 00082 arrToVar(length_st_topic_names, (inbuffer + offset)); 00083 offset += 4; 00084 for(unsigned int k= offset; k< offset+length_st_topic_names; ++k){ 00085 inbuffer[k-1]=inbuffer[k]; 00086 } 00087 inbuffer[offset+length_st_topic_names-1]=0; 00088 this->st_topic_names = (char *)(inbuffer + offset-1); 00089 offset += length_st_topic_names; 00090 memcpy( &(this->topic_names[i]), &(this->st_topic_names), sizeof(char*)); 00091 } 00092 return offset; 00093 } 00094 00095 virtual const char * getType(){ return LIST; }; 00096 virtual const char * getMD5(){ return "f88f7a076bf16dde010b2480af40dcdb"; }; 00097 00098 }; 00099 00100 class List { 00101 public: 00102 typedef ListRequest Request; 00103 typedef ListResponse Response; 00104 }; 00105 00106 } 00107 #endif
Generated on Mon Sep 26 2022 13:47:01 by
1.7.2