Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BufferedSerial motor_sn7544
Image.h
00001 #ifndef _ROS_sensor_msgs_Image_h 00002 #define _ROS_sensor_msgs_Image_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 <vector> 00010 00011 namespace sensor_msgs 00012 { 00013 00014 class Image : public ros::Msg 00015 { 00016 public: 00017 typedef std_msgs::Header _header_type; 00018 _header_type header; 00019 typedef uint32_t _height_type; 00020 _height_type height; 00021 typedef uint32_t _width_type; 00022 _width_type width; 00023 typedef const char* _encoding_type; 00024 _encoding_type encoding; 00025 typedef uint8_t _is_bigendian_type; 00026 _is_bigendian_type is_bigendian; 00027 typedef uint32_t _step_type; 00028 _step_type step; 00029 uint32_t data_length; 00030 typedef uint8_t _data_type; 00031 _data_type st_data; 00032 _data_type * data; 00033 00034 Image(): 00035 header(), 00036 height(0), 00037 width(0), 00038 encoding(""), 00039 is_bigendian(0), 00040 step(0), 00041 data_length(0), data(NULL) 00042 { 00043 } 00044 00045 virtual int serialize(unsigned char *outbuffer) const 00046 { 00047 int offset = 0; 00048 offset += this->header.serialize(outbuffer + offset); 00049 *(outbuffer + offset + 0) = (this->height >> (8 * 0)) & 0xFF; 00050 *(outbuffer + offset + 1) = (this->height >> (8 * 1)) & 0xFF; 00051 *(outbuffer + offset + 2) = (this->height >> (8 * 2)) & 0xFF; 00052 *(outbuffer + offset + 3) = (this->height >> (8 * 3)) & 0xFF; 00053 offset += sizeof(this->height); 00054 *(outbuffer + offset + 0) = (this->width >> (8 * 0)) & 0xFF; 00055 *(outbuffer + offset + 1) = (this->width >> (8 * 1)) & 0xFF; 00056 *(outbuffer + offset + 2) = (this->width >> (8 * 2)) & 0xFF; 00057 *(outbuffer + offset + 3) = (this->width >> (8 * 3)) & 0xFF; 00058 offset += sizeof(this->width); 00059 uint32_t length_encoding = strlen(this->encoding); 00060 varToArr(outbuffer + offset, length_encoding); 00061 offset += 4; 00062 memcpy(outbuffer + offset, this->encoding, length_encoding); 00063 offset += length_encoding; 00064 *(outbuffer + offset + 0) = (this->is_bigendian >> (8 * 0)) & 0xFF; 00065 offset += sizeof(this->is_bigendian); 00066 *(outbuffer + offset + 0) = (this->step >> (8 * 0)) & 0xFF; 00067 *(outbuffer + offset + 1) = (this->step >> (8 * 1)) & 0xFF; 00068 *(outbuffer + offset + 2) = (this->step >> (8 * 2)) & 0xFF; 00069 *(outbuffer + offset + 3) = (this->step >> (8 * 3)) & 0xFF; 00070 offset += sizeof(this->step); 00071 *(outbuffer + offset + 0) = (this->data_length >> (8 * 0)) & 0xFF; 00072 *(outbuffer + offset + 1) = (this->data_length >> (8 * 1)) & 0xFF; 00073 *(outbuffer + offset + 2) = (this->data_length >> (8 * 2)) & 0xFF; 00074 *(outbuffer + offset + 3) = (this->data_length >> (8 * 3)) & 0xFF; 00075 offset += sizeof(this->data_length); 00076 for( uint32_t i = 0; i < data_length; i++){ 00077 *(outbuffer + offset + 0) = (this->data[i] >> (8 * 0)) & 0xFF; 00078 offset += sizeof(this->data[i]); 00079 } 00080 return offset; 00081 } 00082 00083 virtual int deserialize(unsigned char *inbuffer) 00084 { 00085 int offset = 0; 00086 offset += this->header.deserialize(inbuffer + offset); 00087 this->height = ((uint32_t) (*(inbuffer + offset))); 00088 this->height |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00089 this->height |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00090 this->height |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00091 offset += sizeof(this->height); 00092 this->width = ((uint32_t) (*(inbuffer + offset))); 00093 this->width |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00094 this->width |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00095 this->width |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00096 offset += sizeof(this->width); 00097 uint32_t length_encoding; 00098 arrToVar(length_encoding, (inbuffer + offset)); 00099 offset += 4; 00100 for(unsigned int k= offset; k< offset+length_encoding; ++k){ 00101 inbuffer[k-1]=inbuffer[k]; 00102 } 00103 inbuffer[offset+length_encoding-1]=0; 00104 this->encoding = (char *)(inbuffer + offset-1); 00105 offset += length_encoding; 00106 this->is_bigendian = ((uint8_t) (*(inbuffer + offset))); 00107 offset += sizeof(this->is_bigendian); 00108 this->step = ((uint32_t) (*(inbuffer + offset))); 00109 this->step |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00110 this->step |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00111 this->step |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00112 offset += sizeof(this->step); 00113 uint32_t data_lengthT = ((uint32_t) (*(inbuffer + offset))); 00114 data_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00115 data_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00116 data_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00117 offset += sizeof(this->data_length); 00118 if(data_lengthT > data_length) 00119 this->data = (uint8_t*)realloc(this->data, data_lengthT * sizeof(uint8_t)); 00120 data_length = data_lengthT; 00121 for( uint32_t i = 0; i < data_length; i++){ 00122 this->st_data = ((uint8_t) (*(inbuffer + offset))); 00123 offset += sizeof(this->st_data); 00124 memcpy( &(this->data[i]), &(this->st_data), sizeof(uint8_t)); 00125 } 00126 return offset; 00127 } 00128 00129 const char * getType(){ return "sensor_msgs/Image"; }; 00130 const char * getMD5(){ return "060021388200f6f0f447d0fcd9c64743"; }; 00131 00132 }; 00133 00134 } 00135 #endif
Generated on Wed Jul 13 2022 07:13:54 by
