hairo
Dependencies: mbed BufferedSerial
sensor_msgs/Image.h@0:9e9b7db60fd5, 2016-12-31 (annotated)
- Committer:
- garyservin
- Date:
- Sat Dec 31 00:48:34 2016 +0000
- Revision:
- 0:9e9b7db60fd5
Initial commit, generated based on a clean kinetic-desktop-full
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
garyservin | 0:9e9b7db60fd5 | 1 | #ifndef _ROS_sensor_msgs_Image_h |
garyservin | 0:9e9b7db60fd5 | 2 | #define _ROS_sensor_msgs_Image_h |
garyservin | 0:9e9b7db60fd5 | 3 | |
garyservin | 0:9e9b7db60fd5 | 4 | #include <stdint.h> |
garyservin | 0:9e9b7db60fd5 | 5 | #include <string.h> |
garyservin | 0:9e9b7db60fd5 | 6 | #include <stdlib.h> |
garyservin | 0:9e9b7db60fd5 | 7 | #include "ros/msg.h" |
garyservin | 0:9e9b7db60fd5 | 8 | #include "std_msgs/Header.h" |
garyservin | 0:9e9b7db60fd5 | 9 | |
garyservin | 0:9e9b7db60fd5 | 10 | namespace sensor_msgs |
garyservin | 0:9e9b7db60fd5 | 11 | { |
garyservin | 0:9e9b7db60fd5 | 12 | |
garyservin | 0:9e9b7db60fd5 | 13 | class Image : public ros::Msg |
garyservin | 0:9e9b7db60fd5 | 14 | { |
garyservin | 0:9e9b7db60fd5 | 15 | public: |
garyservin | 0:9e9b7db60fd5 | 16 | typedef std_msgs::Header _header_type; |
garyservin | 0:9e9b7db60fd5 | 17 | _header_type header; |
garyservin | 0:9e9b7db60fd5 | 18 | typedef uint32_t _height_type; |
garyservin | 0:9e9b7db60fd5 | 19 | _height_type height; |
garyservin | 0:9e9b7db60fd5 | 20 | typedef uint32_t _width_type; |
garyservin | 0:9e9b7db60fd5 | 21 | _width_type width; |
garyservin | 0:9e9b7db60fd5 | 22 | typedef const char* _encoding_type; |
garyservin | 0:9e9b7db60fd5 | 23 | _encoding_type encoding; |
garyservin | 0:9e9b7db60fd5 | 24 | typedef uint8_t _is_bigendian_type; |
garyservin | 0:9e9b7db60fd5 | 25 | _is_bigendian_type is_bigendian; |
garyservin | 0:9e9b7db60fd5 | 26 | typedef uint32_t _step_type; |
garyservin | 0:9e9b7db60fd5 | 27 | _step_type step; |
garyservin | 0:9e9b7db60fd5 | 28 | uint32_t data_length; |
garyservin | 0:9e9b7db60fd5 | 29 | typedef uint8_t _data_type; |
garyservin | 0:9e9b7db60fd5 | 30 | _data_type st_data; |
garyservin | 0:9e9b7db60fd5 | 31 | _data_type * data; |
garyservin | 0:9e9b7db60fd5 | 32 | |
garyservin | 0:9e9b7db60fd5 | 33 | Image(): |
garyservin | 0:9e9b7db60fd5 | 34 | header(), |
garyservin | 0:9e9b7db60fd5 | 35 | height(0), |
garyservin | 0:9e9b7db60fd5 | 36 | width(0), |
garyservin | 0:9e9b7db60fd5 | 37 | encoding(""), |
garyservin | 0:9e9b7db60fd5 | 38 | is_bigendian(0), |
garyservin | 0:9e9b7db60fd5 | 39 | step(0), |
garyservin | 0:9e9b7db60fd5 | 40 | data_length(0), data(NULL) |
garyservin | 0:9e9b7db60fd5 | 41 | { |
garyservin | 0:9e9b7db60fd5 | 42 | } |
garyservin | 0:9e9b7db60fd5 | 43 | |
garyservin | 0:9e9b7db60fd5 | 44 | virtual int serialize(unsigned char *outbuffer) const |
garyservin | 0:9e9b7db60fd5 | 45 | { |
garyservin | 0:9e9b7db60fd5 | 46 | int offset = 0; |
garyservin | 0:9e9b7db60fd5 | 47 | offset += this->header.serialize(outbuffer + offset); |
garyservin | 0:9e9b7db60fd5 | 48 | *(outbuffer + offset + 0) = (this->height >> (8 * 0)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 49 | *(outbuffer + offset + 1) = (this->height >> (8 * 1)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 50 | *(outbuffer + offset + 2) = (this->height >> (8 * 2)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 51 | *(outbuffer + offset + 3) = (this->height >> (8 * 3)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 52 | offset += sizeof(this->height); |
garyservin | 0:9e9b7db60fd5 | 53 | *(outbuffer + offset + 0) = (this->width >> (8 * 0)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 54 | *(outbuffer + offset + 1) = (this->width >> (8 * 1)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 55 | *(outbuffer + offset + 2) = (this->width >> (8 * 2)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 56 | *(outbuffer + offset + 3) = (this->width >> (8 * 3)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 57 | offset += sizeof(this->width); |
garyservin | 0:9e9b7db60fd5 | 58 | uint32_t length_encoding = strlen(this->encoding); |
garyservin | 0:9e9b7db60fd5 | 59 | varToArr(outbuffer + offset, length_encoding); |
garyservin | 0:9e9b7db60fd5 | 60 | offset += 4; |
garyservin | 0:9e9b7db60fd5 | 61 | memcpy(outbuffer + offset, this->encoding, length_encoding); |
garyservin | 0:9e9b7db60fd5 | 62 | offset += length_encoding; |
garyservin | 0:9e9b7db60fd5 | 63 | *(outbuffer + offset + 0) = (this->is_bigendian >> (8 * 0)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 64 | offset += sizeof(this->is_bigendian); |
garyservin | 0:9e9b7db60fd5 | 65 | *(outbuffer + offset + 0) = (this->step >> (8 * 0)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 66 | *(outbuffer + offset + 1) = (this->step >> (8 * 1)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 67 | *(outbuffer + offset + 2) = (this->step >> (8 * 2)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 68 | *(outbuffer + offset + 3) = (this->step >> (8 * 3)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 69 | offset += sizeof(this->step); |
garyservin | 0:9e9b7db60fd5 | 70 | *(outbuffer + offset + 0) = (this->data_length >> (8 * 0)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 71 | *(outbuffer + offset + 1) = (this->data_length >> (8 * 1)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 72 | *(outbuffer + offset + 2) = (this->data_length >> (8 * 2)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 73 | *(outbuffer + offset + 3) = (this->data_length >> (8 * 3)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 74 | offset += sizeof(this->data_length); |
garyservin | 0:9e9b7db60fd5 | 75 | for( uint32_t i = 0; i < data_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 76 | *(outbuffer + offset + 0) = (this->data[i] >> (8 * 0)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 77 | offset += sizeof(this->data[i]); |
garyservin | 0:9e9b7db60fd5 | 78 | } |
garyservin | 0:9e9b7db60fd5 | 79 | return offset; |
garyservin | 0:9e9b7db60fd5 | 80 | } |
garyservin | 0:9e9b7db60fd5 | 81 | |
garyservin | 0:9e9b7db60fd5 | 82 | virtual int deserialize(unsigned char *inbuffer) |
garyservin | 0:9e9b7db60fd5 | 83 | { |
garyservin | 0:9e9b7db60fd5 | 84 | int offset = 0; |
garyservin | 0:9e9b7db60fd5 | 85 | offset += this->header.deserialize(inbuffer + offset); |
garyservin | 0:9e9b7db60fd5 | 86 | this->height = ((uint32_t) (*(inbuffer + offset))); |
garyservin | 0:9e9b7db60fd5 | 87 | this->height |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:9e9b7db60fd5 | 88 | this->height |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:9e9b7db60fd5 | 89 | this->height |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:9e9b7db60fd5 | 90 | offset += sizeof(this->height); |
garyservin | 0:9e9b7db60fd5 | 91 | this->width = ((uint32_t) (*(inbuffer + offset))); |
garyservin | 0:9e9b7db60fd5 | 92 | this->width |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:9e9b7db60fd5 | 93 | this->width |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:9e9b7db60fd5 | 94 | this->width |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:9e9b7db60fd5 | 95 | offset += sizeof(this->width); |
garyservin | 0:9e9b7db60fd5 | 96 | uint32_t length_encoding; |
garyservin | 0:9e9b7db60fd5 | 97 | arrToVar(length_encoding, (inbuffer + offset)); |
garyservin | 0:9e9b7db60fd5 | 98 | offset += 4; |
garyservin | 0:9e9b7db60fd5 | 99 | for(unsigned int k= offset; k< offset+length_encoding; ++k){ |
garyservin | 0:9e9b7db60fd5 | 100 | inbuffer[k-1]=inbuffer[k]; |
garyservin | 0:9e9b7db60fd5 | 101 | } |
garyservin | 0:9e9b7db60fd5 | 102 | inbuffer[offset+length_encoding-1]=0; |
garyservin | 0:9e9b7db60fd5 | 103 | this->encoding = (char *)(inbuffer + offset-1); |
garyservin | 0:9e9b7db60fd5 | 104 | offset += length_encoding; |
garyservin | 0:9e9b7db60fd5 | 105 | this->is_bigendian = ((uint8_t) (*(inbuffer + offset))); |
garyservin | 0:9e9b7db60fd5 | 106 | offset += sizeof(this->is_bigendian); |
garyservin | 0:9e9b7db60fd5 | 107 | this->step = ((uint32_t) (*(inbuffer + offset))); |
garyservin | 0:9e9b7db60fd5 | 108 | this->step |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:9e9b7db60fd5 | 109 | this->step |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:9e9b7db60fd5 | 110 | this->step |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:9e9b7db60fd5 | 111 | offset += sizeof(this->step); |
garyservin | 0:9e9b7db60fd5 | 112 | uint32_t data_lengthT = ((uint32_t) (*(inbuffer + offset))); |
garyservin | 0:9e9b7db60fd5 | 113 | data_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:9e9b7db60fd5 | 114 | data_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:9e9b7db60fd5 | 115 | data_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:9e9b7db60fd5 | 116 | offset += sizeof(this->data_length); |
garyservin | 0:9e9b7db60fd5 | 117 | if(data_lengthT > data_length) |
garyservin | 0:9e9b7db60fd5 | 118 | this->data = (uint8_t*)realloc(this->data, data_lengthT * sizeof(uint8_t)); |
garyservin | 0:9e9b7db60fd5 | 119 | data_length = data_lengthT; |
garyservin | 0:9e9b7db60fd5 | 120 | for( uint32_t i = 0; i < data_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 121 | this->st_data = ((uint8_t) (*(inbuffer + offset))); |
garyservin | 0:9e9b7db60fd5 | 122 | offset += sizeof(this->st_data); |
garyservin | 0:9e9b7db60fd5 | 123 | memcpy( &(this->data[i]), &(this->st_data), sizeof(uint8_t)); |
garyservin | 0:9e9b7db60fd5 | 124 | } |
garyservin | 0:9e9b7db60fd5 | 125 | return offset; |
garyservin | 0:9e9b7db60fd5 | 126 | } |
garyservin | 0:9e9b7db60fd5 | 127 | |
garyservin | 0:9e9b7db60fd5 | 128 | const char * getType(){ return "sensor_msgs/Image"; }; |
garyservin | 0:9e9b7db60fd5 | 129 | const char * getMD5(){ return "060021388200f6f0f447d0fcd9c64743"; }; |
garyservin | 0:9e9b7db60fd5 | 130 | |
garyservin | 0:9e9b7db60fd5 | 131 | }; |
garyservin | 0:9e9b7db60fd5 | 132 | |
garyservin | 0:9e9b7db60fd5 | 133 | } |
garyservin | 0:9e9b7db60fd5 | 134 | #endif |