rosserial library for mbed Inspired by nucho's rosserial library This library is still under development

Dependencies:   MODSERIAL mbed

Dependents:   mbed_roshydro_test

Library still under development!

Committer:
akashvibhute
Date:
Sun Feb 15 10:53:43 2015 +0000
Revision:
0:30537dec6e0b
First commit; Library still need to be debugged, compilation issues with new mbed and modserial updates.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
akashvibhute 0:30537dec6e0b 1 #ifndef _ROS_actionlib_tutorials_AveragingFeedback_h
akashvibhute 0:30537dec6e0b 2 #define _ROS_actionlib_tutorials_AveragingFeedback_h
akashvibhute 0:30537dec6e0b 3
akashvibhute 0:30537dec6e0b 4 #include <stdint.h>
akashvibhute 0:30537dec6e0b 5 #include <string.h>
akashvibhute 0:30537dec6e0b 6 #include <stdlib.h>
akashvibhute 0:30537dec6e0b 7 #include "ros/msg.h"
akashvibhute 0:30537dec6e0b 8
akashvibhute 0:30537dec6e0b 9 namespace actionlib_tutorials
akashvibhute 0:30537dec6e0b 10 {
akashvibhute 0:30537dec6e0b 11
akashvibhute 0:30537dec6e0b 12 class AveragingFeedback : public ros::Msg
akashvibhute 0:30537dec6e0b 13 {
akashvibhute 0:30537dec6e0b 14 public:
akashvibhute 0:30537dec6e0b 15 int32_t sample;
akashvibhute 0:30537dec6e0b 16 float data;
akashvibhute 0:30537dec6e0b 17 float mean;
akashvibhute 0:30537dec6e0b 18 float std_dev;
akashvibhute 0:30537dec6e0b 19
akashvibhute 0:30537dec6e0b 20 AveragingFeedback():
akashvibhute 0:30537dec6e0b 21 sample(0),
akashvibhute 0:30537dec6e0b 22 data(0),
akashvibhute 0:30537dec6e0b 23 mean(0),
akashvibhute 0:30537dec6e0b 24 std_dev(0)
akashvibhute 0:30537dec6e0b 25 {
akashvibhute 0:30537dec6e0b 26 }
akashvibhute 0:30537dec6e0b 27
akashvibhute 0:30537dec6e0b 28 virtual int serialize(unsigned char *outbuffer) const
akashvibhute 0:30537dec6e0b 29 {
akashvibhute 0:30537dec6e0b 30 int offset = 0;
akashvibhute 0:30537dec6e0b 31 union {
akashvibhute 0:30537dec6e0b 32 int32_t real;
akashvibhute 0:30537dec6e0b 33 uint32_t base;
akashvibhute 0:30537dec6e0b 34 } u_sample;
akashvibhute 0:30537dec6e0b 35 u_sample.real = this->sample;
akashvibhute 0:30537dec6e0b 36 *(outbuffer + offset + 0) = (u_sample.base >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 37 *(outbuffer + offset + 1) = (u_sample.base >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 38 *(outbuffer + offset + 2) = (u_sample.base >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 39 *(outbuffer + offset + 3) = (u_sample.base >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 40 offset += sizeof(this->sample);
akashvibhute 0:30537dec6e0b 41 union {
akashvibhute 0:30537dec6e0b 42 float real;
akashvibhute 0:30537dec6e0b 43 uint32_t base;
akashvibhute 0:30537dec6e0b 44 } u_data;
akashvibhute 0:30537dec6e0b 45 u_data.real = this->data;
akashvibhute 0:30537dec6e0b 46 *(outbuffer + offset + 0) = (u_data.base >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 47 *(outbuffer + offset + 1) = (u_data.base >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 48 *(outbuffer + offset + 2) = (u_data.base >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 49 *(outbuffer + offset + 3) = (u_data.base >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 50 offset += sizeof(this->data);
akashvibhute 0:30537dec6e0b 51 union {
akashvibhute 0:30537dec6e0b 52 float real;
akashvibhute 0:30537dec6e0b 53 uint32_t base;
akashvibhute 0:30537dec6e0b 54 } u_mean;
akashvibhute 0:30537dec6e0b 55 u_mean.real = this->mean;
akashvibhute 0:30537dec6e0b 56 *(outbuffer + offset + 0) = (u_mean.base >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 57 *(outbuffer + offset + 1) = (u_mean.base >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 58 *(outbuffer + offset + 2) = (u_mean.base >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 59 *(outbuffer + offset + 3) = (u_mean.base >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 60 offset += sizeof(this->mean);
akashvibhute 0:30537dec6e0b 61 union {
akashvibhute 0:30537dec6e0b 62 float real;
akashvibhute 0:30537dec6e0b 63 uint32_t base;
akashvibhute 0:30537dec6e0b 64 } u_std_dev;
akashvibhute 0:30537dec6e0b 65 u_std_dev.real = this->std_dev;
akashvibhute 0:30537dec6e0b 66 *(outbuffer + offset + 0) = (u_std_dev.base >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 67 *(outbuffer + offset + 1) = (u_std_dev.base >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 68 *(outbuffer + offset + 2) = (u_std_dev.base >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 69 *(outbuffer + offset + 3) = (u_std_dev.base >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 70 offset += sizeof(this->std_dev);
akashvibhute 0:30537dec6e0b 71 return offset;
akashvibhute 0:30537dec6e0b 72 }
akashvibhute 0:30537dec6e0b 73
akashvibhute 0:30537dec6e0b 74 virtual int deserialize(unsigned char *inbuffer)
akashvibhute 0:30537dec6e0b 75 {
akashvibhute 0:30537dec6e0b 76 int offset = 0;
akashvibhute 0:30537dec6e0b 77 union {
akashvibhute 0:30537dec6e0b 78 int32_t real;
akashvibhute 0:30537dec6e0b 79 uint32_t base;
akashvibhute 0:30537dec6e0b 80 } u_sample;
akashvibhute 0:30537dec6e0b 81 u_sample.base = 0;
akashvibhute 0:30537dec6e0b 82 u_sample.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
akashvibhute 0:30537dec6e0b 83 u_sample.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 84 u_sample.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 85 u_sample.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 86 this->sample = u_sample.real;
akashvibhute 0:30537dec6e0b 87 offset += sizeof(this->sample);
akashvibhute 0:30537dec6e0b 88 union {
akashvibhute 0:30537dec6e0b 89 float real;
akashvibhute 0:30537dec6e0b 90 uint32_t base;
akashvibhute 0:30537dec6e0b 91 } u_data;
akashvibhute 0:30537dec6e0b 92 u_data.base = 0;
akashvibhute 0:30537dec6e0b 93 u_data.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
akashvibhute 0:30537dec6e0b 94 u_data.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 95 u_data.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 96 u_data.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 97 this->data = u_data.real;
akashvibhute 0:30537dec6e0b 98 offset += sizeof(this->data);
akashvibhute 0:30537dec6e0b 99 union {
akashvibhute 0:30537dec6e0b 100 float real;
akashvibhute 0:30537dec6e0b 101 uint32_t base;
akashvibhute 0:30537dec6e0b 102 } u_mean;
akashvibhute 0:30537dec6e0b 103 u_mean.base = 0;
akashvibhute 0:30537dec6e0b 104 u_mean.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
akashvibhute 0:30537dec6e0b 105 u_mean.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 106 u_mean.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 107 u_mean.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 108 this->mean = u_mean.real;
akashvibhute 0:30537dec6e0b 109 offset += sizeof(this->mean);
akashvibhute 0:30537dec6e0b 110 union {
akashvibhute 0:30537dec6e0b 111 float real;
akashvibhute 0:30537dec6e0b 112 uint32_t base;
akashvibhute 0:30537dec6e0b 113 } u_std_dev;
akashvibhute 0:30537dec6e0b 114 u_std_dev.base = 0;
akashvibhute 0:30537dec6e0b 115 u_std_dev.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
akashvibhute 0:30537dec6e0b 116 u_std_dev.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 117 u_std_dev.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 118 u_std_dev.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 119 this->std_dev = u_std_dev.real;
akashvibhute 0:30537dec6e0b 120 offset += sizeof(this->std_dev);
akashvibhute 0:30537dec6e0b 121 return offset;
akashvibhute 0:30537dec6e0b 122 }
akashvibhute 0:30537dec6e0b 123
akashvibhute 0:30537dec6e0b 124 const char * getType(){ return "actionlib_tutorials/AveragingFeedback"; };
akashvibhute 0:30537dec6e0b 125 const char * getMD5(){ return "9e8dfc53c2f2a032ca33fa80ec46fd4f"; };
akashvibhute 0:30537dec6e0b 126
akashvibhute 0:30537dec6e0b 127 };
akashvibhute 0:30537dec6e0b 128
akashvibhute 0:30537dec6e0b 129 }
akashvibhute 0:30537dec6e0b 130 #endif