catchrobo2022 mbed LPC1768 メインプログラム
Dependencies: mbed
ColorHistogram.h
00001 #ifndef _ROS_jsk_recognition_msgs_ColorHistogram_h 00002 #define _ROS_jsk_recognition_msgs_ColorHistogram_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 00010 namespace jsk_recognition_msgs 00011 { 00012 00013 class ColorHistogram : public ros::Msg 00014 { 00015 public: 00016 typedef std_msgs::Header _header_type; 00017 _header_type header; 00018 uint32_t histogram_length; 00019 typedef float _histogram_type; 00020 _histogram_type st_histogram; 00021 _histogram_type * histogram; 00022 00023 ColorHistogram(): 00024 header(), 00025 histogram_length(0), histogram(NULL) 00026 { 00027 } 00028 00029 virtual int serialize(unsigned char *outbuffer) const 00030 { 00031 int offset = 0; 00032 offset += this->header.serialize(outbuffer + offset); 00033 *(outbuffer + offset + 0) = (this->histogram_length >> (8 * 0)) & 0xFF; 00034 *(outbuffer + offset + 1) = (this->histogram_length >> (8 * 1)) & 0xFF; 00035 *(outbuffer + offset + 2) = (this->histogram_length >> (8 * 2)) & 0xFF; 00036 *(outbuffer + offset + 3) = (this->histogram_length >> (8 * 3)) & 0xFF; 00037 offset += sizeof(this->histogram_length); 00038 for( uint32_t i = 0; i < histogram_length; i++){ 00039 union { 00040 float real; 00041 uint32_t base; 00042 } u_histogrami; 00043 u_histogrami.real = this->histogram[i]; 00044 *(outbuffer + offset + 0) = (u_histogrami.base >> (8 * 0)) & 0xFF; 00045 *(outbuffer + offset + 1) = (u_histogrami.base >> (8 * 1)) & 0xFF; 00046 *(outbuffer + offset + 2) = (u_histogrami.base >> (8 * 2)) & 0xFF; 00047 *(outbuffer + offset + 3) = (u_histogrami.base >> (8 * 3)) & 0xFF; 00048 offset += sizeof(this->histogram[i]); 00049 } 00050 return offset; 00051 } 00052 00053 virtual int deserialize(unsigned char *inbuffer) 00054 { 00055 int offset = 0; 00056 offset += this->header.deserialize(inbuffer + offset); 00057 uint32_t histogram_lengthT = ((uint32_t) (*(inbuffer + offset))); 00058 histogram_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00059 histogram_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00060 histogram_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00061 offset += sizeof(this->histogram_length); 00062 if(histogram_lengthT > histogram_length) 00063 this->histogram = (float*)realloc(this->histogram, histogram_lengthT * sizeof(float)); 00064 histogram_length = histogram_lengthT; 00065 for( uint32_t i = 0; i < histogram_length; i++){ 00066 union { 00067 float real; 00068 uint32_t base; 00069 } u_st_histogram; 00070 u_st_histogram.base = 0; 00071 u_st_histogram.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00072 u_st_histogram.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00073 u_st_histogram.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00074 u_st_histogram.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00075 this->st_histogram = u_st_histogram.real; 00076 offset += sizeof(this->st_histogram); 00077 memcpy( &(this->histogram[i]), &(this->st_histogram), sizeof(float)); 00078 } 00079 return offset; 00080 } 00081 00082 virtual const char * getType(){ return "jsk_recognition_msgs/ColorHistogram"; }; 00083 virtual const char * getMD5(){ return "5b08641478fdecd8720ba08b36fce2aa"; }; 00084 00085 }; 00086 00087 } 00088 #endif
Generated on Mon Sep 26 2022 13:47:00 by
1.7.2