rosserial for Hydro

Dependencies:   MODSERIAL

Fork of rosserial_mbed_lib by nucho

Committer:
nucho
Date:
Fri Aug 19 09:06:30 2011 +0000
Revision:
0:77afd7560544
Child:
1:ff0ec969dad1

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nucho 0:77afd7560544 1 #ifndef ros_Point32_h
nucho 0:77afd7560544 2 #define ros_Point32_h
nucho 0:77afd7560544 3
nucho 0:77afd7560544 4 #include <stdint.h>
nucho 0:77afd7560544 5 #include <string.h>
nucho 0:77afd7560544 6 #include <stdlib.h>
nucho 0:77afd7560544 7 #include "../ros/msg.h"
nucho 0:77afd7560544 8
nucho 0:77afd7560544 9 namespace geometry_msgs
nucho 0:77afd7560544 10 {
nucho 0:77afd7560544 11
nucho 0:77afd7560544 12 class Point32 : public ros::Msg
nucho 0:77afd7560544 13 {
nucho 0:77afd7560544 14 public:
nucho 0:77afd7560544 15 float x;
nucho 0:77afd7560544 16 float y;
nucho 0:77afd7560544 17 float z;
nucho 0:77afd7560544 18
nucho 0:77afd7560544 19 virtual int serialize(unsigned char *outbuffer)
nucho 0:77afd7560544 20 {
nucho 0:77afd7560544 21 int offset = 0;
nucho 0:77afd7560544 22 union {
nucho 0:77afd7560544 23 float real;
nucho 0:77afd7560544 24 unsigned long base;
nucho 0:77afd7560544 25 } u_x;
nucho 0:77afd7560544 26 u_x.real = this->x;
nucho 0:77afd7560544 27 *(outbuffer + offset + 0) = (u_x.base >> (8 * 0)) & 0xFF;
nucho 0:77afd7560544 28 *(outbuffer + offset + 1) = (u_x.base >> (8 * 1)) & 0xFF;
nucho 0:77afd7560544 29 *(outbuffer + offset + 2) = (u_x.base >> (8 * 2)) & 0xFF;
nucho 0:77afd7560544 30 *(outbuffer + offset + 3) = (u_x.base >> (8 * 3)) & 0xFF;
nucho 0:77afd7560544 31 offset += sizeof(this->x);
nucho 0:77afd7560544 32 union {
nucho 0:77afd7560544 33 float real;
nucho 0:77afd7560544 34 unsigned long base;
nucho 0:77afd7560544 35 } u_y;
nucho 0:77afd7560544 36 u_y.real = this->y;
nucho 0:77afd7560544 37 *(outbuffer + offset + 0) = (u_y.base >> (8 * 0)) & 0xFF;
nucho 0:77afd7560544 38 *(outbuffer + offset + 1) = (u_y.base >> (8 * 1)) & 0xFF;
nucho 0:77afd7560544 39 *(outbuffer + offset + 2) = (u_y.base >> (8 * 2)) & 0xFF;
nucho 0:77afd7560544 40 *(outbuffer + offset + 3) = (u_y.base >> (8 * 3)) & 0xFF;
nucho 0:77afd7560544 41 offset += sizeof(this->y);
nucho 0:77afd7560544 42 union {
nucho 0:77afd7560544 43 float real;
nucho 0:77afd7560544 44 unsigned long base;
nucho 0:77afd7560544 45 } u_z;
nucho 0:77afd7560544 46 u_z.real = this->z;
nucho 0:77afd7560544 47 *(outbuffer + offset + 0) = (u_z.base >> (8 * 0)) & 0xFF;
nucho 0:77afd7560544 48 *(outbuffer + offset + 1) = (u_z.base >> (8 * 1)) & 0xFF;
nucho 0:77afd7560544 49 *(outbuffer + offset + 2) = (u_z.base >> (8 * 2)) & 0xFF;
nucho 0:77afd7560544 50 *(outbuffer + offset + 3) = (u_z.base >> (8 * 3)) & 0xFF;
nucho 0:77afd7560544 51 offset += sizeof(this->z);
nucho 0:77afd7560544 52 return offset;
nucho 0:77afd7560544 53 }
nucho 0:77afd7560544 54
nucho 0:77afd7560544 55 virtual int deserialize(unsigned char *inbuffer)
nucho 0:77afd7560544 56 {
nucho 0:77afd7560544 57 int offset = 0;
nucho 0:77afd7560544 58 union {
nucho 0:77afd7560544 59 float real;
nucho 0:77afd7560544 60 unsigned long base;
nucho 0:77afd7560544 61 } u_x;
nucho 0:77afd7560544 62 u_x.base = 0;
nucho 0:77afd7560544 63 u_x.base |= ((typeof(u_x.base)) (*(inbuffer + offset + 0))) << (8 * 0);
nucho 0:77afd7560544 64 u_x.base |= ((typeof(u_x.base)) (*(inbuffer + offset + 1))) << (8 * 1);
nucho 0:77afd7560544 65 u_x.base |= ((typeof(u_x.base)) (*(inbuffer + offset + 2))) << (8 * 2);
nucho 0:77afd7560544 66 u_x.base |= ((typeof(u_x.base)) (*(inbuffer + offset + 3))) << (8 * 3);
nucho 0:77afd7560544 67 this->x = u_x.real;
nucho 0:77afd7560544 68 offset += sizeof(this->x);
nucho 0:77afd7560544 69 union {
nucho 0:77afd7560544 70 float real;
nucho 0:77afd7560544 71 unsigned long base;
nucho 0:77afd7560544 72 } u_y;
nucho 0:77afd7560544 73 u_y.base = 0;
nucho 0:77afd7560544 74 u_y.base |= ((typeof(u_y.base)) (*(inbuffer + offset + 0))) << (8 * 0);
nucho 0:77afd7560544 75 u_y.base |= ((typeof(u_y.base)) (*(inbuffer + offset + 1))) << (8 * 1);
nucho 0:77afd7560544 76 u_y.base |= ((typeof(u_y.base)) (*(inbuffer + offset + 2))) << (8 * 2);
nucho 0:77afd7560544 77 u_y.base |= ((typeof(u_y.base)) (*(inbuffer + offset + 3))) << (8 * 3);
nucho 0:77afd7560544 78 this->y = u_y.real;
nucho 0:77afd7560544 79 offset += sizeof(this->y);
nucho 0:77afd7560544 80 union {
nucho 0:77afd7560544 81 float real;
nucho 0:77afd7560544 82 unsigned long base;
nucho 0:77afd7560544 83 } u_z;
nucho 0:77afd7560544 84 u_z.base = 0;
nucho 0:77afd7560544 85 u_z.base |= ((typeof(u_z.base)) (*(inbuffer + offset + 0))) << (8 * 0);
nucho 0:77afd7560544 86 u_z.base |= ((typeof(u_z.base)) (*(inbuffer + offset + 1))) << (8 * 1);
nucho 0:77afd7560544 87 u_z.base |= ((typeof(u_z.base)) (*(inbuffer + offset + 2))) << (8 * 2);
nucho 0:77afd7560544 88 u_z.base |= ((typeof(u_z.base)) (*(inbuffer + offset + 3))) << (8 * 3);
nucho 0:77afd7560544 89 this->z = u_z.real;
nucho 0:77afd7560544 90 offset += sizeof(this->z);
nucho 0:77afd7560544 91 return offset;
nucho 0:77afd7560544 92 }
nucho 0:77afd7560544 93
nucho 0:77afd7560544 94 virtual const char * getType(){ return "geometry_msgs/Point32"; };
nucho 0:77afd7560544 95
nucho 0:77afd7560544 96 };
nucho 0:77afd7560544 97
nucho 0:77afd7560544 98 }
nucho 0:77afd7560544 99 #endif