catchrobo2022 mbed LPC1768 メインプログラム
Dependencies: mbed
SwitchController.h
00001 #ifndef _ROS_SERVICE_SwitchController_h 00002 #define _ROS_SERVICE_SwitchController_h 00003 #include <stdint.h> 00004 #include <string.h> 00005 #include <stdlib.h> 00006 #include "ros/msg.h" 00007 00008 namespace controller_manager_msgs 00009 { 00010 00011 static const char SWITCHCONTROLLER[] = "controller_manager_msgs/SwitchController"; 00012 00013 class SwitchControllerRequest : public ros::Msg 00014 { 00015 public: 00016 uint32_t start_controllers_length; 00017 typedef char* _start_controllers_type; 00018 _start_controllers_type st_start_controllers; 00019 _start_controllers_type * start_controllers; 00020 uint32_t stop_controllers_length; 00021 typedef char* _stop_controllers_type; 00022 _stop_controllers_type st_stop_controllers; 00023 _stop_controllers_type * stop_controllers; 00024 typedef int32_t _strictness_type; 00025 _strictness_type strictness; 00026 typedef bool _start_asap_type; 00027 _start_asap_type start_asap; 00028 typedef double _timeout_type; 00029 _timeout_type timeout; 00030 enum { BEST_EFFORT = 1 }; 00031 enum { STRICT = 2 }; 00032 00033 SwitchControllerRequest(): 00034 start_controllers_length(0), start_controllers(NULL), 00035 stop_controllers_length(0), stop_controllers(NULL), 00036 strictness(0), 00037 start_asap(0), 00038 timeout(0) 00039 { 00040 } 00041 00042 virtual int serialize(unsigned char *outbuffer) const 00043 { 00044 int offset = 0; 00045 *(outbuffer + offset + 0) = (this->start_controllers_length >> (8 * 0)) & 0xFF; 00046 *(outbuffer + offset + 1) = (this->start_controllers_length >> (8 * 1)) & 0xFF; 00047 *(outbuffer + offset + 2) = (this->start_controllers_length >> (8 * 2)) & 0xFF; 00048 *(outbuffer + offset + 3) = (this->start_controllers_length >> (8 * 3)) & 0xFF; 00049 offset += sizeof(this->start_controllers_length); 00050 for( uint32_t i = 0; i < start_controllers_length; i++){ 00051 uint32_t length_start_controllersi = strlen(this->start_controllers[i]); 00052 varToArr(outbuffer + offset, length_start_controllersi); 00053 offset += 4; 00054 memcpy(outbuffer + offset, this->start_controllers[i], length_start_controllersi); 00055 offset += length_start_controllersi; 00056 } 00057 *(outbuffer + offset + 0) = (this->stop_controllers_length >> (8 * 0)) & 0xFF; 00058 *(outbuffer + offset + 1) = (this->stop_controllers_length >> (8 * 1)) & 0xFF; 00059 *(outbuffer + offset + 2) = (this->stop_controllers_length >> (8 * 2)) & 0xFF; 00060 *(outbuffer + offset + 3) = (this->stop_controllers_length >> (8 * 3)) & 0xFF; 00061 offset += sizeof(this->stop_controllers_length); 00062 for( uint32_t i = 0; i < stop_controllers_length; i++){ 00063 uint32_t length_stop_controllersi = strlen(this->stop_controllers[i]); 00064 varToArr(outbuffer + offset, length_stop_controllersi); 00065 offset += 4; 00066 memcpy(outbuffer + offset, this->stop_controllers[i], length_stop_controllersi); 00067 offset += length_stop_controllersi; 00068 } 00069 union { 00070 int32_t real; 00071 uint32_t base; 00072 } u_strictness; 00073 u_strictness.real = this->strictness; 00074 *(outbuffer + offset + 0) = (u_strictness.base >> (8 * 0)) & 0xFF; 00075 *(outbuffer + offset + 1) = (u_strictness.base >> (8 * 1)) & 0xFF; 00076 *(outbuffer + offset + 2) = (u_strictness.base >> (8 * 2)) & 0xFF; 00077 *(outbuffer + offset + 3) = (u_strictness.base >> (8 * 3)) & 0xFF; 00078 offset += sizeof(this->strictness); 00079 union { 00080 bool real; 00081 uint8_t base; 00082 } u_start_asap; 00083 u_start_asap.real = this->start_asap; 00084 *(outbuffer + offset + 0) = (u_start_asap.base >> (8 * 0)) & 0xFF; 00085 offset += sizeof(this->start_asap); 00086 union { 00087 double real; 00088 uint64_t base; 00089 } u_timeout; 00090 u_timeout.real = this->timeout; 00091 *(outbuffer + offset + 0) = (u_timeout.base >> (8 * 0)) & 0xFF; 00092 *(outbuffer + offset + 1) = (u_timeout.base >> (8 * 1)) & 0xFF; 00093 *(outbuffer + offset + 2) = (u_timeout.base >> (8 * 2)) & 0xFF; 00094 *(outbuffer + offset + 3) = (u_timeout.base >> (8 * 3)) & 0xFF; 00095 *(outbuffer + offset + 4) = (u_timeout.base >> (8 * 4)) & 0xFF; 00096 *(outbuffer + offset + 5) = (u_timeout.base >> (8 * 5)) & 0xFF; 00097 *(outbuffer + offset + 6) = (u_timeout.base >> (8 * 6)) & 0xFF; 00098 *(outbuffer + offset + 7) = (u_timeout.base >> (8 * 7)) & 0xFF; 00099 offset += sizeof(this->timeout); 00100 return offset; 00101 } 00102 00103 virtual int deserialize(unsigned char *inbuffer) 00104 { 00105 int offset = 0; 00106 uint32_t start_controllers_lengthT = ((uint32_t) (*(inbuffer + offset))); 00107 start_controllers_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00108 start_controllers_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00109 start_controllers_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00110 offset += sizeof(this->start_controllers_length); 00111 if(start_controllers_lengthT > start_controllers_length) 00112 this->start_controllers = (char**)realloc(this->start_controllers, start_controllers_lengthT * sizeof(char*)); 00113 start_controllers_length = start_controllers_lengthT; 00114 for( uint32_t i = 0; i < start_controllers_length; i++){ 00115 uint32_t length_st_start_controllers; 00116 arrToVar(length_st_start_controllers, (inbuffer + offset)); 00117 offset += 4; 00118 for(unsigned int k= offset; k< offset+length_st_start_controllers; ++k){ 00119 inbuffer[k-1]=inbuffer[k]; 00120 } 00121 inbuffer[offset+length_st_start_controllers-1]=0; 00122 this->st_start_controllers = (char *)(inbuffer + offset-1); 00123 offset += length_st_start_controllers; 00124 memcpy( &(this->start_controllers[i]), &(this->st_start_controllers), sizeof(char*)); 00125 } 00126 uint32_t stop_controllers_lengthT = ((uint32_t) (*(inbuffer + offset))); 00127 stop_controllers_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00128 stop_controllers_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00129 stop_controllers_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00130 offset += sizeof(this->stop_controllers_length); 00131 if(stop_controllers_lengthT > stop_controllers_length) 00132 this->stop_controllers = (char**)realloc(this->stop_controllers, stop_controllers_lengthT * sizeof(char*)); 00133 stop_controllers_length = stop_controllers_lengthT; 00134 for( uint32_t i = 0; i < stop_controllers_length; i++){ 00135 uint32_t length_st_stop_controllers; 00136 arrToVar(length_st_stop_controllers, (inbuffer + offset)); 00137 offset += 4; 00138 for(unsigned int k= offset; k< offset+length_st_stop_controllers; ++k){ 00139 inbuffer[k-1]=inbuffer[k]; 00140 } 00141 inbuffer[offset+length_st_stop_controllers-1]=0; 00142 this->st_stop_controllers = (char *)(inbuffer + offset-1); 00143 offset += length_st_stop_controllers; 00144 memcpy( &(this->stop_controllers[i]), &(this->st_stop_controllers), sizeof(char*)); 00145 } 00146 union { 00147 int32_t real; 00148 uint32_t base; 00149 } u_strictness; 00150 u_strictness.base = 0; 00151 u_strictness.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00152 u_strictness.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00153 u_strictness.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00154 u_strictness.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00155 this->strictness = u_strictness.real; 00156 offset += sizeof(this->strictness); 00157 union { 00158 bool real; 00159 uint8_t base; 00160 } u_start_asap; 00161 u_start_asap.base = 0; 00162 u_start_asap.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); 00163 this->start_asap = u_start_asap.real; 00164 offset += sizeof(this->start_asap); 00165 union { 00166 double real; 00167 uint64_t base; 00168 } u_timeout; 00169 u_timeout.base = 0; 00170 u_timeout.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); 00171 u_timeout.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); 00172 u_timeout.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); 00173 u_timeout.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); 00174 u_timeout.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); 00175 u_timeout.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); 00176 u_timeout.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); 00177 u_timeout.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); 00178 this->timeout = u_timeout.real; 00179 offset += sizeof(this->timeout); 00180 return offset; 00181 } 00182 00183 virtual const char * getType(){ return SWITCHCONTROLLER; }; 00184 virtual const char * getMD5(){ return "36d99a977432b71d4bf16ce5847949d7"; }; 00185 00186 }; 00187 00188 class SwitchControllerResponse : public ros::Msg 00189 { 00190 public: 00191 typedef bool _ok_type; 00192 _ok_type ok; 00193 00194 SwitchControllerResponse(): 00195 ok(0) 00196 { 00197 } 00198 00199 virtual int serialize(unsigned char *outbuffer) const 00200 { 00201 int offset = 0; 00202 union { 00203 bool real; 00204 uint8_t base; 00205 } u_ok; 00206 u_ok.real = this->ok; 00207 *(outbuffer + offset + 0) = (u_ok.base >> (8 * 0)) & 0xFF; 00208 offset += sizeof(this->ok); 00209 return offset; 00210 } 00211 00212 virtual int deserialize(unsigned char *inbuffer) 00213 { 00214 int offset = 0; 00215 union { 00216 bool real; 00217 uint8_t base; 00218 } u_ok; 00219 u_ok.base = 0; 00220 u_ok.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); 00221 this->ok = u_ok.real; 00222 offset += sizeof(this->ok); 00223 return offset; 00224 } 00225 00226 virtual const char * getType(){ return SWITCHCONTROLLER; }; 00227 virtual const char * getMD5(){ return "6f6da3883749771fac40d6deb24a8c02"; }; 00228 00229 }; 00230 00231 class SwitchController { 00232 public: 00233 typedef SwitchControllerRequest Request; 00234 typedef SwitchControllerResponse Response; 00235 }; 00236 00237 } 00238 #endif
Generated on Mon Sep 26 2022 13:47:04 by
1.7.2