catchrobo2022 mbed LPC1768 メインプログラム
Dependencies: mbed
PositionMeasurementArray.h
00001 #ifndef _ROS_people_msgs_PositionMeasurementArray_h 00002 #define _ROS_people_msgs_PositionMeasurementArray_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 "people_msgs/PositionMeasurement.h" 00010 00011 namespace people_msgs 00012 { 00013 00014 class PositionMeasurementArray : public ros::Msg 00015 { 00016 public: 00017 typedef std_msgs::Header _header_type; 00018 _header_type header; 00019 uint32_t people_length; 00020 typedef people_msgs::PositionMeasurement _people_type; 00021 _people_type st_people; 00022 _people_type * people; 00023 uint32_t cooccurrence_length; 00024 typedef float _cooccurrence_type; 00025 _cooccurrence_type st_cooccurrence; 00026 _cooccurrence_type * cooccurrence; 00027 00028 PositionMeasurementArray(): 00029 header(), 00030 people_length(0), people(NULL), 00031 cooccurrence_length(0), cooccurrence(NULL) 00032 { 00033 } 00034 00035 virtual int serialize(unsigned char *outbuffer) const 00036 { 00037 int offset = 0; 00038 offset += this->header.serialize(outbuffer + offset); 00039 *(outbuffer + offset + 0) = (this->people_length >> (8 * 0)) & 0xFF; 00040 *(outbuffer + offset + 1) = (this->people_length >> (8 * 1)) & 0xFF; 00041 *(outbuffer + offset + 2) = (this->people_length >> (8 * 2)) & 0xFF; 00042 *(outbuffer + offset + 3) = (this->people_length >> (8 * 3)) & 0xFF; 00043 offset += sizeof(this->people_length); 00044 for( uint32_t i = 0; i < people_length; i++){ 00045 offset += this->people[i].serialize(outbuffer + offset); 00046 } 00047 *(outbuffer + offset + 0) = (this->cooccurrence_length >> (8 * 0)) & 0xFF; 00048 *(outbuffer + offset + 1) = (this->cooccurrence_length >> (8 * 1)) & 0xFF; 00049 *(outbuffer + offset + 2) = (this->cooccurrence_length >> (8 * 2)) & 0xFF; 00050 *(outbuffer + offset + 3) = (this->cooccurrence_length >> (8 * 3)) & 0xFF; 00051 offset += sizeof(this->cooccurrence_length); 00052 for( uint32_t i = 0; i < cooccurrence_length; i++){ 00053 union { 00054 float real; 00055 uint32_t base; 00056 } u_cooccurrencei; 00057 u_cooccurrencei.real = this->cooccurrence[i]; 00058 *(outbuffer + offset + 0) = (u_cooccurrencei.base >> (8 * 0)) & 0xFF; 00059 *(outbuffer + offset + 1) = (u_cooccurrencei.base >> (8 * 1)) & 0xFF; 00060 *(outbuffer + offset + 2) = (u_cooccurrencei.base >> (8 * 2)) & 0xFF; 00061 *(outbuffer + offset + 3) = (u_cooccurrencei.base >> (8 * 3)) & 0xFF; 00062 offset += sizeof(this->cooccurrence[i]); 00063 } 00064 return offset; 00065 } 00066 00067 virtual int deserialize(unsigned char *inbuffer) 00068 { 00069 int offset = 0; 00070 offset += this->header.deserialize(inbuffer + offset); 00071 uint32_t people_lengthT = ((uint32_t) (*(inbuffer + offset))); 00072 people_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00073 people_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00074 people_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00075 offset += sizeof(this->people_length); 00076 if(people_lengthT > people_length) 00077 this->people = (people_msgs::PositionMeasurement*)realloc(this->people, people_lengthT * sizeof(people_msgs::PositionMeasurement)); 00078 people_length = people_lengthT; 00079 for( uint32_t i = 0; i < people_length; i++){ 00080 offset += this->st_people.deserialize(inbuffer + offset); 00081 memcpy( &(this->people[i]), &(this->st_people), sizeof(people_msgs::PositionMeasurement)); 00082 } 00083 uint32_t cooccurrence_lengthT = ((uint32_t) (*(inbuffer + offset))); 00084 cooccurrence_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00085 cooccurrence_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00086 cooccurrence_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00087 offset += sizeof(this->cooccurrence_length); 00088 if(cooccurrence_lengthT > cooccurrence_length) 00089 this->cooccurrence = (float*)realloc(this->cooccurrence, cooccurrence_lengthT * sizeof(float)); 00090 cooccurrence_length = cooccurrence_lengthT; 00091 for( uint32_t i = 0; i < cooccurrence_length; i++){ 00092 union { 00093 float real; 00094 uint32_t base; 00095 } u_st_cooccurrence; 00096 u_st_cooccurrence.base = 0; 00097 u_st_cooccurrence.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00098 u_st_cooccurrence.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00099 u_st_cooccurrence.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00100 u_st_cooccurrence.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00101 this->st_cooccurrence = u_st_cooccurrence.real; 00102 offset += sizeof(this->st_cooccurrence); 00103 memcpy( &(this->cooccurrence[i]), &(this->st_cooccurrence), sizeof(float)); 00104 } 00105 return offset; 00106 } 00107 00108 virtual const char * getType(){ return "people_msgs/PositionMeasurementArray"; }; 00109 virtual const char * getMD5(){ return "59c860d40aa739ec920eb3ad24ae019e"; }; 00110 00111 }; 00112 00113 } 00114 #endif
Generated on Mon Sep 26 2022 13:47:03 by
1.7.2