catchrobo2022 mbed LPC1768 メインプログラム
Dependencies: mbed
ImageMarker2.h
00001 #ifndef _ROS_image_view2_ImageMarker2_h 00002 #define _ROS_image_view2_ImageMarker2_h 00003 00004 #include <stdint.h> 00005 #include <string.h> 00006 #include <stdlib.h> 00007 #include "ros/msg.h" 00008 #include "std_msgs/Header.h" 00009 #include "geometry_msgs/Point.h" 00010 #include "geometry_msgs/PointStamped.h" 00011 #include "geometry_msgs/PoseStamped.h" 00012 #include "std_msgs/ColorRGBA.h" 00013 #include "ros/duration.h" 00014 #include "image_view2/PointArrayStamped.h" 00015 00016 namespace image_view2 00017 { 00018 00019 class ImageMarker2 : public ros::Msg 00020 { 00021 public: 00022 typedef std_msgs::Header _header_type; 00023 _header_type header; 00024 typedef const char* _ns_type; 00025 _ns_type ns; 00026 typedef int32_t _id_type; 00027 _id_type id; 00028 typedef int32_t _type_type; 00029 _type_type type; 00030 typedef int32_t _action_type; 00031 _action_type action; 00032 typedef geometry_msgs::Point _position_type; 00033 _position_type position; 00034 typedef geometry_msgs::PointStamped _position3D_type; 00035 _position3D_type position3D; 00036 typedef geometry_msgs::PoseStamped _pose_type; 00037 _pose_type pose; 00038 typedef float _scale_type; 00039 _scale_type scale; 00040 typedef float _width_type; 00041 _width_type width; 00042 typedef std_msgs::ColorRGBA _outline_color_type; 00043 _outline_color_type outline_color; 00044 typedef int8_t _filled_type; 00045 _filled_type filled; 00046 typedef std_msgs::ColorRGBA _fill_color_type; 00047 _fill_color_type fill_color; 00048 typedef ros::Duration _lifetime_type; 00049 _lifetime_type lifetime; 00050 typedef int8_t _arc_type; 00051 _arc_type arc; 00052 typedef float _angle_type; 00053 _angle_type angle; 00054 uint32_t points_length; 00055 typedef geometry_msgs::Point _points_type; 00056 _points_type st_points; 00057 _points_type * points; 00058 typedef image_view2::PointArrayStamped _points3D_type; 00059 _points3D_type points3D; 00060 uint32_t outline_colors_length; 00061 typedef std_msgs::ColorRGBA _outline_colors_type; 00062 _outline_colors_type st_outline_colors; 00063 _outline_colors_type * outline_colors; 00064 uint32_t frames_length; 00065 typedef char* _frames_type; 00066 _frames_type st_frames; 00067 _frames_type * frames; 00068 typedef const char* _text_type; 00069 _text_type text; 00070 typedef bool _left_up_origin_type; 00071 _left_up_origin_type left_up_origin; 00072 typedef bool _ratio_scale_type; 00073 _ratio_scale_type ratio_scale; 00074 enum { CIRCLE = 0 }; 00075 enum { LINE_STRIP = 1 }; 00076 enum { LINE_LIST = 2 }; 00077 enum { POLYGON = 3 }; 00078 enum { POINTS = 4 }; 00079 enum { FRAMES = 5 }; 00080 enum { TEXT = 6 }; 00081 enum { LINE_STRIP3D = 7 }; 00082 enum { LINE_LIST3D = 8 }; 00083 enum { POLYGON3D = 9 }; 00084 enum { POINTS3D = 10 }; 00085 enum { TEXT3D = 11 }; 00086 enum { CIRCLE3D = 12 }; 00087 enum { ADD = 0 }; 00088 enum { REMOVE = 1 }; 00089 00090 ImageMarker2(): 00091 header(), 00092 ns(""), 00093 id(0), 00094 type(0), 00095 action(0), 00096 position(), 00097 position3D(), 00098 pose(), 00099 scale(0), 00100 width(0), 00101 outline_color(), 00102 filled(0), 00103 fill_color(), 00104 lifetime(), 00105 arc(0), 00106 angle(0), 00107 points_length(0), points(NULL), 00108 points3D(), 00109 outline_colors_length(0), outline_colors(NULL), 00110 frames_length(0), frames(NULL), 00111 text(""), 00112 left_up_origin(0), 00113 ratio_scale(0) 00114 { 00115 } 00116 00117 virtual int serialize(unsigned char *outbuffer) const 00118 { 00119 int offset = 0; 00120 offset += this->header.serialize(outbuffer + offset); 00121 uint32_t length_ns = strlen(this->ns); 00122 varToArr(outbuffer + offset, length_ns); 00123 offset += 4; 00124 memcpy(outbuffer + offset, this->ns, length_ns); 00125 offset += length_ns; 00126 union { 00127 int32_t real; 00128 uint32_t base; 00129 } u_id; 00130 u_id.real = this->id; 00131 *(outbuffer + offset + 0) = (u_id.base >> (8 * 0)) & 0xFF; 00132 *(outbuffer + offset + 1) = (u_id.base >> (8 * 1)) & 0xFF; 00133 *(outbuffer + offset + 2) = (u_id.base >> (8 * 2)) & 0xFF; 00134 *(outbuffer + offset + 3) = (u_id.base >> (8 * 3)) & 0xFF; 00135 offset += sizeof(this->id); 00136 union { 00137 int32_t real; 00138 uint32_t base; 00139 } u_type; 00140 u_type.real = this->type; 00141 *(outbuffer + offset + 0) = (u_type.base >> (8 * 0)) & 0xFF; 00142 *(outbuffer + offset + 1) = (u_type.base >> (8 * 1)) & 0xFF; 00143 *(outbuffer + offset + 2) = (u_type.base >> (8 * 2)) & 0xFF; 00144 *(outbuffer + offset + 3) = (u_type.base >> (8 * 3)) & 0xFF; 00145 offset += sizeof(this->type); 00146 union { 00147 int32_t real; 00148 uint32_t base; 00149 } u_action; 00150 u_action.real = this->action; 00151 *(outbuffer + offset + 0) = (u_action.base >> (8 * 0)) & 0xFF; 00152 *(outbuffer + offset + 1) = (u_action.base >> (8 * 1)) & 0xFF; 00153 *(outbuffer + offset + 2) = (u_action.base >> (8 * 2)) & 0xFF; 00154 *(outbuffer + offset + 3) = (u_action.base >> (8 * 3)) & 0xFF; 00155 offset += sizeof(this->action); 00156 offset += this->position.serialize(outbuffer + offset); 00157 offset += this->position3D.serialize(outbuffer + offset); 00158 offset += this->pose.serialize(outbuffer + offset); 00159 union { 00160 float real; 00161 uint32_t base; 00162 } u_scale; 00163 u_scale.real = this->scale; 00164 *(outbuffer + offset + 0) = (u_scale.base >> (8 * 0)) & 0xFF; 00165 *(outbuffer + offset + 1) = (u_scale.base >> (8 * 1)) & 0xFF; 00166 *(outbuffer + offset + 2) = (u_scale.base >> (8 * 2)) & 0xFF; 00167 *(outbuffer + offset + 3) = (u_scale.base >> (8 * 3)) & 0xFF; 00168 offset += sizeof(this->scale); 00169 union { 00170 float real; 00171 uint32_t base; 00172 } u_width; 00173 u_width.real = this->width; 00174 *(outbuffer + offset + 0) = (u_width.base >> (8 * 0)) & 0xFF; 00175 *(outbuffer + offset + 1) = (u_width.base >> (8 * 1)) & 0xFF; 00176 *(outbuffer + offset + 2) = (u_width.base >> (8 * 2)) & 0xFF; 00177 *(outbuffer + offset + 3) = (u_width.base >> (8 * 3)) & 0xFF; 00178 offset += sizeof(this->width); 00179 offset += this->outline_color.serialize(outbuffer + offset); 00180 union { 00181 int8_t real; 00182 uint8_t base; 00183 } u_filled; 00184 u_filled.real = this->filled; 00185 *(outbuffer + offset + 0) = (u_filled.base >> (8 * 0)) & 0xFF; 00186 offset += sizeof(this->filled); 00187 offset += this->fill_color.serialize(outbuffer + offset); 00188 *(outbuffer + offset + 0) = (this->lifetime.sec >> (8 * 0)) & 0xFF; 00189 *(outbuffer + offset + 1) = (this->lifetime.sec >> (8 * 1)) & 0xFF; 00190 *(outbuffer + offset + 2) = (this->lifetime.sec >> (8 * 2)) & 0xFF; 00191 *(outbuffer + offset + 3) = (this->lifetime.sec >> (8 * 3)) & 0xFF; 00192 offset += sizeof(this->lifetime.sec); 00193 *(outbuffer + offset + 0) = (this->lifetime.nsec >> (8 * 0)) & 0xFF; 00194 *(outbuffer + offset + 1) = (this->lifetime.nsec >> (8 * 1)) & 0xFF; 00195 *(outbuffer + offset + 2) = (this->lifetime.nsec >> (8 * 2)) & 0xFF; 00196 *(outbuffer + offset + 3) = (this->lifetime.nsec >> (8 * 3)) & 0xFF; 00197 offset += sizeof(this->lifetime.nsec); 00198 union { 00199 int8_t real; 00200 uint8_t base; 00201 } u_arc; 00202 u_arc.real = this->arc; 00203 *(outbuffer + offset + 0) = (u_arc.base >> (8 * 0)) & 0xFF; 00204 offset += sizeof(this->arc); 00205 union { 00206 float real; 00207 uint32_t base; 00208 } u_angle; 00209 u_angle.real = this->angle; 00210 *(outbuffer + offset + 0) = (u_angle.base >> (8 * 0)) & 0xFF; 00211 *(outbuffer + offset + 1) = (u_angle.base >> (8 * 1)) & 0xFF; 00212 *(outbuffer + offset + 2) = (u_angle.base >> (8 * 2)) & 0xFF; 00213 *(outbuffer + offset + 3) = (u_angle.base >> (8 * 3)) & 0xFF; 00214 offset += sizeof(this->angle); 00215 *(outbuffer + offset + 0) = (this->points_length >> (8 * 0)) & 0xFF; 00216 *(outbuffer + offset + 1) = (this->points_length >> (8 * 1)) & 0xFF; 00217 *(outbuffer + offset + 2) = (this->points_length >> (8 * 2)) & 0xFF; 00218 *(outbuffer + offset + 3) = (this->points_length >> (8 * 3)) & 0xFF; 00219 offset += sizeof(this->points_length); 00220 for( uint32_t i = 0; i < points_length; i++){ 00221 offset += this->points[i].serialize(outbuffer + offset); 00222 } 00223 offset += this->points3D.serialize(outbuffer + offset); 00224 *(outbuffer + offset + 0) = (this->outline_colors_length >> (8 * 0)) & 0xFF; 00225 *(outbuffer + offset + 1) = (this->outline_colors_length >> (8 * 1)) & 0xFF; 00226 *(outbuffer + offset + 2) = (this->outline_colors_length >> (8 * 2)) & 0xFF; 00227 *(outbuffer + offset + 3) = (this->outline_colors_length >> (8 * 3)) & 0xFF; 00228 offset += sizeof(this->outline_colors_length); 00229 for( uint32_t i = 0; i < outline_colors_length; i++){ 00230 offset += this->outline_colors[i].serialize(outbuffer + offset); 00231 } 00232 *(outbuffer + offset + 0) = (this->frames_length >> (8 * 0)) & 0xFF; 00233 *(outbuffer + offset + 1) = (this->frames_length >> (8 * 1)) & 0xFF; 00234 *(outbuffer + offset + 2) = (this->frames_length >> (8 * 2)) & 0xFF; 00235 *(outbuffer + offset + 3) = (this->frames_length >> (8 * 3)) & 0xFF; 00236 offset += sizeof(this->frames_length); 00237 for( uint32_t i = 0; i < frames_length; i++){ 00238 uint32_t length_framesi = strlen(this->frames[i]); 00239 varToArr(outbuffer + offset, length_framesi); 00240 offset += 4; 00241 memcpy(outbuffer + offset, this->frames[i], length_framesi); 00242 offset += length_framesi; 00243 } 00244 uint32_t length_text = strlen(this->text); 00245 varToArr(outbuffer + offset, length_text); 00246 offset += 4; 00247 memcpy(outbuffer + offset, this->text, length_text); 00248 offset += length_text; 00249 union { 00250 bool real; 00251 uint8_t base; 00252 } u_left_up_origin; 00253 u_left_up_origin.real = this->left_up_origin; 00254 *(outbuffer + offset + 0) = (u_left_up_origin.base >> (8 * 0)) & 0xFF; 00255 offset += sizeof(this->left_up_origin); 00256 union { 00257 bool real; 00258 uint8_t base; 00259 } u_ratio_scale; 00260 u_ratio_scale.real = this->ratio_scale; 00261 *(outbuffer + offset + 0) = (u_ratio_scale.base >> (8 * 0)) & 0xFF; 00262 offset += sizeof(this->ratio_scale); 00263 return offset; 00264 } 00265 00266 virtual int deserialize(unsigned char *inbuffer) 00267 { 00268 int offset = 0; 00269 offset += this->header.deserialize(inbuffer + offset); 00270 uint32_t length_ns; 00271 arrToVar(length_ns, (inbuffer + offset)); 00272 offset += 4; 00273 for(unsigned int k= offset; k< offset+length_ns; ++k){ 00274 inbuffer[k-1]=inbuffer[k]; 00275 } 00276 inbuffer[offset+length_ns-1]=0; 00277 this->ns = (char *)(inbuffer + offset-1); 00278 offset += length_ns; 00279 union { 00280 int32_t real; 00281 uint32_t base; 00282 } u_id; 00283 u_id.base = 0; 00284 u_id.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00285 u_id.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00286 u_id.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00287 u_id.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00288 this->id = u_id.real; 00289 offset += sizeof(this->id); 00290 union { 00291 int32_t real; 00292 uint32_t base; 00293 } u_type; 00294 u_type.base = 0; 00295 u_type.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00296 u_type.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00297 u_type.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00298 u_type.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00299 this->type = u_type.real; 00300 offset += sizeof(this->type); 00301 union { 00302 int32_t real; 00303 uint32_t base; 00304 } u_action; 00305 u_action.base = 0; 00306 u_action.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00307 u_action.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00308 u_action.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00309 u_action.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00310 this->action = u_action.real; 00311 offset += sizeof(this->action); 00312 offset += this->position.deserialize(inbuffer + offset); 00313 offset += this->position3D.deserialize(inbuffer + offset); 00314 offset += this->pose.deserialize(inbuffer + offset); 00315 union { 00316 float real; 00317 uint32_t base; 00318 } u_scale; 00319 u_scale.base = 0; 00320 u_scale.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00321 u_scale.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00322 u_scale.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00323 u_scale.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00324 this->scale = u_scale.real; 00325 offset += sizeof(this->scale); 00326 union { 00327 float real; 00328 uint32_t base; 00329 } u_width; 00330 u_width.base = 0; 00331 u_width.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00332 u_width.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00333 u_width.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00334 u_width.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00335 this->width = u_width.real; 00336 offset += sizeof(this->width); 00337 offset += this->outline_color.deserialize(inbuffer + offset); 00338 union { 00339 int8_t real; 00340 uint8_t base; 00341 } u_filled; 00342 u_filled.base = 0; 00343 u_filled.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); 00344 this->filled = u_filled.real; 00345 offset += sizeof(this->filled); 00346 offset += this->fill_color.deserialize(inbuffer + offset); 00347 this->lifetime.sec = ((uint32_t) (*(inbuffer + offset))); 00348 this->lifetime.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00349 this->lifetime.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00350 this->lifetime.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00351 offset += sizeof(this->lifetime.sec); 00352 this->lifetime.nsec = ((uint32_t) (*(inbuffer + offset))); 00353 this->lifetime.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00354 this->lifetime.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00355 this->lifetime.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00356 offset += sizeof(this->lifetime.nsec); 00357 union { 00358 int8_t real; 00359 uint8_t base; 00360 } u_arc; 00361 u_arc.base = 0; 00362 u_arc.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); 00363 this->arc = u_arc.real; 00364 offset += sizeof(this->arc); 00365 union { 00366 float real; 00367 uint32_t base; 00368 } u_angle; 00369 u_angle.base = 0; 00370 u_angle.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00371 u_angle.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00372 u_angle.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00373 u_angle.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00374 this->angle = u_angle.real; 00375 offset += sizeof(this->angle); 00376 uint32_t points_lengthT = ((uint32_t) (*(inbuffer + offset))); 00377 points_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00378 points_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00379 points_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00380 offset += sizeof(this->points_length); 00381 if(points_lengthT > points_length) 00382 this->points = (geometry_msgs::Point*)realloc(this->points, points_lengthT * sizeof(geometry_msgs::Point)); 00383 points_length = points_lengthT; 00384 for( uint32_t i = 0; i < points_length; i++){ 00385 offset += this->st_points.deserialize(inbuffer + offset); 00386 memcpy( &(this->points[i]), &(this->st_points), sizeof(geometry_msgs::Point)); 00387 } 00388 offset += this->points3D.deserialize(inbuffer + offset); 00389 uint32_t outline_colors_lengthT = ((uint32_t) (*(inbuffer + offset))); 00390 outline_colors_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00391 outline_colors_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00392 outline_colors_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00393 offset += sizeof(this->outline_colors_length); 00394 if(outline_colors_lengthT > outline_colors_length) 00395 this->outline_colors = (std_msgs::ColorRGBA*)realloc(this->outline_colors, outline_colors_lengthT * sizeof(std_msgs::ColorRGBA)); 00396 outline_colors_length = outline_colors_lengthT; 00397 for( uint32_t i = 0; i < outline_colors_length; i++){ 00398 offset += this->st_outline_colors.deserialize(inbuffer + offset); 00399 memcpy( &(this->outline_colors[i]), &(this->st_outline_colors), sizeof(std_msgs::ColorRGBA)); 00400 } 00401 uint32_t frames_lengthT = ((uint32_t) (*(inbuffer + offset))); 00402 frames_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00403 frames_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00404 frames_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00405 offset += sizeof(this->frames_length); 00406 if(frames_lengthT > frames_length) 00407 this->frames = (char**)realloc(this->frames, frames_lengthT * sizeof(char*)); 00408 frames_length = frames_lengthT; 00409 for( uint32_t i = 0; i < frames_length; i++){ 00410 uint32_t length_st_frames; 00411 arrToVar(length_st_frames, (inbuffer + offset)); 00412 offset += 4; 00413 for(unsigned int k= offset; k< offset+length_st_frames; ++k){ 00414 inbuffer[k-1]=inbuffer[k]; 00415 } 00416 inbuffer[offset+length_st_frames-1]=0; 00417 this->st_frames = (char *)(inbuffer + offset-1); 00418 offset += length_st_frames; 00419 memcpy( &(this->frames[i]), &(this->st_frames), sizeof(char*)); 00420 } 00421 uint32_t length_text; 00422 arrToVar(length_text, (inbuffer + offset)); 00423 offset += 4; 00424 for(unsigned int k= offset; k< offset+length_text; ++k){ 00425 inbuffer[k-1]=inbuffer[k]; 00426 } 00427 inbuffer[offset+length_text-1]=0; 00428 this->text = (char *)(inbuffer + offset-1); 00429 offset += length_text; 00430 union { 00431 bool real; 00432 uint8_t base; 00433 } u_left_up_origin; 00434 u_left_up_origin.base = 0; 00435 u_left_up_origin.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); 00436 this->left_up_origin = u_left_up_origin.real; 00437 offset += sizeof(this->left_up_origin); 00438 union { 00439 bool real; 00440 uint8_t base; 00441 } u_ratio_scale; 00442 u_ratio_scale.base = 0; 00443 u_ratio_scale.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); 00444 this->ratio_scale = u_ratio_scale.real; 00445 offset += sizeof(this->ratio_scale); 00446 return offset; 00447 } 00448 00449 virtual const char * getType(){ return "image_view2/ImageMarker2"; }; 00450 virtual const char * getMD5(){ return "8efc23e411f94f2c04288719c078c291"; }; 00451 00452 }; 00453 00454 } 00455 #endif
Generated on Mon Sep 26 2022 13:47:01 by
1.7.2