hairo

Dependencies:   mbed BufferedSerial

Committer:
tknara
Date:
Tue Dec 04 00:14:32 2018 +0000
Revision:
4:bcdd99711326
Parent:
0:9e9b7db60fd5
test

Who changed what in which revision?

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