Spawn.h
Go to the documentation of this file.
00001 #ifndef _ROS_SERVICE_Spawn_h
00002 #define _ROS_SERVICE_Spawn_h
00003 #include <stdint.h>
00004 #include <string.h>
00005 #include <stdlib.h>
00006 #include "ros/msg.h"
00007 
00008 namespace turtlesim
00009 {
00010 
00011 static const char SPAWN[] = "turtlesim/Spawn";
00012 
00013   class SpawnRequest : public ros::Msg
00014   {
00015     public:
00016       float x;
00017       float y;
00018       float theta;
00019       char * name;
00020 
00021     virtual int serialize(unsigned char *outbuffer) const
00022     {
00023       int offset = 0;
00024       union {
00025         float real;
00026         uint32_t base;
00027       } u_x;
00028       u_x.real = this->x;
00029       *(outbuffer + offset + 0) = (u_x.base >> (8 * 0)) & 0xFF;
00030       *(outbuffer + offset + 1) = (u_x.base >> (8 * 1)) & 0xFF;
00031       *(outbuffer + offset + 2) = (u_x.base >> (8 * 2)) & 0xFF;
00032       *(outbuffer + offset + 3) = (u_x.base >> (8 * 3)) & 0xFF;
00033       offset += sizeof(this->x);
00034       union {
00035         float real;
00036         uint32_t base;
00037       } u_y;
00038       u_y.real = this->y;
00039       *(outbuffer + offset + 0) = (u_y.base >> (8 * 0)) & 0xFF;
00040       *(outbuffer + offset + 1) = (u_y.base >> (8 * 1)) & 0xFF;
00041       *(outbuffer + offset + 2) = (u_y.base >> (8 * 2)) & 0xFF;
00042       *(outbuffer + offset + 3) = (u_y.base >> (8 * 3)) & 0xFF;
00043       offset += sizeof(this->y);
00044       union {
00045         float real;
00046         uint32_t base;
00047       } u_theta;
00048       u_theta.real = this->theta;
00049       *(outbuffer + offset + 0) = (u_theta.base >> (8 * 0)) & 0xFF;
00050       *(outbuffer + offset + 1) = (u_theta.base >> (8 * 1)) & 0xFF;
00051       *(outbuffer + offset + 2) = (u_theta.base >> (8 * 2)) & 0xFF;
00052       *(outbuffer + offset + 3) = (u_theta.base >> (8 * 3)) & 0xFF;
00053       offset += sizeof(this->theta);
00054       uint32_t length_name = strlen( (const char*) this->name);
00055       memcpy(outbuffer + offset, &length_name, sizeof(uint32_t));
00056       offset += 4;
00057       memcpy(outbuffer + offset, this->name, length_name);
00058       offset += length_name;
00059       return offset;
00060     }
00061 
00062     virtual int deserialize(unsigned char *inbuffer)
00063     {
00064       int offset = 0;
00065       union {
00066         float real;
00067         uint32_t base;
00068       } u_x;
00069       u_x.base = 0;
00070       u_x.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00071       u_x.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00072       u_x.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00073       u_x.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00074       this->x = u_x.real;
00075       offset += sizeof(this->x);
00076       union {
00077         float real;
00078         uint32_t base;
00079       } u_y;
00080       u_y.base = 0;
00081       u_y.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00082       u_y.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00083       u_y.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00084       u_y.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00085       this->y = u_y.real;
00086       offset += sizeof(this->y);
00087       union {
00088         float real;
00089         uint32_t base;
00090       } u_theta;
00091       u_theta.base = 0;
00092       u_theta.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00093       u_theta.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00094       u_theta.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00095       u_theta.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00096       this->theta = u_theta.real;
00097       offset += sizeof(this->theta);
00098       uint32_t length_name;
00099       memcpy(&length_name, (inbuffer + offset), sizeof(uint32_t));
00100       offset += 4;
00101       for(unsigned int k= offset; k< offset+length_name; ++k){
00102           inbuffer[k-1]=inbuffer[k];
00103       }
00104       inbuffer[offset+length_name-1]=0;
00105       this->name = (char *)(inbuffer + offset-1);
00106       offset += length_name;
00107      return offset;
00108     }
00109 
00110     const char * getType(){ return SPAWN; };
00111     const char * getMD5(){ return "57f001c49ab7b11d699f8606c1f4f7ff"; };
00112 
00113   };
00114 
00115   class SpawnResponse : public ros::Msg
00116   {
00117     public:
00118       char * name;
00119 
00120     virtual int serialize(unsigned char *outbuffer) const
00121     {
00122       int offset = 0;
00123       uint32_t length_name = strlen( (const char*) this->name);
00124       memcpy(outbuffer + offset, &length_name, sizeof(uint32_t));
00125       offset += 4;
00126       memcpy(outbuffer + offset, this->name, length_name);
00127       offset += length_name;
00128       return offset;
00129     }
00130 
00131     virtual int deserialize(unsigned char *inbuffer)
00132     {
00133       int offset = 0;
00134       uint32_t length_name;
00135       memcpy(&length_name, (inbuffer + offset), sizeof(uint32_t));
00136       offset += 4;
00137       for(unsigned int k= offset; k< offset+length_name; ++k){
00138           inbuffer[k-1]=inbuffer[k];
00139       }
00140       inbuffer[offset+length_name-1]=0;
00141       this->name = (char *)(inbuffer + offset-1);
00142       offset += length_name;
00143      return offset;
00144     }
00145 
00146     const char * getType(){ return SPAWN; };
00147     const char * getMD5(){ return "c1f3d28f1b044c871e6eff2e9fc3c667"; };
00148 
00149   };
00150 
00151   class Spawn {
00152     public:
00153     typedef SpawnRequest Request;
00154     typedef SpawnResponse Response;
00155   };
00156 
00157 }
00158 #endif


lizi_arduino
Author(s): RoboTiCan
autogenerated on Wed Aug 26 2015 12:24:22