catchrobo2022 mbed LPC1768 メインプログラム

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PositionMeasurement.h Source File

PositionMeasurement.h

00001 #ifndef _ROS_people_msgs_PositionMeasurement_h
00002 #define _ROS_people_msgs_PositionMeasurement_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 "geometry_msgs/Point.h"
00010 
00011 namespace people_msgs
00012 {
00013 
00014   class PositionMeasurement : public ros::Msg
00015   {
00016     public:
00017       typedef std_msgs::Header _header_type;
00018       _header_type header;
00019       typedef const char* _name_type;
00020       _name_type name;
00021       typedef const char* _object_id_type;
00022       _object_id_type object_id;
00023       typedef geometry_msgs::Point _pos_type;
00024       _pos_type pos;
00025       typedef double _reliability_type;
00026       _reliability_type reliability;
00027       double covariance[9];
00028       typedef int8_t _initialization_type;
00029       _initialization_type initialization;
00030 
00031     PositionMeasurement():
00032       header(),
00033       name(""),
00034       object_id(""),
00035       pos(),
00036       reliability(0),
00037       covariance(),
00038       initialization(0)
00039     {
00040     }
00041 
00042     virtual int serialize(unsigned char *outbuffer) const
00043     {
00044       int offset = 0;
00045       offset += this->header.serialize(outbuffer + offset);
00046       uint32_t length_name = strlen(this->name);
00047       varToArr(outbuffer + offset, length_name);
00048       offset += 4;
00049       memcpy(outbuffer + offset, this->name, length_name);
00050       offset += length_name;
00051       uint32_t length_object_id = strlen(this->object_id);
00052       varToArr(outbuffer + offset, length_object_id);
00053       offset += 4;
00054       memcpy(outbuffer + offset, this->object_id, length_object_id);
00055       offset += length_object_id;
00056       offset += this->pos.serialize(outbuffer + offset);
00057       union {
00058         double real;
00059         uint64_t base;
00060       } u_reliability;
00061       u_reliability.real = this->reliability;
00062       *(outbuffer + offset + 0) = (u_reliability.base >> (8 * 0)) & 0xFF;
00063       *(outbuffer + offset + 1) = (u_reliability.base >> (8 * 1)) & 0xFF;
00064       *(outbuffer + offset + 2) = (u_reliability.base >> (8 * 2)) & 0xFF;
00065       *(outbuffer + offset + 3) = (u_reliability.base >> (8 * 3)) & 0xFF;
00066       *(outbuffer + offset + 4) = (u_reliability.base >> (8 * 4)) & 0xFF;
00067       *(outbuffer + offset + 5) = (u_reliability.base >> (8 * 5)) & 0xFF;
00068       *(outbuffer + offset + 6) = (u_reliability.base >> (8 * 6)) & 0xFF;
00069       *(outbuffer + offset + 7) = (u_reliability.base >> (8 * 7)) & 0xFF;
00070       offset += sizeof(this->reliability);
00071       for( uint32_t i = 0; i < 9; i++){
00072       union {
00073         double real;
00074         uint64_t base;
00075       } u_covariancei;
00076       u_covariancei.real = this->covariance[i];
00077       *(outbuffer + offset + 0) = (u_covariancei.base >> (8 * 0)) & 0xFF;
00078       *(outbuffer + offset + 1) = (u_covariancei.base >> (8 * 1)) & 0xFF;
00079       *(outbuffer + offset + 2) = (u_covariancei.base >> (8 * 2)) & 0xFF;
00080       *(outbuffer + offset + 3) = (u_covariancei.base >> (8 * 3)) & 0xFF;
00081       *(outbuffer + offset + 4) = (u_covariancei.base >> (8 * 4)) & 0xFF;
00082       *(outbuffer + offset + 5) = (u_covariancei.base >> (8 * 5)) & 0xFF;
00083       *(outbuffer + offset + 6) = (u_covariancei.base >> (8 * 6)) & 0xFF;
00084       *(outbuffer + offset + 7) = (u_covariancei.base >> (8 * 7)) & 0xFF;
00085       offset += sizeof(this->covariance[i]);
00086       }
00087       union {
00088         int8_t real;
00089         uint8_t base;
00090       } u_initialization;
00091       u_initialization.real = this->initialization;
00092       *(outbuffer + offset + 0) = (u_initialization.base >> (8 * 0)) & 0xFF;
00093       offset += sizeof(this->initialization);
00094       return offset;
00095     }
00096 
00097     virtual int deserialize(unsigned char *inbuffer)
00098     {
00099       int offset = 0;
00100       offset += this->header.deserialize(inbuffer + offset);
00101       uint32_t length_name;
00102       arrToVar(length_name, (inbuffer + offset));
00103       offset += 4;
00104       for(unsigned int k= offset; k< offset+length_name; ++k){
00105           inbuffer[k-1]=inbuffer[k];
00106       }
00107       inbuffer[offset+length_name-1]=0;
00108       this->name = (char *)(inbuffer + offset-1);
00109       offset += length_name;
00110       uint32_t length_object_id;
00111       arrToVar(length_object_id, (inbuffer + offset));
00112       offset += 4;
00113       for(unsigned int k= offset; k< offset+length_object_id; ++k){
00114           inbuffer[k-1]=inbuffer[k];
00115       }
00116       inbuffer[offset+length_object_id-1]=0;
00117       this->object_id = (char *)(inbuffer + offset-1);
00118       offset += length_object_id;
00119       offset += this->pos.deserialize(inbuffer + offset);
00120       union {
00121         double real;
00122         uint64_t base;
00123       } u_reliability;
00124       u_reliability.base = 0;
00125       u_reliability.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00126       u_reliability.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00127       u_reliability.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00128       u_reliability.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00129       u_reliability.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00130       u_reliability.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00131       u_reliability.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00132       u_reliability.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00133       this->reliability = u_reliability.real;
00134       offset += sizeof(this->reliability);
00135       for( uint32_t i = 0; i < 9; i++){
00136       union {
00137         double real;
00138         uint64_t base;
00139       } u_covariancei;
00140       u_covariancei.base = 0;
00141       u_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00142       u_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00143       u_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00144       u_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00145       u_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00146       u_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00147       u_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00148       u_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00149       this->covariance[i] = u_covariancei.real;
00150       offset += sizeof(this->covariance[i]);
00151       }
00152       union {
00153         int8_t real;
00154         uint8_t base;
00155       } u_initialization;
00156       u_initialization.base = 0;
00157       u_initialization.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
00158       this->initialization = u_initialization.real;
00159       offset += sizeof(this->initialization);
00160      return offset;
00161     }
00162 
00163     virtual const char * getType(){ return "people_msgs/PositionMeasurement"; };
00164     virtual const char * getMD5(){ return "54fa938b4ec28728e01575b79eb0ec7c"; };
00165 
00166   };
00167 
00168 }
00169 #endif