catchrobo2022 / Mbed 2 deprecated catchrobo2022_mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Feature0D.h Source File

Feature0D.h

00001 #ifndef _ROS_posedetection_msgs_Feature0D_h
00002 #define _ROS_posedetection_msgs_Feature0D_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 
00010 namespace posedetection_msgs
00011 {
00012 
00013   class Feature0D : public ros::Msg
00014   {
00015     public:
00016       typedef std_msgs::Header _header_type;
00017       _header_type header;
00018       uint32_t positions_length;
00019       typedef float _positions_type;
00020       _positions_type st_positions;
00021       _positions_type * positions;
00022       uint32_t scales_length;
00023       typedef float _scales_type;
00024       _scales_type st_scales;
00025       _scales_type * scales;
00026       uint32_t orientations_length;
00027       typedef float _orientations_type;
00028       _orientations_type st_orientations;
00029       _orientations_type * orientations;
00030       uint32_t confidences_length;
00031       typedef float _confidences_type;
00032       _confidences_type st_confidences;
00033       _confidences_type * confidences;
00034       uint32_t descriptors_length;
00035       typedef float _descriptors_type;
00036       _descriptors_type st_descriptors;
00037       _descriptors_type * descriptors;
00038       typedef int32_t _descriptor_dim_type;
00039       _descriptor_dim_type descriptor_dim;
00040       typedef const char* _type_type;
00041       _type_type type;
00042 
00043     Feature0D():
00044       header(),
00045       positions_length(0), positions(NULL),
00046       scales_length(0), scales(NULL),
00047       orientations_length(0), orientations(NULL),
00048       confidences_length(0), confidences(NULL),
00049       descriptors_length(0), descriptors(NULL),
00050       descriptor_dim(0),
00051       type("")
00052     {
00053     }
00054 
00055     virtual int serialize(unsigned char *outbuffer) const
00056     {
00057       int offset = 0;
00058       offset += this->header.serialize(outbuffer + offset);
00059       *(outbuffer + offset + 0) = (this->positions_length >> (8 * 0)) & 0xFF;
00060       *(outbuffer + offset + 1) = (this->positions_length >> (8 * 1)) & 0xFF;
00061       *(outbuffer + offset + 2) = (this->positions_length >> (8 * 2)) & 0xFF;
00062       *(outbuffer + offset + 3) = (this->positions_length >> (8 * 3)) & 0xFF;
00063       offset += sizeof(this->positions_length);
00064       for( uint32_t i = 0; i < positions_length; i++){
00065       union {
00066         float real;
00067         uint32_t base;
00068       } u_positionsi;
00069       u_positionsi.real = this->positions[i];
00070       *(outbuffer + offset + 0) = (u_positionsi.base >> (8 * 0)) & 0xFF;
00071       *(outbuffer + offset + 1) = (u_positionsi.base >> (8 * 1)) & 0xFF;
00072       *(outbuffer + offset + 2) = (u_positionsi.base >> (8 * 2)) & 0xFF;
00073       *(outbuffer + offset + 3) = (u_positionsi.base >> (8 * 3)) & 0xFF;
00074       offset += sizeof(this->positions[i]);
00075       }
00076       *(outbuffer + offset + 0) = (this->scales_length >> (8 * 0)) & 0xFF;
00077       *(outbuffer + offset + 1) = (this->scales_length >> (8 * 1)) & 0xFF;
00078       *(outbuffer + offset + 2) = (this->scales_length >> (8 * 2)) & 0xFF;
00079       *(outbuffer + offset + 3) = (this->scales_length >> (8 * 3)) & 0xFF;
00080       offset += sizeof(this->scales_length);
00081       for( uint32_t i = 0; i < scales_length; i++){
00082       union {
00083         float real;
00084         uint32_t base;
00085       } u_scalesi;
00086       u_scalesi.real = this->scales[i];
00087       *(outbuffer + offset + 0) = (u_scalesi.base >> (8 * 0)) & 0xFF;
00088       *(outbuffer + offset + 1) = (u_scalesi.base >> (8 * 1)) & 0xFF;
00089       *(outbuffer + offset + 2) = (u_scalesi.base >> (8 * 2)) & 0xFF;
00090       *(outbuffer + offset + 3) = (u_scalesi.base >> (8 * 3)) & 0xFF;
00091       offset += sizeof(this->scales[i]);
00092       }
00093       *(outbuffer + offset + 0) = (this->orientations_length >> (8 * 0)) & 0xFF;
00094       *(outbuffer + offset + 1) = (this->orientations_length >> (8 * 1)) & 0xFF;
00095       *(outbuffer + offset + 2) = (this->orientations_length >> (8 * 2)) & 0xFF;
00096       *(outbuffer + offset + 3) = (this->orientations_length >> (8 * 3)) & 0xFF;
00097       offset += sizeof(this->orientations_length);
00098       for( uint32_t i = 0; i < orientations_length; i++){
00099       union {
00100         float real;
00101         uint32_t base;
00102       } u_orientationsi;
00103       u_orientationsi.real = this->orientations[i];
00104       *(outbuffer + offset + 0) = (u_orientationsi.base >> (8 * 0)) & 0xFF;
00105       *(outbuffer + offset + 1) = (u_orientationsi.base >> (8 * 1)) & 0xFF;
00106       *(outbuffer + offset + 2) = (u_orientationsi.base >> (8 * 2)) & 0xFF;
00107       *(outbuffer + offset + 3) = (u_orientationsi.base >> (8 * 3)) & 0xFF;
00108       offset += sizeof(this->orientations[i]);
00109       }
00110       *(outbuffer + offset + 0) = (this->confidences_length >> (8 * 0)) & 0xFF;
00111       *(outbuffer + offset + 1) = (this->confidences_length >> (8 * 1)) & 0xFF;
00112       *(outbuffer + offset + 2) = (this->confidences_length >> (8 * 2)) & 0xFF;
00113       *(outbuffer + offset + 3) = (this->confidences_length >> (8 * 3)) & 0xFF;
00114       offset += sizeof(this->confidences_length);
00115       for( uint32_t i = 0; i < confidences_length; i++){
00116       union {
00117         float real;
00118         uint32_t base;
00119       } u_confidencesi;
00120       u_confidencesi.real = this->confidences[i];
00121       *(outbuffer + offset + 0) = (u_confidencesi.base >> (8 * 0)) & 0xFF;
00122       *(outbuffer + offset + 1) = (u_confidencesi.base >> (8 * 1)) & 0xFF;
00123       *(outbuffer + offset + 2) = (u_confidencesi.base >> (8 * 2)) & 0xFF;
00124       *(outbuffer + offset + 3) = (u_confidencesi.base >> (8 * 3)) & 0xFF;
00125       offset += sizeof(this->confidences[i]);
00126       }
00127       *(outbuffer + offset + 0) = (this->descriptors_length >> (8 * 0)) & 0xFF;
00128       *(outbuffer + offset + 1) = (this->descriptors_length >> (8 * 1)) & 0xFF;
00129       *(outbuffer + offset + 2) = (this->descriptors_length >> (8 * 2)) & 0xFF;
00130       *(outbuffer + offset + 3) = (this->descriptors_length >> (8 * 3)) & 0xFF;
00131       offset += sizeof(this->descriptors_length);
00132       for( uint32_t i = 0; i < descriptors_length; i++){
00133       union {
00134         float real;
00135         uint32_t base;
00136       } u_descriptorsi;
00137       u_descriptorsi.real = this->descriptors[i];
00138       *(outbuffer + offset + 0) = (u_descriptorsi.base >> (8 * 0)) & 0xFF;
00139       *(outbuffer + offset + 1) = (u_descriptorsi.base >> (8 * 1)) & 0xFF;
00140       *(outbuffer + offset + 2) = (u_descriptorsi.base >> (8 * 2)) & 0xFF;
00141       *(outbuffer + offset + 3) = (u_descriptorsi.base >> (8 * 3)) & 0xFF;
00142       offset += sizeof(this->descriptors[i]);
00143       }
00144       union {
00145         int32_t real;
00146         uint32_t base;
00147       } u_descriptor_dim;
00148       u_descriptor_dim.real = this->descriptor_dim;
00149       *(outbuffer + offset + 0) = (u_descriptor_dim.base >> (8 * 0)) & 0xFF;
00150       *(outbuffer + offset + 1) = (u_descriptor_dim.base >> (8 * 1)) & 0xFF;
00151       *(outbuffer + offset + 2) = (u_descriptor_dim.base >> (8 * 2)) & 0xFF;
00152       *(outbuffer + offset + 3) = (u_descriptor_dim.base >> (8 * 3)) & 0xFF;
00153       offset += sizeof(this->descriptor_dim);
00154       uint32_t length_type = strlen(this->type);
00155       varToArr(outbuffer + offset, length_type);
00156       offset += 4;
00157       memcpy(outbuffer + offset, this->type, length_type);
00158       offset += length_type;
00159       return offset;
00160     }
00161 
00162     virtual int deserialize(unsigned char *inbuffer)
00163     {
00164       int offset = 0;
00165       offset += this->header.deserialize(inbuffer + offset);
00166       uint32_t positions_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00167       positions_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00168       positions_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00169       positions_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00170       offset += sizeof(this->positions_length);
00171       if(positions_lengthT > positions_length)
00172         this->positions = (float*)realloc(this->positions, positions_lengthT * sizeof(float));
00173       positions_length = positions_lengthT;
00174       for( uint32_t i = 0; i < positions_length; i++){
00175       union {
00176         float real;
00177         uint32_t base;
00178       } u_st_positions;
00179       u_st_positions.base = 0;
00180       u_st_positions.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00181       u_st_positions.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00182       u_st_positions.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00183       u_st_positions.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00184       this->st_positions = u_st_positions.real;
00185       offset += sizeof(this->st_positions);
00186         memcpy( &(this->positions[i]), &(this->st_positions), sizeof(float));
00187       }
00188       uint32_t scales_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00189       scales_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00190       scales_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00191       scales_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00192       offset += sizeof(this->scales_length);
00193       if(scales_lengthT > scales_length)
00194         this->scales = (float*)realloc(this->scales, scales_lengthT * sizeof(float));
00195       scales_length = scales_lengthT;
00196       for( uint32_t i = 0; i < scales_length; i++){
00197       union {
00198         float real;
00199         uint32_t base;
00200       } u_st_scales;
00201       u_st_scales.base = 0;
00202       u_st_scales.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00203       u_st_scales.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00204       u_st_scales.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00205       u_st_scales.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00206       this->st_scales = u_st_scales.real;
00207       offset += sizeof(this->st_scales);
00208         memcpy( &(this->scales[i]), &(this->st_scales), sizeof(float));
00209       }
00210       uint32_t orientations_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00211       orientations_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00212       orientations_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00213       orientations_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00214       offset += sizeof(this->orientations_length);
00215       if(orientations_lengthT > orientations_length)
00216         this->orientations = (float*)realloc(this->orientations, orientations_lengthT * sizeof(float));
00217       orientations_length = orientations_lengthT;
00218       for( uint32_t i = 0; i < orientations_length; i++){
00219       union {
00220         float real;
00221         uint32_t base;
00222       } u_st_orientations;
00223       u_st_orientations.base = 0;
00224       u_st_orientations.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00225       u_st_orientations.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00226       u_st_orientations.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00227       u_st_orientations.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00228       this->st_orientations = u_st_orientations.real;
00229       offset += sizeof(this->st_orientations);
00230         memcpy( &(this->orientations[i]), &(this->st_orientations), sizeof(float));
00231       }
00232       uint32_t confidences_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00233       confidences_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00234       confidences_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00235       confidences_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00236       offset += sizeof(this->confidences_length);
00237       if(confidences_lengthT > confidences_length)
00238         this->confidences = (float*)realloc(this->confidences, confidences_lengthT * sizeof(float));
00239       confidences_length = confidences_lengthT;
00240       for( uint32_t i = 0; i < confidences_length; i++){
00241       union {
00242         float real;
00243         uint32_t base;
00244       } u_st_confidences;
00245       u_st_confidences.base = 0;
00246       u_st_confidences.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00247       u_st_confidences.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00248       u_st_confidences.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00249       u_st_confidences.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00250       this->st_confidences = u_st_confidences.real;
00251       offset += sizeof(this->st_confidences);
00252         memcpy( &(this->confidences[i]), &(this->st_confidences), sizeof(float));
00253       }
00254       uint32_t descriptors_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00255       descriptors_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00256       descriptors_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00257       descriptors_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00258       offset += sizeof(this->descriptors_length);
00259       if(descriptors_lengthT > descriptors_length)
00260         this->descriptors = (float*)realloc(this->descriptors, descriptors_lengthT * sizeof(float));
00261       descriptors_length = descriptors_lengthT;
00262       for( uint32_t i = 0; i < descriptors_length; i++){
00263       union {
00264         float real;
00265         uint32_t base;
00266       } u_st_descriptors;
00267       u_st_descriptors.base = 0;
00268       u_st_descriptors.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00269       u_st_descriptors.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00270       u_st_descriptors.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00271       u_st_descriptors.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00272       this->st_descriptors = u_st_descriptors.real;
00273       offset += sizeof(this->st_descriptors);
00274         memcpy( &(this->descriptors[i]), &(this->st_descriptors), sizeof(float));
00275       }
00276       union {
00277         int32_t real;
00278         uint32_t base;
00279       } u_descriptor_dim;
00280       u_descriptor_dim.base = 0;
00281       u_descriptor_dim.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00282       u_descriptor_dim.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00283       u_descriptor_dim.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00284       u_descriptor_dim.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00285       this->descriptor_dim = u_descriptor_dim.real;
00286       offset += sizeof(this->descriptor_dim);
00287       uint32_t length_type;
00288       arrToVar(length_type, (inbuffer + offset));
00289       offset += 4;
00290       for(unsigned int k= offset; k< offset+length_type; ++k){
00291           inbuffer[k-1]=inbuffer[k];
00292       }
00293       inbuffer[offset+length_type-1]=0;
00294       this->type = (char *)(inbuffer + offset-1);
00295       offset += length_type;
00296      return offset;
00297     }
00298 
00299     virtual const char * getType(){ return "posedetection_msgs/Feature0D"; };
00300     virtual const char * getMD5(){ return "fcb3ba42a42cf972f3838cdb171f5e04"; };
00301 
00302   };
00303 
00304 }
00305 #endif