Just changed OUTPUT_SIZE and INPUT_SIZE in ros/node_handle.h
Dependents: WRS2020_mecanum_node
SelfTest.h
00001 #ifndef _ROS_SERVICE_SelfTest_h 00002 #define _ROS_SERVICE_SelfTest_h 00003 #include <stdint.h> 00004 #include <string.h> 00005 #include <stdlib.h> 00006 #include "ros/msg.h" 00007 #include "diagnostic_msgs/DiagnosticStatus.h" 00008 00009 namespace diagnostic_msgs 00010 { 00011 00012 static const char SELFTEST[] = "diagnostic_msgs/SelfTest"; 00013 00014 class SelfTestRequest : public ros::Msg 00015 { 00016 public: 00017 00018 SelfTestRequest() 00019 { 00020 } 00021 00022 virtual int serialize(unsigned char *outbuffer) const 00023 { 00024 int offset = 0; 00025 return offset; 00026 } 00027 00028 virtual int deserialize(unsigned char *inbuffer) 00029 { 00030 int offset = 0; 00031 return offset; 00032 } 00033 00034 const char * getType(){ return SELFTEST; }; 00035 const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; }; 00036 00037 }; 00038 00039 class SelfTestResponse : public ros::Msg 00040 { 00041 public: 00042 typedef const char* _id_type; 00043 _id_type id; 00044 typedef int8_t _passed_type; 00045 _passed_type passed; 00046 uint32_t status_length; 00047 typedef diagnostic_msgs::DiagnosticStatus _status_type; 00048 _status_type st_status; 00049 _status_type * status; 00050 00051 SelfTestResponse(): 00052 id(""), 00053 passed(0), 00054 status_length(0), status(NULL) 00055 { 00056 } 00057 00058 virtual int serialize(unsigned char *outbuffer) const 00059 { 00060 int offset = 0; 00061 uint32_t length_id = strlen(this->id); 00062 varToArr(outbuffer + offset, length_id); 00063 offset += 4; 00064 memcpy(outbuffer + offset, this->id, length_id); 00065 offset += length_id; 00066 union { 00067 int8_t real; 00068 uint8_t base; 00069 } u_passed; 00070 u_passed.real = this->passed; 00071 *(outbuffer + offset + 0) = (u_passed.base >> (8 * 0)) & 0xFF; 00072 offset += sizeof(this->passed); 00073 *(outbuffer + offset + 0) = (this->status_length >> (8 * 0)) & 0xFF; 00074 *(outbuffer + offset + 1) = (this->status_length >> (8 * 1)) & 0xFF; 00075 *(outbuffer + offset + 2) = (this->status_length >> (8 * 2)) & 0xFF; 00076 *(outbuffer + offset + 3) = (this->status_length >> (8 * 3)) & 0xFF; 00077 offset += sizeof(this->status_length); 00078 for( uint32_t i = 0; i < status_length; i++){ 00079 offset += this->status[i].serialize(outbuffer + offset); 00080 } 00081 return offset; 00082 } 00083 00084 virtual int deserialize(unsigned char *inbuffer) 00085 { 00086 int offset = 0; 00087 uint32_t length_id; 00088 arrToVar(length_id, (inbuffer + offset)); 00089 offset += 4; 00090 for(unsigned int k= offset; k< offset+length_id; ++k){ 00091 inbuffer[k-1]=inbuffer[k]; 00092 } 00093 inbuffer[offset+length_id-1]=0; 00094 this->id = (char *)(inbuffer + offset-1); 00095 offset += length_id; 00096 union { 00097 int8_t real; 00098 uint8_t base; 00099 } u_passed; 00100 u_passed.base = 0; 00101 u_passed.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); 00102 this->passed = u_passed.real; 00103 offset += sizeof(this->passed); 00104 uint32_t status_lengthT = ((uint32_t) (*(inbuffer + offset))); 00105 status_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00106 status_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00107 status_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00108 offset += sizeof(this->status_length); 00109 if(status_lengthT > status_length) 00110 this->status = (diagnostic_msgs::DiagnosticStatus*)realloc(this->status, status_lengthT * sizeof(diagnostic_msgs::DiagnosticStatus)); 00111 status_length = status_lengthT; 00112 for( uint32_t i = 0; i < status_length; i++){ 00113 offset += this->st_status.deserialize(inbuffer + offset); 00114 memcpy( &(this->status[i]), &(this->st_status), sizeof(diagnostic_msgs::DiagnosticStatus)); 00115 } 00116 return offset; 00117 } 00118 00119 const char * getType(){ return SELFTEST; }; 00120 const char * getMD5(){ return "ac21b1bab7ab17546986536c22eb34e9"; }; 00121 00122 }; 00123 00124 class SelfTest { 00125 public: 00126 typedef SelfTestRequest Request; 00127 typedef SelfTestResponse Response; 00128 }; 00129 00130 } 00131 #endif
Generated on Tue Jul 12 2022 18:49:19 by 1.7.2