catchrobo2022 / Mbed 2 deprecated catchrobo2022_mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PeoplePose.h Source File

PeoplePose.h

00001 #ifndef _ROS_jsk_recognition_msgs_PeoplePose_h
00002 #define _ROS_jsk_recognition_msgs_PeoplePose_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 jsk_recognition_msgs
00011 {
00012 
00013   class PeoplePose : public ros::Msg
00014   {
00015     public:
00016       uint32_t limb_names_length;
00017       typedef char* _limb_names_type;
00018       _limb_names_type st_limb_names;
00019       _limb_names_type * limb_names;
00020       uint32_t poses_length;
00021       typedef geometry_msgs::Pose _poses_type;
00022       _poses_type st_poses;
00023       _poses_type * poses;
00024       uint32_t scores_length;
00025       typedef float _scores_type;
00026       _scores_type st_scores;
00027       _scores_type * scores;
00028 
00029     PeoplePose():
00030       limb_names_length(0), limb_names(NULL),
00031       poses_length(0), poses(NULL),
00032       scores_length(0), scores(NULL)
00033     {
00034     }
00035 
00036     virtual int serialize(unsigned char *outbuffer) const
00037     {
00038       int offset = 0;
00039       *(outbuffer + offset + 0) = (this->limb_names_length >> (8 * 0)) & 0xFF;
00040       *(outbuffer + offset + 1) = (this->limb_names_length >> (8 * 1)) & 0xFF;
00041       *(outbuffer + offset + 2) = (this->limb_names_length >> (8 * 2)) & 0xFF;
00042       *(outbuffer + offset + 3) = (this->limb_names_length >> (8 * 3)) & 0xFF;
00043       offset += sizeof(this->limb_names_length);
00044       for( uint32_t i = 0; i < limb_names_length; i++){
00045       uint32_t length_limb_namesi = strlen(this->limb_names[i]);
00046       varToArr(outbuffer + offset, length_limb_namesi);
00047       offset += 4;
00048       memcpy(outbuffer + offset, this->limb_names[i], length_limb_namesi);
00049       offset += length_limb_namesi;
00050       }
00051       *(outbuffer + offset + 0) = (this->poses_length >> (8 * 0)) & 0xFF;
00052       *(outbuffer + offset + 1) = (this->poses_length >> (8 * 1)) & 0xFF;
00053       *(outbuffer + offset + 2) = (this->poses_length >> (8 * 2)) & 0xFF;
00054       *(outbuffer + offset + 3) = (this->poses_length >> (8 * 3)) & 0xFF;
00055       offset += sizeof(this->poses_length);
00056       for( uint32_t i = 0; i < poses_length; i++){
00057       offset += this->poses[i].serialize(outbuffer + offset);
00058       }
00059       *(outbuffer + offset + 0) = (this->scores_length >> (8 * 0)) & 0xFF;
00060       *(outbuffer + offset + 1) = (this->scores_length >> (8 * 1)) & 0xFF;
00061       *(outbuffer + offset + 2) = (this->scores_length >> (8 * 2)) & 0xFF;
00062       *(outbuffer + offset + 3) = (this->scores_length >> (8 * 3)) & 0xFF;
00063       offset += sizeof(this->scores_length);
00064       for( uint32_t i = 0; i < scores_length; i++){
00065       union {
00066         float real;
00067         uint32_t base;
00068       } u_scoresi;
00069       u_scoresi.real = this->scores[i];
00070       *(outbuffer + offset + 0) = (u_scoresi.base >> (8 * 0)) & 0xFF;
00071       *(outbuffer + offset + 1) = (u_scoresi.base >> (8 * 1)) & 0xFF;
00072       *(outbuffer + offset + 2) = (u_scoresi.base >> (8 * 2)) & 0xFF;
00073       *(outbuffer + offset + 3) = (u_scoresi.base >> (8 * 3)) & 0xFF;
00074       offset += sizeof(this->scores[i]);
00075       }
00076       return offset;
00077     }
00078 
00079     virtual int deserialize(unsigned char *inbuffer)
00080     {
00081       int offset = 0;
00082       uint32_t limb_names_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00083       limb_names_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00084       limb_names_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00085       limb_names_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00086       offset += sizeof(this->limb_names_length);
00087       if(limb_names_lengthT > limb_names_length)
00088         this->limb_names = (char**)realloc(this->limb_names, limb_names_lengthT * sizeof(char*));
00089       limb_names_length = limb_names_lengthT;
00090       for( uint32_t i = 0; i < limb_names_length; i++){
00091       uint32_t length_st_limb_names;
00092       arrToVar(length_st_limb_names, (inbuffer + offset));
00093       offset += 4;
00094       for(unsigned int k= offset; k< offset+length_st_limb_names; ++k){
00095           inbuffer[k-1]=inbuffer[k];
00096       }
00097       inbuffer[offset+length_st_limb_names-1]=0;
00098       this->st_limb_names = (char *)(inbuffer + offset-1);
00099       offset += length_st_limb_names;
00100         memcpy( &(this->limb_names[i]), &(this->st_limb_names), sizeof(char*));
00101       }
00102       uint32_t poses_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00103       poses_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00104       poses_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00105       poses_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00106       offset += sizeof(this->poses_length);
00107       if(poses_lengthT > poses_length)
00108         this->poses = (geometry_msgs::Pose*)realloc(this->poses, poses_lengthT * sizeof(geometry_msgs::Pose));
00109       poses_length = poses_lengthT;
00110       for( uint32_t i = 0; i < poses_length; i++){
00111       offset += this->st_poses.deserialize(inbuffer + offset);
00112         memcpy( &(this->poses[i]), &(this->st_poses), sizeof(geometry_msgs::Pose));
00113       }
00114       uint32_t scores_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00115       scores_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00116       scores_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00117       scores_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00118       offset += sizeof(this->scores_length);
00119       if(scores_lengthT > scores_length)
00120         this->scores = (float*)realloc(this->scores, scores_lengthT * sizeof(float));
00121       scores_length = scores_lengthT;
00122       for( uint32_t i = 0; i < scores_length; i++){
00123       union {
00124         float real;
00125         uint32_t base;
00126       } u_st_scores;
00127       u_st_scores.base = 0;
00128       u_st_scores.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00129       u_st_scores.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00130       u_st_scores.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00131       u_st_scores.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00132       this->st_scores = u_st_scores.real;
00133       offset += sizeof(this->st_scores);
00134         memcpy( &(this->scores[i]), &(this->st_scores), sizeof(float));
00135       }
00136      return offset;
00137     }
00138 
00139     virtual const char * getType(){ return "jsk_recognition_msgs/PeoplePose"; };
00140     virtual const char * getMD5(){ return "24f6e59dae1b7cbd9d480f0008a5a515"; };
00141 
00142   };
00143 
00144 }
00145 #endif