catchrobo2022 / Mbed 2 deprecated catchrobo2022_mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Feature1D.h Source File

Feature1D.h

00001 #ifndef _ROS_posedetection_msgs_Feature1D_h
00002 #define _ROS_posedetection_msgs_Feature1D_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 "posedetection_msgs/Curve1D.h"
00010 
00011 namespace posedetection_msgs
00012 {
00013 
00014   class Feature1D : public ros::Msg
00015   {
00016     public:
00017       typedef std_msgs::Header _header_type;
00018       _header_type header;
00019       uint32_t lines_length;
00020       typedef posedetection_msgs::Curve1D _lines_type;
00021       _lines_type st_lines;
00022       _lines_type * lines;
00023       uint32_t descriptors_length;
00024       typedef float _descriptors_type;
00025       _descriptors_type st_descriptors;
00026       _descriptors_type * descriptors;
00027       uint32_t confidences_length;
00028       typedef float _confidences_type;
00029       _confidences_type st_confidences;
00030       _confidences_type * confidences;
00031       typedef int32_t _descriptor_dim_type;
00032       _descriptor_dim_type descriptor_dim;
00033 
00034     Feature1D():
00035       header(),
00036       lines_length(0), lines(NULL),
00037       descriptors_length(0), descriptors(NULL),
00038       confidences_length(0), confidences(NULL),
00039       descriptor_dim(0)
00040     {
00041     }
00042 
00043     virtual int serialize(unsigned char *outbuffer) const
00044     {
00045       int offset = 0;
00046       offset += this->header.serialize(outbuffer + offset);
00047       *(outbuffer + offset + 0) = (this->lines_length >> (8 * 0)) & 0xFF;
00048       *(outbuffer + offset + 1) = (this->lines_length >> (8 * 1)) & 0xFF;
00049       *(outbuffer + offset + 2) = (this->lines_length >> (8 * 2)) & 0xFF;
00050       *(outbuffer + offset + 3) = (this->lines_length >> (8 * 3)) & 0xFF;
00051       offset += sizeof(this->lines_length);
00052       for( uint32_t i = 0; i < lines_length; i++){
00053       offset += this->lines[i].serialize(outbuffer + offset);
00054       }
00055       *(outbuffer + offset + 0) = (this->descriptors_length >> (8 * 0)) & 0xFF;
00056       *(outbuffer + offset + 1) = (this->descriptors_length >> (8 * 1)) & 0xFF;
00057       *(outbuffer + offset + 2) = (this->descriptors_length >> (8 * 2)) & 0xFF;
00058       *(outbuffer + offset + 3) = (this->descriptors_length >> (8 * 3)) & 0xFF;
00059       offset += sizeof(this->descriptors_length);
00060       for( uint32_t i = 0; i < descriptors_length; i++){
00061       union {
00062         float real;
00063         uint32_t base;
00064       } u_descriptorsi;
00065       u_descriptorsi.real = this->descriptors[i];
00066       *(outbuffer + offset + 0) = (u_descriptorsi.base >> (8 * 0)) & 0xFF;
00067       *(outbuffer + offset + 1) = (u_descriptorsi.base >> (8 * 1)) & 0xFF;
00068       *(outbuffer + offset + 2) = (u_descriptorsi.base >> (8 * 2)) & 0xFF;
00069       *(outbuffer + offset + 3) = (u_descriptorsi.base >> (8 * 3)) & 0xFF;
00070       offset += sizeof(this->descriptors[i]);
00071       }
00072       *(outbuffer + offset + 0) = (this->confidences_length >> (8 * 0)) & 0xFF;
00073       *(outbuffer + offset + 1) = (this->confidences_length >> (8 * 1)) & 0xFF;
00074       *(outbuffer + offset + 2) = (this->confidences_length >> (8 * 2)) & 0xFF;
00075       *(outbuffer + offset + 3) = (this->confidences_length >> (8 * 3)) & 0xFF;
00076       offset += sizeof(this->confidences_length);
00077       for( uint32_t i = 0; i < confidences_length; i++){
00078       union {
00079         float real;
00080         uint32_t base;
00081       } u_confidencesi;
00082       u_confidencesi.real = this->confidences[i];
00083       *(outbuffer + offset + 0) = (u_confidencesi.base >> (8 * 0)) & 0xFF;
00084       *(outbuffer + offset + 1) = (u_confidencesi.base >> (8 * 1)) & 0xFF;
00085       *(outbuffer + offset + 2) = (u_confidencesi.base >> (8 * 2)) & 0xFF;
00086       *(outbuffer + offset + 3) = (u_confidencesi.base >> (8 * 3)) & 0xFF;
00087       offset += sizeof(this->confidences[i]);
00088       }
00089       union {
00090         int32_t real;
00091         uint32_t base;
00092       } u_descriptor_dim;
00093       u_descriptor_dim.real = this->descriptor_dim;
00094       *(outbuffer + offset + 0) = (u_descriptor_dim.base >> (8 * 0)) & 0xFF;
00095       *(outbuffer + offset + 1) = (u_descriptor_dim.base >> (8 * 1)) & 0xFF;
00096       *(outbuffer + offset + 2) = (u_descriptor_dim.base >> (8 * 2)) & 0xFF;
00097       *(outbuffer + offset + 3) = (u_descriptor_dim.base >> (8 * 3)) & 0xFF;
00098       offset += sizeof(this->descriptor_dim);
00099       return offset;
00100     }
00101 
00102     virtual int deserialize(unsigned char *inbuffer)
00103     {
00104       int offset = 0;
00105       offset += this->header.deserialize(inbuffer + offset);
00106       uint32_t lines_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00107       lines_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00108       lines_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00109       lines_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00110       offset += sizeof(this->lines_length);
00111       if(lines_lengthT > lines_length)
00112         this->lines = (posedetection_msgs::Curve1D*)realloc(this->lines, lines_lengthT * sizeof(posedetection_msgs::Curve1D));
00113       lines_length = lines_lengthT;
00114       for( uint32_t i = 0; i < lines_length; i++){
00115       offset += this->st_lines.deserialize(inbuffer + offset);
00116         memcpy( &(this->lines[i]), &(this->st_lines), sizeof(posedetection_msgs::Curve1D));
00117       }
00118       uint32_t descriptors_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00119       descriptors_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00120       descriptors_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00121       descriptors_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00122       offset += sizeof(this->descriptors_length);
00123       if(descriptors_lengthT > descriptors_length)
00124         this->descriptors = (float*)realloc(this->descriptors, descriptors_lengthT * sizeof(float));
00125       descriptors_length = descriptors_lengthT;
00126       for( uint32_t i = 0; i < descriptors_length; i++){
00127       union {
00128         float real;
00129         uint32_t base;
00130       } u_st_descriptors;
00131       u_st_descriptors.base = 0;
00132       u_st_descriptors.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00133       u_st_descriptors.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00134       u_st_descriptors.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00135       u_st_descriptors.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00136       this->st_descriptors = u_st_descriptors.real;
00137       offset += sizeof(this->st_descriptors);
00138         memcpy( &(this->descriptors[i]), &(this->st_descriptors), sizeof(float));
00139       }
00140       uint32_t confidences_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00141       confidences_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00142       confidences_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00143       confidences_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00144       offset += sizeof(this->confidences_length);
00145       if(confidences_lengthT > confidences_length)
00146         this->confidences = (float*)realloc(this->confidences, confidences_lengthT * sizeof(float));
00147       confidences_length = confidences_lengthT;
00148       for( uint32_t i = 0; i < confidences_length; i++){
00149       union {
00150         float real;
00151         uint32_t base;
00152       } u_st_confidences;
00153       u_st_confidences.base = 0;
00154       u_st_confidences.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00155       u_st_confidences.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00156       u_st_confidences.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00157       u_st_confidences.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00158       this->st_confidences = u_st_confidences.real;
00159       offset += sizeof(this->st_confidences);
00160         memcpy( &(this->confidences[i]), &(this->st_confidences), sizeof(float));
00161       }
00162       union {
00163         int32_t real;
00164         uint32_t base;
00165       } u_descriptor_dim;
00166       u_descriptor_dim.base = 0;
00167       u_descriptor_dim.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00168       u_descriptor_dim.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00169       u_descriptor_dim.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00170       u_descriptor_dim.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00171       this->descriptor_dim = u_descriptor_dim.real;
00172       offset += sizeof(this->descriptor_dim);
00173      return offset;
00174     }
00175 
00176     virtual const char * getType(){ return "posedetection_msgs/Feature1D"; };
00177     virtual const char * getMD5(){ return "4568f21f2dd0840ca2d658d4d1710f33"; };
00178 
00179   };
00180 
00181 }
00182 #endif