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

Point2D.h

00001 #ifndef _ROS_opencv_apps_Point2D_h
00002 #define _ROS_opencv_apps_Point2D_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 
00009 namespace opencv_apps
00010 {
00011 
00012   class Point2D : public ros::Msg
00013   {
00014     public:
00015       double x;
00016       double y;
00017 
00018     Point2D():
00019       x(0),
00020       y(0)
00021     {
00022     }
00023 
00024     virtual int serialize(unsigned char *outbuffer) const
00025     {
00026       int offset = 0;
00027       union {
00028         double real;
00029         uint64_t base;
00030       } u_x;
00031       u_x.real = this->x;
00032       *(outbuffer + offset + 0) = (u_x.base >> (8 * 0)) & 0xFF;
00033       *(outbuffer + offset + 1) = (u_x.base >> (8 * 1)) & 0xFF;
00034       *(outbuffer + offset + 2) = (u_x.base >> (8 * 2)) & 0xFF;
00035       *(outbuffer + offset + 3) = (u_x.base >> (8 * 3)) & 0xFF;
00036       *(outbuffer + offset + 4) = (u_x.base >> (8 * 4)) & 0xFF;
00037       *(outbuffer + offset + 5) = (u_x.base >> (8 * 5)) & 0xFF;
00038       *(outbuffer + offset + 6) = (u_x.base >> (8 * 6)) & 0xFF;
00039       *(outbuffer + offset + 7) = (u_x.base >> (8 * 7)) & 0xFF;
00040       offset += sizeof(this->x);
00041       union {
00042         double real;
00043         uint64_t base;
00044       } u_y;
00045       u_y.real = this->y;
00046       *(outbuffer + offset + 0) = (u_y.base >> (8 * 0)) & 0xFF;
00047       *(outbuffer + offset + 1) = (u_y.base >> (8 * 1)) & 0xFF;
00048       *(outbuffer + offset + 2) = (u_y.base >> (8 * 2)) & 0xFF;
00049       *(outbuffer + offset + 3) = (u_y.base >> (8 * 3)) & 0xFF;
00050       *(outbuffer + offset + 4) = (u_y.base >> (8 * 4)) & 0xFF;
00051       *(outbuffer + offset + 5) = (u_y.base >> (8 * 5)) & 0xFF;
00052       *(outbuffer + offset + 6) = (u_y.base >> (8 * 6)) & 0xFF;
00053       *(outbuffer + offset + 7) = (u_y.base >> (8 * 7)) & 0xFF;
00054       offset += sizeof(this->y);
00055       return offset;
00056     }
00057 
00058     virtual int deserialize(unsigned char *inbuffer)
00059     {
00060       int offset = 0;
00061       union {
00062         double real;
00063         uint64_t base;
00064       } u_x;
00065       u_x.base = 0;
00066       u_x.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00067       u_x.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00068       u_x.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00069       u_x.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00070       u_x.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00071       u_x.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00072       u_x.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00073       u_x.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00074       this->x = u_x.real;
00075       offset += sizeof(this->x);
00076       union {
00077         double real;
00078         uint64_t base;
00079       } u_y;
00080       u_y.base = 0;
00081       u_y.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00082       u_y.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00083       u_y.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00084       u_y.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00085       u_y.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00086       u_y.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00087       u_y.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00088       u_y.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00089       this->y = u_y.real;
00090       offset += sizeof(this->y);
00091      return offset;
00092     }
00093 
00094     const char * getType(){ return "opencv_apps/Point2D"; };
00095     const char * getMD5(){ return "209f516d3eb691f0663e25cb750d67c1"; };
00096 
00097   };
00098 
00099 }
00100 #endif