make changes on buffer serial

Dependencies:   BufferedSerial

Dependents:  

Committer:
Gary Servin
Date:
Fri Nov 08 14:38:09 2019 -0300
Revision:
0:04ac6be8229a
Initial commit, generated based on a clean melodic-desktop-full

Who changed what in which revision?

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