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