ROS Serial library for Mbed platforms for ROS Melodic Morenia. Check http://wiki.ros.org/rosserial_mbed/ for more information.
actionlib_tutorials/AveragingResult.h@2:fa426560b283, 2021-05-27 (annotated)
- Committer:
- krogedal
- Date:
- Thu May 27 19:25:46 2021 +0000
- Revision:
- 2:fa426560b283
- Parent:
- 0:04ac6be8229a
no change
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Gary Servin |
0:04ac6be8229a | 1 | #ifndef _ROS_actionlib_tutorials_AveragingResult_h |
Gary Servin |
0:04ac6be8229a | 2 | #define _ROS_actionlib_tutorials_AveragingResult_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 AveragingResult : public ros::Msg |
Gary Servin |
0:04ac6be8229a | 13 | { |
Gary Servin |
0:04ac6be8229a | 14 | public: |
Gary Servin |
0:04ac6be8229a | 15 | typedef float _mean_type; |
Gary Servin |
0:04ac6be8229a | 16 | _mean_type mean; |
Gary Servin |
0:04ac6be8229a | 17 | typedef float _std_dev_type; |
Gary Servin |
0:04ac6be8229a | 18 | _std_dev_type std_dev; |
Gary Servin |
0:04ac6be8229a | 19 | |
Gary Servin |
0:04ac6be8229a | 20 | AveragingResult(): |
Gary Servin |
0:04ac6be8229a | 21 | mean(0), |
Gary Servin |
0:04ac6be8229a | 22 | std_dev(0) |
Gary Servin |
0:04ac6be8229a | 23 | { |
Gary Servin |
0:04ac6be8229a | 24 | } |
Gary Servin |
0:04ac6be8229a | 25 | |
Gary Servin |
0:04ac6be8229a | 26 | virtual int serialize(unsigned char *outbuffer) const |
Gary Servin |
0:04ac6be8229a | 27 | { |
Gary Servin |
0:04ac6be8229a | 28 | int offset = 0; |
Gary Servin |
0:04ac6be8229a | 29 | union { |
Gary Servin |
0:04ac6be8229a | 30 | float real; |
Gary Servin |
0:04ac6be8229a | 31 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 32 | } u_mean; |
Gary Servin |
0:04ac6be8229a | 33 | u_mean.real = this->mean; |
Gary Servin |
0:04ac6be8229a | 34 | *(outbuffer + offset + 0) = (u_mean.base >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 35 | *(outbuffer + offset + 1) = (u_mean.base >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 36 | *(outbuffer + offset + 2) = (u_mean.base >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 37 | *(outbuffer + offset + 3) = (u_mean.base >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 38 | offset += sizeof(this->mean); |
Gary Servin |
0:04ac6be8229a | 39 | union { |
Gary Servin |
0:04ac6be8229a | 40 | float real; |
Gary Servin |
0:04ac6be8229a | 41 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 42 | } u_std_dev; |
Gary Servin |
0:04ac6be8229a | 43 | u_std_dev.real = this->std_dev; |
Gary Servin |
0:04ac6be8229a | 44 | *(outbuffer + offset + 0) = (u_std_dev.base >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 45 | *(outbuffer + offset + 1) = (u_std_dev.base >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 46 | *(outbuffer + offset + 2) = (u_std_dev.base >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 47 | *(outbuffer + offset + 3) = (u_std_dev.base >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 48 | offset += sizeof(this->std_dev); |
Gary Servin |
0:04ac6be8229a | 49 | return offset; |
Gary Servin |
0:04ac6be8229a | 50 | } |
Gary Servin |
0:04ac6be8229a | 51 | |
Gary Servin |
0:04ac6be8229a | 52 | virtual int deserialize(unsigned char *inbuffer) |
Gary Servin |
0:04ac6be8229a | 53 | { |
Gary Servin |
0:04ac6be8229a | 54 | int offset = 0; |
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.base = 0; |
Gary Servin |
0:04ac6be8229a | 60 | u_mean.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
Gary Servin |
0:04ac6be8229a | 61 | u_mean.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 62 | u_mean.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 63 | u_mean.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 64 | this->mean = u_mean.real; |
Gary Servin |
0:04ac6be8229a | 65 | offset += sizeof(this->mean); |
Gary Servin |
0:04ac6be8229a | 66 | union { |
Gary Servin |
0:04ac6be8229a | 67 | float real; |
Gary Servin |
0:04ac6be8229a | 68 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 69 | } u_std_dev; |
Gary Servin |
0:04ac6be8229a | 70 | u_std_dev.base = 0; |
Gary Servin |
0:04ac6be8229a | 71 | u_std_dev.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
Gary Servin |
0:04ac6be8229a | 72 | u_std_dev.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 73 | u_std_dev.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 74 | u_std_dev.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 75 | this->std_dev = u_std_dev.real; |
Gary Servin |
0:04ac6be8229a | 76 | offset += sizeof(this->std_dev); |
Gary Servin |
0:04ac6be8229a | 77 | return offset; |
Gary Servin |
0:04ac6be8229a | 78 | } |
Gary Servin |
0:04ac6be8229a | 79 | |
Gary Servin |
0:04ac6be8229a | 80 | const char * getType(){ return "actionlib_tutorials/AveragingResult"; }; |
Gary Servin |
0:04ac6be8229a | 81 | const char * getMD5(){ return "d5c7decf6df75ffb4367a05c1bcc7612"; }; |
Gary Servin |
0:04ac6be8229a | 82 | |
Gary Servin |
0:04ac6be8229a | 83 | }; |
Gary Servin |
0:04ac6be8229a | 84 | |
Gary Servin |
0:04ac6be8229a | 85 | } |
Gary Servin |
0:04ac6be8229a | 86 | #endif |