This program is porting rosserial_arduino for mbed http://www.ros.org/wiki/rosserial_arduino This program supported the revision of 169 of rosserial.

Dependencies:  

Dependents:   rosserial_mbed robot_S2

Committer:
nucho
Date:
Sun Oct 16 07:19:36 2011 +0000
Revision:
1:ff0ec969dad1
Parent:
0:77afd7560544
Child:
3:1cf99502f396
This program supported the revision of 143 of rosserial.
And the bug fix of receive of array data.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nucho 0:77afd7560544 1 #ifndef ros_ColorRGBA_h
nucho 0:77afd7560544 2 #define ros_ColorRGBA_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 std_msgs
nucho 0:77afd7560544 10 {
nucho 0:77afd7560544 11
nucho 0:77afd7560544 12 class ColorRGBA : public ros::Msg
nucho 0:77afd7560544 13 {
nucho 0:77afd7560544 14 public:
nucho 0:77afd7560544 15 float r;
nucho 0:77afd7560544 16 float g;
nucho 0:77afd7560544 17 float b;
nucho 0:77afd7560544 18 float a;
nucho 0:77afd7560544 19
nucho 0:77afd7560544 20 virtual int serialize(unsigned char *outbuffer)
nucho 0:77afd7560544 21 {
nucho 0:77afd7560544 22 int offset = 0;
nucho 0:77afd7560544 23 union {
nucho 0:77afd7560544 24 float real;
nucho 1:ff0ec969dad1 25 uint32_t base;
nucho 0:77afd7560544 26 } u_r;
nucho 0:77afd7560544 27 u_r.real = this->r;
nucho 0:77afd7560544 28 *(outbuffer + offset + 0) = (u_r.base >> (8 * 0)) & 0xFF;
nucho 0:77afd7560544 29 *(outbuffer + offset + 1) = (u_r.base >> (8 * 1)) & 0xFF;
nucho 0:77afd7560544 30 *(outbuffer + offset + 2) = (u_r.base >> (8 * 2)) & 0xFF;
nucho 0:77afd7560544 31 *(outbuffer + offset + 3) = (u_r.base >> (8 * 3)) & 0xFF;
nucho 0:77afd7560544 32 offset += sizeof(this->r);
nucho 0:77afd7560544 33 union {
nucho 0:77afd7560544 34 float real;
nucho 1:ff0ec969dad1 35 uint32_t base;
nucho 0:77afd7560544 36 } u_g;
nucho 0:77afd7560544 37 u_g.real = this->g;
nucho 0:77afd7560544 38 *(outbuffer + offset + 0) = (u_g.base >> (8 * 0)) & 0xFF;
nucho 0:77afd7560544 39 *(outbuffer + offset + 1) = (u_g.base >> (8 * 1)) & 0xFF;
nucho 0:77afd7560544 40 *(outbuffer + offset + 2) = (u_g.base >> (8 * 2)) & 0xFF;
nucho 0:77afd7560544 41 *(outbuffer + offset + 3) = (u_g.base >> (8 * 3)) & 0xFF;
nucho 0:77afd7560544 42 offset += sizeof(this->g);
nucho 0:77afd7560544 43 union {
nucho 0:77afd7560544 44 float real;
nucho 1:ff0ec969dad1 45 uint32_t base;
nucho 0:77afd7560544 46 } u_b;
nucho 0:77afd7560544 47 u_b.real = this->b;
nucho 0:77afd7560544 48 *(outbuffer + offset + 0) = (u_b.base >> (8 * 0)) & 0xFF;
nucho 0:77afd7560544 49 *(outbuffer + offset + 1) = (u_b.base >> (8 * 1)) & 0xFF;
nucho 0:77afd7560544 50 *(outbuffer + offset + 2) = (u_b.base >> (8 * 2)) & 0xFF;
nucho 0:77afd7560544 51 *(outbuffer + offset + 3) = (u_b.base >> (8 * 3)) & 0xFF;
nucho 0:77afd7560544 52 offset += sizeof(this->b);
nucho 0:77afd7560544 53 union {
nucho 0:77afd7560544 54 float real;
nucho 1:ff0ec969dad1 55 uint32_t base;
nucho 0:77afd7560544 56 } u_a;
nucho 0:77afd7560544 57 u_a.real = this->a;
nucho 0:77afd7560544 58 *(outbuffer + offset + 0) = (u_a.base >> (8 * 0)) & 0xFF;
nucho 0:77afd7560544 59 *(outbuffer + offset + 1) = (u_a.base >> (8 * 1)) & 0xFF;
nucho 0:77afd7560544 60 *(outbuffer + offset + 2) = (u_a.base >> (8 * 2)) & 0xFF;
nucho 0:77afd7560544 61 *(outbuffer + offset + 3) = (u_a.base >> (8 * 3)) & 0xFF;
nucho 0:77afd7560544 62 offset += sizeof(this->a);
nucho 0:77afd7560544 63 return offset;
nucho 0:77afd7560544 64 }
nucho 0:77afd7560544 65
nucho 0:77afd7560544 66 virtual int deserialize(unsigned char *inbuffer)
nucho 0:77afd7560544 67 {
nucho 0:77afd7560544 68 int offset = 0;
nucho 0:77afd7560544 69 union {
nucho 0:77afd7560544 70 float real;
nucho 1:ff0ec969dad1 71 uint32_t base;
nucho 0:77afd7560544 72 } u_r;
nucho 0:77afd7560544 73 u_r.base = 0;
nucho 0:77afd7560544 74 u_r.base |= ((typeof(u_r.base)) (*(inbuffer + offset + 0))) << (8 * 0);
nucho 0:77afd7560544 75 u_r.base |= ((typeof(u_r.base)) (*(inbuffer + offset + 1))) << (8 * 1);
nucho 0:77afd7560544 76 u_r.base |= ((typeof(u_r.base)) (*(inbuffer + offset + 2))) << (8 * 2);
nucho 0:77afd7560544 77 u_r.base |= ((typeof(u_r.base)) (*(inbuffer + offset + 3))) << (8 * 3);
nucho 0:77afd7560544 78 this->r = u_r.real;
nucho 0:77afd7560544 79 offset += sizeof(this->r);
nucho 0:77afd7560544 80 union {
nucho 0:77afd7560544 81 float real;
nucho 1:ff0ec969dad1 82 uint32_t base;
nucho 0:77afd7560544 83 } u_g;
nucho 0:77afd7560544 84 u_g.base = 0;
nucho 0:77afd7560544 85 u_g.base |= ((typeof(u_g.base)) (*(inbuffer + offset + 0))) << (8 * 0);
nucho 0:77afd7560544 86 u_g.base |= ((typeof(u_g.base)) (*(inbuffer + offset + 1))) << (8 * 1);
nucho 0:77afd7560544 87 u_g.base |= ((typeof(u_g.base)) (*(inbuffer + offset + 2))) << (8 * 2);
nucho 0:77afd7560544 88 u_g.base |= ((typeof(u_g.base)) (*(inbuffer + offset + 3))) << (8 * 3);
nucho 0:77afd7560544 89 this->g = u_g.real;
nucho 0:77afd7560544 90 offset += sizeof(this->g);
nucho 0:77afd7560544 91 union {
nucho 0:77afd7560544 92 float real;
nucho 1:ff0ec969dad1 93 uint32_t base;
nucho 0:77afd7560544 94 } u_b;
nucho 0:77afd7560544 95 u_b.base = 0;
nucho 0:77afd7560544 96 u_b.base |= ((typeof(u_b.base)) (*(inbuffer + offset + 0))) << (8 * 0);
nucho 0:77afd7560544 97 u_b.base |= ((typeof(u_b.base)) (*(inbuffer + offset + 1))) << (8 * 1);
nucho 0:77afd7560544 98 u_b.base |= ((typeof(u_b.base)) (*(inbuffer + offset + 2))) << (8 * 2);
nucho 0:77afd7560544 99 u_b.base |= ((typeof(u_b.base)) (*(inbuffer + offset + 3))) << (8 * 3);
nucho 0:77afd7560544 100 this->b = u_b.real;
nucho 0:77afd7560544 101 offset += sizeof(this->b);
nucho 0:77afd7560544 102 union {
nucho 0:77afd7560544 103 float real;
nucho 1:ff0ec969dad1 104 uint32_t base;
nucho 0:77afd7560544 105 } u_a;
nucho 0:77afd7560544 106 u_a.base = 0;
nucho 0:77afd7560544 107 u_a.base |= ((typeof(u_a.base)) (*(inbuffer + offset + 0))) << (8 * 0);
nucho 0:77afd7560544 108 u_a.base |= ((typeof(u_a.base)) (*(inbuffer + offset + 1))) << (8 * 1);
nucho 0:77afd7560544 109 u_a.base |= ((typeof(u_a.base)) (*(inbuffer + offset + 2))) << (8 * 2);
nucho 0:77afd7560544 110 u_a.base |= ((typeof(u_a.base)) (*(inbuffer + offset + 3))) << (8 * 3);
nucho 0:77afd7560544 111 this->a = u_a.real;
nucho 0:77afd7560544 112 offset += sizeof(this->a);
nucho 0:77afd7560544 113 return offset;
nucho 0:77afd7560544 114 }
nucho 0:77afd7560544 115
nucho 0:77afd7560544 116 virtual const char * getType(){ return "std_msgs/ColorRGBA"; };
nucho 0:77afd7560544 117
nucho 0:77afd7560544 118 };
nucho 0:77afd7560544 119
nucho 0:77afd7560544 120 }
nucho 0:77afd7560544 121 #endif