Go to the documentation of this file.00001 #ifndef _ROS_turtlesim_Pose_h
00002 #define _ROS_turtlesim_Pose_h
00003
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008
00009 namespace turtlesim
00010 {
00011
00012 class Pose : public ros::Msg
00013 {
00014 public:
00015 float x;
00016 float y;
00017 float theta;
00018 float linear_velocity;
00019 float angular_velocity;
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 union {
00055 float real;
00056 uint32_t base;
00057 } u_linear_velocity;
00058 u_linear_velocity.real = this->linear_velocity;
00059 *(outbuffer + offset + 0) = (u_linear_velocity.base >> (8 * 0)) & 0xFF;
00060 *(outbuffer + offset + 1) = (u_linear_velocity.base >> (8 * 1)) & 0xFF;
00061 *(outbuffer + offset + 2) = (u_linear_velocity.base >> (8 * 2)) & 0xFF;
00062 *(outbuffer + offset + 3) = (u_linear_velocity.base >> (8 * 3)) & 0xFF;
00063 offset += sizeof(this->linear_velocity);
00064 union {
00065 float real;
00066 uint32_t base;
00067 } u_angular_velocity;
00068 u_angular_velocity.real = this->angular_velocity;
00069 *(outbuffer + offset + 0) = (u_angular_velocity.base >> (8 * 0)) & 0xFF;
00070 *(outbuffer + offset + 1) = (u_angular_velocity.base >> (8 * 1)) & 0xFF;
00071 *(outbuffer + offset + 2) = (u_angular_velocity.base >> (8 * 2)) & 0xFF;
00072 *(outbuffer + offset + 3) = (u_angular_velocity.base >> (8 * 3)) & 0xFF;
00073 offset += sizeof(this->angular_velocity);
00074 return offset;
00075 }
00076
00077 virtual int deserialize(unsigned char *inbuffer)
00078 {
00079 int offset = 0;
00080 union {
00081 float real;
00082 uint32_t base;
00083 } u_x;
00084 u_x.base = 0;
00085 u_x.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00086 u_x.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00087 u_x.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00088 u_x.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00089 this->x = u_x.real;
00090 offset += sizeof(this->x);
00091 union {
00092 float real;
00093 uint32_t base;
00094 } u_y;
00095 u_y.base = 0;
00096 u_y.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00097 u_y.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00098 u_y.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00099 u_y.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00100 this->y = u_y.real;
00101 offset += sizeof(this->y);
00102 union {
00103 float real;
00104 uint32_t base;
00105 } u_theta;
00106 u_theta.base = 0;
00107 u_theta.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00108 u_theta.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00109 u_theta.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00110 u_theta.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00111 this->theta = u_theta.real;
00112 offset += sizeof(this->theta);
00113 union {
00114 float real;
00115 uint32_t base;
00116 } u_linear_velocity;
00117 u_linear_velocity.base = 0;
00118 u_linear_velocity.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00119 u_linear_velocity.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00120 u_linear_velocity.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00121 u_linear_velocity.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00122 this->linear_velocity = u_linear_velocity.real;
00123 offset += sizeof(this->linear_velocity);
00124 union {
00125 float real;
00126 uint32_t base;
00127 } u_angular_velocity;
00128 u_angular_velocity.base = 0;
00129 u_angular_velocity.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00130 u_angular_velocity.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00131 u_angular_velocity.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00132 u_angular_velocity.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00133 this->angular_velocity = u_angular_velocity.real;
00134 offset += sizeof(this->angular_velocity);
00135 return offset;
00136 }
00137
00138 const char * getType(){ return "turtlesim/Pose"; };
00139 const char * getMD5(){ return "863b248d5016ca62ea2e895ae5265cf9"; };
00140
00141 };
00142
00143 }
00144 #endif