ROS Serial library for Mbed platforms for ROS Indigo Igloo. Check http://wiki.ros.org/rosserial_mbed/ for more information

Dependencies:   BufferedSerial

Dependents:   rosserial_mbed_hello_world_publisher rtos_base_control rosserial_mbed_F64MA ROS-RTOS ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GetPolledImage.h Source File

GetPolledImage.h

00001 #ifndef _ROS_SERVICE_GetPolledImage_h
00002 #define _ROS_SERVICE_GetPolledImage_h
00003 #include <stdint.h>
00004 #include <string.h>
00005 #include <stdlib.h>
00006 #include "ros/msg.h"
00007 #include "sensor_msgs/RegionOfInterest.h"
00008 #include "ros/duration.h"
00009 #include "ros/time.h"
00010 
00011 namespace polled_camera
00012 {
00013 
00014 static const char GETPOLLEDIMAGE[] = "polled_camera/GetPolledImage";
00015 
00016   class GetPolledImageRequest : public ros::Msg
00017   {
00018     public:
00019       const char* response_namespace;
00020       ros::Duration timeout;
00021       uint32_t binning_x;
00022       uint32_t binning_y;
00023       sensor_msgs::RegionOfInterest roi;
00024 
00025     GetPolledImageRequest():
00026       response_namespace(""),
00027       timeout(),
00028       binning_x(0),
00029       binning_y(0),
00030       roi()
00031     {
00032     }
00033 
00034     virtual int serialize(unsigned char *outbuffer) const
00035     {
00036       int offset = 0;
00037       uint32_t length_response_namespace = strlen(this->response_namespace);
00038       memcpy(outbuffer + offset, &length_response_namespace, sizeof(uint32_t));
00039       offset += 4;
00040       memcpy(outbuffer + offset, this->response_namespace, length_response_namespace);
00041       offset += length_response_namespace;
00042       *(outbuffer + offset + 0) = (this->timeout.sec >> (8 * 0)) & 0xFF;
00043       *(outbuffer + offset + 1) = (this->timeout.sec >> (8 * 1)) & 0xFF;
00044       *(outbuffer + offset + 2) = (this->timeout.sec >> (8 * 2)) & 0xFF;
00045       *(outbuffer + offset + 3) = (this->timeout.sec >> (8 * 3)) & 0xFF;
00046       offset += sizeof(this->timeout.sec);
00047       *(outbuffer + offset + 0) = (this->timeout.nsec >> (8 * 0)) & 0xFF;
00048       *(outbuffer + offset + 1) = (this->timeout.nsec >> (8 * 1)) & 0xFF;
00049       *(outbuffer + offset + 2) = (this->timeout.nsec >> (8 * 2)) & 0xFF;
00050       *(outbuffer + offset + 3) = (this->timeout.nsec >> (8 * 3)) & 0xFF;
00051       offset += sizeof(this->timeout.nsec);
00052       *(outbuffer + offset + 0) = (this->binning_x >> (8 * 0)) & 0xFF;
00053       *(outbuffer + offset + 1) = (this->binning_x >> (8 * 1)) & 0xFF;
00054       *(outbuffer + offset + 2) = (this->binning_x >> (8 * 2)) & 0xFF;
00055       *(outbuffer + offset + 3) = (this->binning_x >> (8 * 3)) & 0xFF;
00056       offset += sizeof(this->binning_x);
00057       *(outbuffer + offset + 0) = (this->binning_y >> (8 * 0)) & 0xFF;
00058       *(outbuffer + offset + 1) = (this->binning_y >> (8 * 1)) & 0xFF;
00059       *(outbuffer + offset + 2) = (this->binning_y >> (8 * 2)) & 0xFF;
00060       *(outbuffer + offset + 3) = (this->binning_y >> (8 * 3)) & 0xFF;
00061       offset += sizeof(this->binning_y);
00062       offset += this->roi.serialize(outbuffer + offset);
00063       return offset;
00064     }
00065 
00066     virtual int deserialize(unsigned char *inbuffer)
00067     {
00068       int offset = 0;
00069       uint32_t length_response_namespace;
00070       memcpy(&length_response_namespace, (inbuffer + offset), sizeof(uint32_t));
00071       offset += 4;
00072       for(unsigned int k= offset; k< offset+length_response_namespace; ++k){
00073           inbuffer[k-1]=inbuffer[k];
00074       }
00075       inbuffer[offset+length_response_namespace-1]=0;
00076       this->response_namespace = (char *)(inbuffer + offset-1);
00077       offset += length_response_namespace;
00078       this->timeout.sec =  ((uint32_t) (*(inbuffer + offset)));
00079       this->timeout.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00080       this->timeout.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00081       this->timeout.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00082       offset += sizeof(this->timeout.sec);
00083       this->timeout.nsec =  ((uint32_t) (*(inbuffer + offset)));
00084       this->timeout.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00085       this->timeout.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00086       this->timeout.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00087       offset += sizeof(this->timeout.nsec);
00088       this->binning_x =  ((uint32_t) (*(inbuffer + offset)));
00089       this->binning_x |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00090       this->binning_x |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00091       this->binning_x |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00092       offset += sizeof(this->binning_x);
00093       this->binning_y =  ((uint32_t) (*(inbuffer + offset)));
00094       this->binning_y |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00095       this->binning_y |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00096       this->binning_y |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00097       offset += sizeof(this->binning_y);
00098       offset += this->roi.deserialize(inbuffer + offset);
00099      return offset;
00100     }
00101 
00102     const char * getType(){ return GETPOLLEDIMAGE; };
00103     const char * getMD5(){ return "c77ed43e530fd48e9e7a2a93845e154c"; };
00104 
00105   };
00106 
00107   class GetPolledImageResponse : public ros::Msg
00108   {
00109     public:
00110       bool success;
00111       const char* status_message;
00112       ros::Time stamp;
00113 
00114     GetPolledImageResponse():
00115       success(0),
00116       status_message(""),
00117       stamp()
00118     {
00119     }
00120 
00121     virtual int serialize(unsigned char *outbuffer) const
00122     {
00123       int offset = 0;
00124       union {
00125         bool real;
00126         uint8_t base;
00127       } u_success;
00128       u_success.real = this->success;
00129       *(outbuffer + offset + 0) = (u_success.base >> (8 * 0)) & 0xFF;
00130       offset += sizeof(this->success);
00131       uint32_t length_status_message = strlen(this->status_message);
00132       memcpy(outbuffer + offset, &length_status_message, sizeof(uint32_t));
00133       offset += 4;
00134       memcpy(outbuffer + offset, this->status_message, length_status_message);
00135       offset += length_status_message;
00136       *(outbuffer + offset + 0) = (this->stamp.sec >> (8 * 0)) & 0xFF;
00137       *(outbuffer + offset + 1) = (this->stamp.sec >> (8 * 1)) & 0xFF;
00138       *(outbuffer + offset + 2) = (this->stamp.sec >> (8 * 2)) & 0xFF;
00139       *(outbuffer + offset + 3) = (this->stamp.sec >> (8 * 3)) & 0xFF;
00140       offset += sizeof(this->stamp.sec);
00141       *(outbuffer + offset + 0) = (this->stamp.nsec >> (8 * 0)) & 0xFF;
00142       *(outbuffer + offset + 1) = (this->stamp.nsec >> (8 * 1)) & 0xFF;
00143       *(outbuffer + offset + 2) = (this->stamp.nsec >> (8 * 2)) & 0xFF;
00144       *(outbuffer + offset + 3) = (this->stamp.nsec >> (8 * 3)) & 0xFF;
00145       offset += sizeof(this->stamp.nsec);
00146       return offset;
00147     }
00148 
00149     virtual int deserialize(unsigned char *inbuffer)
00150     {
00151       int offset = 0;
00152       union {
00153         bool real;
00154         uint8_t base;
00155       } u_success;
00156       u_success.base = 0;
00157       u_success.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
00158       this->success = u_success.real;
00159       offset += sizeof(this->success);
00160       uint32_t length_status_message;
00161       memcpy(&length_status_message, (inbuffer + offset), sizeof(uint32_t));
00162       offset += 4;
00163       for(unsigned int k= offset; k< offset+length_status_message; ++k){
00164           inbuffer[k-1]=inbuffer[k];
00165       }
00166       inbuffer[offset+length_status_message-1]=0;
00167       this->status_message = (char *)(inbuffer + offset-1);
00168       offset += length_status_message;
00169       this->stamp.sec =  ((uint32_t) (*(inbuffer + offset)));
00170       this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00171       this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00172       this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00173       offset += sizeof(this->stamp.sec);
00174       this->stamp.nsec =  ((uint32_t) (*(inbuffer + offset)));
00175       this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00176       this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00177       this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00178       offset += sizeof(this->stamp.nsec);
00179      return offset;
00180     }
00181 
00182     const char * getType(){ return GETPOLLEDIMAGE; };
00183     const char * getMD5(){ return "dbf1f851bc511800e6129ccd5a3542ab"; };
00184 
00185   };
00186 
00187   class GetPolledImage {
00188     public:
00189     typedef GetPolledImageRequest Request;
00190     typedef GetPolledImageResponse Response;
00191   };
00192 
00193 }
00194 #endif