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 Pose.h Source File

Pose.h

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     Pose():
00022       x(0),
00023       y(0),
00024       theta(0),
00025       linear_velocity(0),
00026       angular_velocity(0)
00027     {
00028     }
00029 
00030     virtual int serialize(unsigned char *outbuffer) const
00031     {
00032       int offset = 0;
00033       union {
00034         float real;
00035         uint32_t base;
00036       } u_x;
00037       u_x.real = this->x;
00038       *(outbuffer + offset + 0) = (u_x.base >> (8 * 0)) & 0xFF;
00039       *(outbuffer + offset + 1) = (u_x.base >> (8 * 1)) & 0xFF;
00040       *(outbuffer + offset + 2) = (u_x.base >> (8 * 2)) & 0xFF;
00041       *(outbuffer + offset + 3) = (u_x.base >> (8 * 3)) & 0xFF;
00042       offset += sizeof(this->x);
00043       union {
00044         float real;
00045         uint32_t base;
00046       } u_y;
00047       u_y.real = this->y;
00048       *(outbuffer + offset + 0) = (u_y.base >> (8 * 0)) & 0xFF;
00049       *(outbuffer + offset + 1) = (u_y.base >> (8 * 1)) & 0xFF;
00050       *(outbuffer + offset + 2) = (u_y.base >> (8 * 2)) & 0xFF;
00051       *(outbuffer + offset + 3) = (u_y.base >> (8 * 3)) & 0xFF;
00052       offset += sizeof(this->y);
00053       union {
00054         float real;
00055         uint32_t base;
00056       } u_theta;
00057       u_theta.real = this->theta;
00058       *(outbuffer + offset + 0) = (u_theta.base >> (8 * 0)) & 0xFF;
00059       *(outbuffer + offset + 1) = (u_theta.base >> (8 * 1)) & 0xFF;
00060       *(outbuffer + offset + 2) = (u_theta.base >> (8 * 2)) & 0xFF;
00061       *(outbuffer + offset + 3) = (u_theta.base >> (8 * 3)) & 0xFF;
00062       offset += sizeof(this->theta);
00063       union {
00064         float real;
00065         uint32_t base;
00066       } u_linear_velocity;
00067       u_linear_velocity.real = this->linear_velocity;
00068       *(outbuffer + offset + 0) = (u_linear_velocity.base >> (8 * 0)) & 0xFF;
00069       *(outbuffer + offset + 1) = (u_linear_velocity.base >> (8 * 1)) & 0xFF;
00070       *(outbuffer + offset + 2) = (u_linear_velocity.base >> (8 * 2)) & 0xFF;
00071       *(outbuffer + offset + 3) = (u_linear_velocity.base >> (8 * 3)) & 0xFF;
00072       offset += sizeof(this->linear_velocity);
00073       union {
00074         float real;
00075         uint32_t base;
00076       } u_angular_velocity;
00077       u_angular_velocity.real = this->angular_velocity;
00078       *(outbuffer + offset + 0) = (u_angular_velocity.base >> (8 * 0)) & 0xFF;
00079       *(outbuffer + offset + 1) = (u_angular_velocity.base >> (8 * 1)) & 0xFF;
00080       *(outbuffer + offset + 2) = (u_angular_velocity.base >> (8 * 2)) & 0xFF;
00081       *(outbuffer + offset + 3) = (u_angular_velocity.base >> (8 * 3)) & 0xFF;
00082       offset += sizeof(this->angular_velocity);
00083       return offset;
00084     }
00085 
00086     virtual int deserialize(unsigned char *inbuffer)
00087     {
00088       int offset = 0;
00089       union {
00090         float real;
00091         uint32_t base;
00092       } u_x;
00093       u_x.base = 0;
00094       u_x.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00095       u_x.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00096       u_x.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00097       u_x.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00098       this->x = u_x.real;
00099       offset += sizeof(this->x);
00100       union {
00101         float real;
00102         uint32_t base;
00103       } u_y;
00104       u_y.base = 0;
00105       u_y.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00106       u_y.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00107       u_y.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00108       u_y.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00109       this->y = u_y.real;
00110       offset += sizeof(this->y);
00111       union {
00112         float real;
00113         uint32_t base;
00114       } u_theta;
00115       u_theta.base = 0;
00116       u_theta.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00117       u_theta.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00118       u_theta.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00119       u_theta.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00120       this->theta = u_theta.real;
00121       offset += sizeof(this->theta);
00122       union {
00123         float real;
00124         uint32_t base;
00125       } u_linear_velocity;
00126       u_linear_velocity.base = 0;
00127       u_linear_velocity.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00128       u_linear_velocity.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00129       u_linear_velocity.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00130       u_linear_velocity.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00131       this->linear_velocity = u_linear_velocity.real;
00132       offset += sizeof(this->linear_velocity);
00133       union {
00134         float real;
00135         uint32_t base;
00136       } u_angular_velocity;
00137       u_angular_velocity.base = 0;
00138       u_angular_velocity.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00139       u_angular_velocity.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00140       u_angular_velocity.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00141       u_angular_velocity.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00142       this->angular_velocity = u_angular_velocity.real;
00143       offset += sizeof(this->angular_velocity);
00144      return offset;
00145     }
00146 
00147     const char * getType(){ return "turtlesim/Pose"; };
00148     const char * getMD5(){ return "863b248d5016ca62ea2e895ae5265cf9"; };
00149 
00150   };
00151 
00152 }
00153 #endif