Just changed OUTPUT_SIZE and INPUT_SIZE in ros/node_handle.h
Dependents: WRS2020_mecanum_node
polled_camera/GetPolledImage.h@2:5d429be7d0aa, 2020-11-02 (annotated)
- Committer:
- sgrsn
- Date:
- Mon Nov 02 09:00:01 2020 +0000
- Revision:
- 2:5d429be7d0aa
- Parent:
- 0:04ac6be8229a
Change INPUT_SIZE and OUTPUT_SIZE on node_handle.h to pub sub
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Gary Servin |
0:04ac6be8229a | 1 | #ifndef _ROS_SERVICE_GetPolledImage_h |
Gary Servin |
0:04ac6be8229a | 2 | #define _ROS_SERVICE_GetPolledImage_h |
Gary Servin |
0:04ac6be8229a | 3 | #include <stdint.h> |
Gary Servin |
0:04ac6be8229a | 4 | #include <string.h> |
Gary Servin |
0:04ac6be8229a | 5 | #include <stdlib.h> |
Gary Servin |
0:04ac6be8229a | 6 | #include "ros/msg.h" |
Gary Servin |
0:04ac6be8229a | 7 | #include "sensor_msgs/RegionOfInterest.h" |
Gary Servin |
0:04ac6be8229a | 8 | #include "ros/duration.h" |
Gary Servin |
0:04ac6be8229a | 9 | #include "ros/time.h" |
Gary Servin |
0:04ac6be8229a | 10 | |
Gary Servin |
0:04ac6be8229a | 11 | namespace polled_camera |
Gary Servin |
0:04ac6be8229a | 12 | { |
Gary Servin |
0:04ac6be8229a | 13 | |
Gary Servin |
0:04ac6be8229a | 14 | static const char GETPOLLEDIMAGE[] = "polled_camera/GetPolledImage"; |
Gary Servin |
0:04ac6be8229a | 15 | |
Gary Servin |
0:04ac6be8229a | 16 | class GetPolledImageRequest : public ros::Msg |
Gary Servin |
0:04ac6be8229a | 17 | { |
Gary Servin |
0:04ac6be8229a | 18 | public: |
Gary Servin |
0:04ac6be8229a | 19 | typedef const char* _response_namespace_type; |
Gary Servin |
0:04ac6be8229a | 20 | _response_namespace_type response_namespace; |
Gary Servin |
0:04ac6be8229a | 21 | typedef ros::Duration _timeout_type; |
Gary Servin |
0:04ac6be8229a | 22 | _timeout_type timeout; |
Gary Servin |
0:04ac6be8229a | 23 | typedef uint32_t _binning_x_type; |
Gary Servin |
0:04ac6be8229a | 24 | _binning_x_type binning_x; |
Gary Servin |
0:04ac6be8229a | 25 | typedef uint32_t _binning_y_type; |
Gary Servin |
0:04ac6be8229a | 26 | _binning_y_type binning_y; |
Gary Servin |
0:04ac6be8229a | 27 | typedef sensor_msgs::RegionOfInterest _roi_type; |
Gary Servin |
0:04ac6be8229a | 28 | _roi_type roi; |
Gary Servin |
0:04ac6be8229a | 29 | |
Gary Servin |
0:04ac6be8229a | 30 | GetPolledImageRequest(): |
Gary Servin |
0:04ac6be8229a | 31 | response_namespace(""), |
Gary Servin |
0:04ac6be8229a | 32 | timeout(), |
Gary Servin |
0:04ac6be8229a | 33 | binning_x(0), |
Gary Servin |
0:04ac6be8229a | 34 | binning_y(0), |
Gary Servin |
0:04ac6be8229a | 35 | roi() |
Gary Servin |
0:04ac6be8229a | 36 | { |
Gary Servin |
0:04ac6be8229a | 37 | } |
Gary Servin |
0:04ac6be8229a | 38 | |
Gary Servin |
0:04ac6be8229a | 39 | virtual int serialize(unsigned char *outbuffer) const |
Gary Servin |
0:04ac6be8229a | 40 | { |
Gary Servin |
0:04ac6be8229a | 41 | int offset = 0; |
Gary Servin |
0:04ac6be8229a | 42 | uint32_t length_response_namespace = strlen(this->response_namespace); |
Gary Servin |
0:04ac6be8229a | 43 | varToArr(outbuffer + offset, length_response_namespace); |
Gary Servin |
0:04ac6be8229a | 44 | offset += 4; |
Gary Servin |
0:04ac6be8229a | 45 | memcpy(outbuffer + offset, this->response_namespace, length_response_namespace); |
Gary Servin |
0:04ac6be8229a | 46 | offset += length_response_namespace; |
Gary Servin |
0:04ac6be8229a | 47 | *(outbuffer + offset + 0) = (this->timeout.sec >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 48 | *(outbuffer + offset + 1) = (this->timeout.sec >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 49 | *(outbuffer + offset + 2) = (this->timeout.sec >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 50 | *(outbuffer + offset + 3) = (this->timeout.sec >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 51 | offset += sizeof(this->timeout.sec); |
Gary Servin |
0:04ac6be8229a | 52 | *(outbuffer + offset + 0) = (this->timeout.nsec >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 53 | *(outbuffer + offset + 1) = (this->timeout.nsec >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 54 | *(outbuffer + offset + 2) = (this->timeout.nsec >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 55 | *(outbuffer + offset + 3) = (this->timeout.nsec >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 56 | offset += sizeof(this->timeout.nsec); |
Gary Servin |
0:04ac6be8229a | 57 | *(outbuffer + offset + 0) = (this->binning_x >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 58 | *(outbuffer + offset + 1) = (this->binning_x >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 59 | *(outbuffer + offset + 2) = (this->binning_x >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 60 | *(outbuffer + offset + 3) = (this->binning_x >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 61 | offset += sizeof(this->binning_x); |
Gary Servin |
0:04ac6be8229a | 62 | *(outbuffer + offset + 0) = (this->binning_y >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 63 | *(outbuffer + offset + 1) = (this->binning_y >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 64 | *(outbuffer + offset + 2) = (this->binning_y >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 65 | *(outbuffer + offset + 3) = (this->binning_y >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 66 | offset += sizeof(this->binning_y); |
Gary Servin |
0:04ac6be8229a | 67 | offset += this->roi.serialize(outbuffer + offset); |
Gary Servin |
0:04ac6be8229a | 68 | return offset; |
Gary Servin |
0:04ac6be8229a | 69 | } |
Gary Servin |
0:04ac6be8229a | 70 | |
Gary Servin |
0:04ac6be8229a | 71 | virtual int deserialize(unsigned char *inbuffer) |
Gary Servin |
0:04ac6be8229a | 72 | { |
Gary Servin |
0:04ac6be8229a | 73 | int offset = 0; |
Gary Servin |
0:04ac6be8229a | 74 | uint32_t length_response_namespace; |
Gary Servin |
0:04ac6be8229a | 75 | arrToVar(length_response_namespace, (inbuffer + offset)); |
Gary Servin |
0:04ac6be8229a | 76 | offset += 4; |
Gary Servin |
0:04ac6be8229a | 77 | for(unsigned int k= offset; k< offset+length_response_namespace; ++k){ |
Gary Servin |
0:04ac6be8229a | 78 | inbuffer[k-1]=inbuffer[k]; |
Gary Servin |
0:04ac6be8229a | 79 | } |
Gary Servin |
0:04ac6be8229a | 80 | inbuffer[offset+length_response_namespace-1]=0; |
Gary Servin |
0:04ac6be8229a | 81 | this->response_namespace = (char *)(inbuffer + offset-1); |
Gary Servin |
0:04ac6be8229a | 82 | offset += length_response_namespace; |
Gary Servin |
0:04ac6be8229a | 83 | this->timeout.sec = ((uint32_t) (*(inbuffer + offset))); |
Gary Servin |
0:04ac6be8229a | 84 | this->timeout.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 85 | this->timeout.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 86 | this->timeout.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 87 | offset += sizeof(this->timeout.sec); |
Gary Servin |
0:04ac6be8229a | 88 | this->timeout.nsec = ((uint32_t) (*(inbuffer + offset))); |
Gary Servin |
0:04ac6be8229a | 89 | this->timeout.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 90 | this->timeout.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 91 | this->timeout.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 92 | offset += sizeof(this->timeout.nsec); |
Gary Servin |
0:04ac6be8229a | 93 | this->binning_x = ((uint32_t) (*(inbuffer + offset))); |
Gary Servin |
0:04ac6be8229a | 94 | this->binning_x |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 95 | this->binning_x |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 96 | this->binning_x |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 97 | offset += sizeof(this->binning_x); |
Gary Servin |
0:04ac6be8229a | 98 | this->binning_y = ((uint32_t) (*(inbuffer + offset))); |
Gary Servin |
0:04ac6be8229a | 99 | this->binning_y |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 100 | this->binning_y |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 101 | this->binning_y |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 102 | offset += sizeof(this->binning_y); |
Gary Servin |
0:04ac6be8229a | 103 | offset += this->roi.deserialize(inbuffer + offset); |
Gary Servin |
0:04ac6be8229a | 104 | return offset; |
Gary Servin |
0:04ac6be8229a | 105 | } |
Gary Servin |
0:04ac6be8229a | 106 | |
Gary Servin |
0:04ac6be8229a | 107 | const char * getType(){ return GETPOLLEDIMAGE; }; |
Gary Servin |
0:04ac6be8229a | 108 | const char * getMD5(){ return "c77ed43e530fd48e9e7a2a93845e154c"; }; |
Gary Servin |
0:04ac6be8229a | 109 | |
Gary Servin |
0:04ac6be8229a | 110 | }; |
Gary Servin |
0:04ac6be8229a | 111 | |
Gary Servin |
0:04ac6be8229a | 112 | class GetPolledImageResponse : public ros::Msg |
Gary Servin |
0:04ac6be8229a | 113 | { |
Gary Servin |
0:04ac6be8229a | 114 | public: |
Gary Servin |
0:04ac6be8229a | 115 | typedef bool _success_type; |
Gary Servin |
0:04ac6be8229a | 116 | _success_type success; |
Gary Servin |
0:04ac6be8229a | 117 | typedef const char* _status_message_type; |
Gary Servin |
0:04ac6be8229a | 118 | _status_message_type status_message; |
Gary Servin |
0:04ac6be8229a | 119 | typedef ros::Time _stamp_type; |
Gary Servin |
0:04ac6be8229a | 120 | _stamp_type stamp; |
Gary Servin |
0:04ac6be8229a | 121 | |
Gary Servin |
0:04ac6be8229a | 122 | GetPolledImageResponse(): |
Gary Servin |
0:04ac6be8229a | 123 | success(0), |
Gary Servin |
0:04ac6be8229a | 124 | status_message(""), |
Gary Servin |
0:04ac6be8229a | 125 | stamp() |
Gary Servin |
0:04ac6be8229a | 126 | { |
Gary Servin |
0:04ac6be8229a | 127 | } |
Gary Servin |
0:04ac6be8229a | 128 | |
Gary Servin |
0:04ac6be8229a | 129 | virtual int serialize(unsigned char *outbuffer) const |
Gary Servin |
0:04ac6be8229a | 130 | { |
Gary Servin |
0:04ac6be8229a | 131 | int offset = 0; |
Gary Servin |
0:04ac6be8229a | 132 | union { |
Gary Servin |
0:04ac6be8229a | 133 | bool real; |
Gary Servin |
0:04ac6be8229a | 134 | uint8_t base; |
Gary Servin |
0:04ac6be8229a | 135 | } u_success; |
Gary Servin |
0:04ac6be8229a | 136 | u_success.real = this->success; |
Gary Servin |
0:04ac6be8229a | 137 | *(outbuffer + offset + 0) = (u_success.base >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 138 | offset += sizeof(this->success); |
Gary Servin |
0:04ac6be8229a | 139 | uint32_t length_status_message = strlen(this->status_message); |
Gary Servin |
0:04ac6be8229a | 140 | varToArr(outbuffer + offset, length_status_message); |
Gary Servin |
0:04ac6be8229a | 141 | offset += 4; |
Gary Servin |
0:04ac6be8229a | 142 | memcpy(outbuffer + offset, this->status_message, length_status_message); |
Gary Servin |
0:04ac6be8229a | 143 | offset += length_status_message; |
Gary Servin |
0:04ac6be8229a | 144 | *(outbuffer + offset + 0) = (this->stamp.sec >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 145 | *(outbuffer + offset + 1) = (this->stamp.sec >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 146 | *(outbuffer + offset + 2) = (this->stamp.sec >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 147 | *(outbuffer + offset + 3) = (this->stamp.sec >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 148 | offset += sizeof(this->stamp.sec); |
Gary Servin |
0:04ac6be8229a | 149 | *(outbuffer + offset + 0) = (this->stamp.nsec >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 150 | *(outbuffer + offset + 1) = (this->stamp.nsec >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 151 | *(outbuffer + offset + 2) = (this->stamp.nsec >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 152 | *(outbuffer + offset + 3) = (this->stamp.nsec >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 153 | offset += sizeof(this->stamp.nsec); |
Gary Servin |
0:04ac6be8229a | 154 | return offset; |
Gary Servin |
0:04ac6be8229a | 155 | } |
Gary Servin |
0:04ac6be8229a | 156 | |
Gary Servin |
0:04ac6be8229a | 157 | virtual int deserialize(unsigned char *inbuffer) |
Gary Servin |
0:04ac6be8229a | 158 | { |
Gary Servin |
0:04ac6be8229a | 159 | int offset = 0; |
Gary Servin |
0:04ac6be8229a | 160 | union { |
Gary Servin |
0:04ac6be8229a | 161 | bool real; |
Gary Servin |
0:04ac6be8229a | 162 | uint8_t base; |
Gary Servin |
0:04ac6be8229a | 163 | } u_success; |
Gary Servin |
0:04ac6be8229a | 164 | u_success.base = 0; |
Gary Servin |
0:04ac6be8229a | 165 | u_success.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); |
Gary Servin |
0:04ac6be8229a | 166 | this->success = u_success.real; |
Gary Servin |
0:04ac6be8229a | 167 | offset += sizeof(this->success); |
Gary Servin |
0:04ac6be8229a | 168 | uint32_t length_status_message; |
Gary Servin |
0:04ac6be8229a | 169 | arrToVar(length_status_message, (inbuffer + offset)); |
Gary Servin |
0:04ac6be8229a | 170 | offset += 4; |
Gary Servin |
0:04ac6be8229a | 171 | for(unsigned int k= offset; k< offset+length_status_message; ++k){ |
Gary Servin |
0:04ac6be8229a | 172 | inbuffer[k-1]=inbuffer[k]; |
Gary Servin |
0:04ac6be8229a | 173 | } |
Gary Servin |
0:04ac6be8229a | 174 | inbuffer[offset+length_status_message-1]=0; |
Gary Servin |
0:04ac6be8229a | 175 | this->status_message = (char *)(inbuffer + offset-1); |
Gary Servin |
0:04ac6be8229a | 176 | offset += length_status_message; |
Gary Servin |
0:04ac6be8229a | 177 | this->stamp.sec = ((uint32_t) (*(inbuffer + offset))); |
Gary Servin |
0:04ac6be8229a | 178 | this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 179 | this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 180 | this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 181 | offset += sizeof(this->stamp.sec); |
Gary Servin |
0:04ac6be8229a | 182 | this->stamp.nsec = ((uint32_t) (*(inbuffer + offset))); |
Gary Servin |
0:04ac6be8229a | 183 | this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 184 | this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 185 | this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 186 | offset += sizeof(this->stamp.nsec); |
Gary Servin |
0:04ac6be8229a | 187 | return offset; |
Gary Servin |
0:04ac6be8229a | 188 | } |
Gary Servin |
0:04ac6be8229a | 189 | |
Gary Servin |
0:04ac6be8229a | 190 | const char * getType(){ return GETPOLLEDIMAGE; }; |
Gary Servin |
0:04ac6be8229a | 191 | const char * getMD5(){ return "dbf1f851bc511800e6129ccd5a3542ab"; }; |
Gary Servin |
0:04ac6be8229a | 192 | |
Gary Servin |
0:04ac6be8229a | 193 | }; |
Gary Servin |
0:04ac6be8229a | 194 | |
Gary Servin |
0:04ac6be8229a | 195 | class GetPolledImage { |
Gary Servin |
0:04ac6be8229a | 196 | public: |
Gary Servin |
0:04ac6be8229a | 197 | typedef GetPolledImageRequest Request; |
Gary Servin |
0:04ac6be8229a | 198 | typedef GetPolledImageResponse Response; |
Gary Servin |
0:04ac6be8229a | 199 | }; |
Gary Servin |
0:04ac6be8229a | 200 | |
Gary Servin |
0:04ac6be8229a | 201 | } |
Gary Servin |
0:04ac6be8229a | 202 | #endif |