catchrobo2022 / Mbed 2 deprecated catchrobo2022_mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Object6DPose.h Source File

Object6DPose.h

00001 #ifndef _ROS_posedetection_msgs_Object6DPose_h
00002 #define _ROS_posedetection_msgs_Object6DPose_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "geometry_msgs/Pose.h"
00009 
00010 namespace posedetection_msgs
00011 {
00012 
00013   class Object6DPose : public ros::Msg
00014   {
00015     public:
00016       typedef geometry_msgs::Pose _pose_type;
00017       _pose_type pose;
00018       typedef float _reliability_type;
00019       _reliability_type reliability;
00020       typedef const char* _type_type;
00021       _type_type type;
00022 
00023     Object6DPose():
00024       pose(),
00025       reliability(0),
00026       type("")
00027     {
00028     }
00029 
00030     virtual int serialize(unsigned char *outbuffer) const
00031     {
00032       int offset = 0;
00033       offset += this->pose.serialize(outbuffer + offset);
00034       union {
00035         float real;
00036         uint32_t base;
00037       } u_reliability;
00038       u_reliability.real = this->reliability;
00039       *(outbuffer + offset + 0) = (u_reliability.base >> (8 * 0)) & 0xFF;
00040       *(outbuffer + offset + 1) = (u_reliability.base >> (8 * 1)) & 0xFF;
00041       *(outbuffer + offset + 2) = (u_reliability.base >> (8 * 2)) & 0xFF;
00042       *(outbuffer + offset + 3) = (u_reliability.base >> (8 * 3)) & 0xFF;
00043       offset += sizeof(this->reliability);
00044       uint32_t length_type = strlen(this->type);
00045       varToArr(outbuffer + offset, length_type);
00046       offset += 4;
00047       memcpy(outbuffer + offset, this->type, length_type);
00048       offset += length_type;
00049       return offset;
00050     }
00051 
00052     virtual int deserialize(unsigned char *inbuffer)
00053     {
00054       int offset = 0;
00055       offset += this->pose.deserialize(inbuffer + offset);
00056       union {
00057         float real;
00058         uint32_t base;
00059       } u_reliability;
00060       u_reliability.base = 0;
00061       u_reliability.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00062       u_reliability.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00063       u_reliability.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00064       u_reliability.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00065       this->reliability = u_reliability.real;
00066       offset += sizeof(this->reliability);
00067       uint32_t length_type;
00068       arrToVar(length_type, (inbuffer + offset));
00069       offset += 4;
00070       for(unsigned int k= offset; k< offset+length_type; ++k){
00071           inbuffer[k-1]=inbuffer[k];
00072       }
00073       inbuffer[offset+length_type-1]=0;
00074       this->type = (char *)(inbuffer + offset-1);
00075       offset += length_type;
00076      return offset;
00077     }
00078 
00079     virtual const char * getType(){ return "posedetection_msgs/Object6DPose"; };
00080     virtual const char * getMD5(){ return "68aad97d55c4f9555772eee1814bb3c7"; };
00081 
00082   };
00083 
00084 }
00085 #endif