catchrobo2022 mbed LPC1768 メインプログラム
Dependencies: mbed
RecognizedObjectArray.h
00001 #ifndef _ROS_object_recognition_msgs_RecognizedObjectArray_h 00002 #define _ROS_object_recognition_msgs_RecognizedObjectArray_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 "object_recognition_msgs/RecognizedObject.h" 00010 00011 namespace object_recognition_msgs 00012 { 00013 00014 class RecognizedObjectArray : public ros::Msg 00015 { 00016 public: 00017 typedef std_msgs::Header _header_type; 00018 _header_type header; 00019 uint32_t objects_length; 00020 typedef object_recognition_msgs::RecognizedObject _objects_type; 00021 _objects_type st_objects; 00022 _objects_type * objects; 00023 uint32_t cooccurrence_length; 00024 typedef float _cooccurrence_type; 00025 _cooccurrence_type st_cooccurrence; 00026 _cooccurrence_type * cooccurrence; 00027 00028 RecognizedObjectArray(): 00029 header(), 00030 objects_length(0), objects(NULL), 00031 cooccurrence_length(0), cooccurrence(NULL) 00032 { 00033 } 00034 00035 virtual int serialize(unsigned char *outbuffer) const 00036 { 00037 int offset = 0; 00038 offset += this->header.serialize(outbuffer + offset); 00039 *(outbuffer + offset + 0) = (this->objects_length >> (8 * 0)) & 0xFF; 00040 *(outbuffer + offset + 1) = (this->objects_length >> (8 * 1)) & 0xFF; 00041 *(outbuffer + offset + 2) = (this->objects_length >> (8 * 2)) & 0xFF; 00042 *(outbuffer + offset + 3) = (this->objects_length >> (8 * 3)) & 0xFF; 00043 offset += sizeof(this->objects_length); 00044 for( uint32_t i = 0; i < objects_length; i++){ 00045 offset += this->objects[i].serialize(outbuffer + offset); 00046 } 00047 *(outbuffer + offset + 0) = (this->cooccurrence_length >> (8 * 0)) & 0xFF; 00048 *(outbuffer + offset + 1) = (this->cooccurrence_length >> (8 * 1)) & 0xFF; 00049 *(outbuffer + offset + 2) = (this->cooccurrence_length >> (8 * 2)) & 0xFF; 00050 *(outbuffer + offset + 3) = (this->cooccurrence_length >> (8 * 3)) & 0xFF; 00051 offset += sizeof(this->cooccurrence_length); 00052 for( uint32_t i = 0; i < cooccurrence_length; i++){ 00053 union { 00054 float real; 00055 uint32_t base; 00056 } u_cooccurrencei; 00057 u_cooccurrencei.real = this->cooccurrence[i]; 00058 *(outbuffer + offset + 0) = (u_cooccurrencei.base >> (8 * 0)) & 0xFF; 00059 *(outbuffer + offset + 1) = (u_cooccurrencei.base >> (8 * 1)) & 0xFF; 00060 *(outbuffer + offset + 2) = (u_cooccurrencei.base >> (8 * 2)) & 0xFF; 00061 *(outbuffer + offset + 3) = (u_cooccurrencei.base >> (8 * 3)) & 0xFF; 00062 offset += sizeof(this->cooccurrence[i]); 00063 } 00064 return offset; 00065 } 00066 00067 virtual int deserialize(unsigned char *inbuffer) 00068 { 00069 int offset = 0; 00070 offset += this->header.deserialize(inbuffer + offset); 00071 uint32_t objects_lengthT = ((uint32_t) (*(inbuffer + offset))); 00072 objects_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00073 objects_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00074 objects_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00075 offset += sizeof(this->objects_length); 00076 if(objects_lengthT > objects_length) 00077 this->objects = (object_recognition_msgs::RecognizedObject*)realloc(this->objects, objects_lengthT * sizeof(object_recognition_msgs::RecognizedObject)); 00078 objects_length = objects_lengthT; 00079 for( uint32_t i = 0; i < objects_length; i++){ 00080 offset += this->st_objects.deserialize(inbuffer + offset); 00081 memcpy( &(this->objects[i]), &(this->st_objects), sizeof(object_recognition_msgs::RecognizedObject)); 00082 } 00083 uint32_t cooccurrence_lengthT = ((uint32_t) (*(inbuffer + offset))); 00084 cooccurrence_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00085 cooccurrence_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00086 cooccurrence_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00087 offset += sizeof(this->cooccurrence_length); 00088 if(cooccurrence_lengthT > cooccurrence_length) 00089 this->cooccurrence = (float*)realloc(this->cooccurrence, cooccurrence_lengthT * sizeof(float)); 00090 cooccurrence_length = cooccurrence_lengthT; 00091 for( uint32_t i = 0; i < cooccurrence_length; i++){ 00092 union { 00093 float real; 00094 uint32_t base; 00095 } u_st_cooccurrence; 00096 u_st_cooccurrence.base = 0; 00097 u_st_cooccurrence.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00098 u_st_cooccurrence.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00099 u_st_cooccurrence.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00100 u_st_cooccurrence.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00101 this->st_cooccurrence = u_st_cooccurrence.real; 00102 offset += sizeof(this->st_cooccurrence); 00103 memcpy( &(this->cooccurrence[i]), &(this->st_cooccurrence), sizeof(float)); 00104 } 00105 return offset; 00106 } 00107 00108 virtual const char * getType(){ return "object_recognition_msgs/RecognizedObjectArray"; }; 00109 virtual const char * getMD5(){ return "bad6b1546b9ebcabb49fb3b858d78964"; }; 00110 00111 }; 00112 00113 } 00114 #endif
Generated on Mon Sep 26 2022 13:47:03 by
1.7.2