added 1 custom message
Fork of ros_lib_kinetic by
openlab/RF.h@2:af816ffd33df, 2017-05-19 (annotated)
- Committer:
- randalthor
- Date:
- Fri May 19 08:59:12 2017 +0000
- Revision:
- 2:af816ffd33df
custom message mobile robot added for ITU cyber physical lab
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
randalthor | 2:af816ffd33df | 1 | #ifndef _ROS_openlab_RF_h |
randalthor | 2:af816ffd33df | 2 | #define _ROS_openlab_RF_h |
randalthor | 2:af816ffd33df | 3 | |
randalthor | 2:af816ffd33df | 4 | #include <stdint.h> |
randalthor | 2:af816ffd33df | 5 | #include <string.h> |
randalthor | 2:af816ffd33df | 6 | #include <stdlib.h> |
randalthor | 2:af816ffd33df | 7 | #include "ros/msg.h" |
randalthor | 2:af816ffd33df | 8 | |
randalthor | 2:af816ffd33df | 9 | namespace openlab |
randalthor | 2:af816ffd33df | 10 | { |
randalthor | 2:af816ffd33df | 11 | |
randalthor | 2:af816ffd33df | 12 | class RF : public ros::Msg |
randalthor | 2:af816ffd33df | 13 | { |
randalthor | 2:af816ffd33df | 14 | public: |
randalthor | 2:af816ffd33df | 15 | typedef int32_t _encoder_1_type; |
randalthor | 2:af816ffd33df | 16 | _encoder_1_type encoder_1; |
randalthor | 2:af816ffd33df | 17 | typedef int32_t _encoder_2_type; |
randalthor | 2:af816ffd33df | 18 | _encoder_2_type encoder_2; |
randalthor | 2:af816ffd33df | 19 | typedef int32_t _encoder_3_type; |
randalthor | 2:af816ffd33df | 20 | _encoder_3_type encoder_3; |
randalthor | 2:af816ffd33df | 21 | typedef int32_t _encoder_4_type; |
randalthor | 2:af816ffd33df | 22 | _encoder_4_type encoder_4; |
randalthor | 2:af816ffd33df | 23 | |
randalthor | 2:af816ffd33df | 24 | RF(): |
randalthor | 2:af816ffd33df | 25 | encoder_1(0), |
randalthor | 2:af816ffd33df | 26 | encoder_2(0), |
randalthor | 2:af816ffd33df | 27 | encoder_3(0), |
randalthor | 2:af816ffd33df | 28 | encoder_4(0) |
randalthor | 2:af816ffd33df | 29 | { |
randalthor | 2:af816ffd33df | 30 | } |
randalthor | 2:af816ffd33df | 31 | |
randalthor | 2:af816ffd33df | 32 | virtual int serialize(unsigned char *outbuffer) const |
randalthor | 2:af816ffd33df | 33 | { |
randalthor | 2:af816ffd33df | 34 | int offset = 0; |
randalthor | 2:af816ffd33df | 35 | union { |
randalthor | 2:af816ffd33df | 36 | int32_t real; |
randalthor | 2:af816ffd33df | 37 | uint32_t base; |
randalthor | 2:af816ffd33df | 38 | } u_encoder_1; |
randalthor | 2:af816ffd33df | 39 | u_encoder_1.real = this->encoder_1; |
randalthor | 2:af816ffd33df | 40 | *(outbuffer + offset + 0) = (u_encoder_1.base >> (8 * 0)) & 0xFF; |
randalthor | 2:af816ffd33df | 41 | *(outbuffer + offset + 1) = (u_encoder_1.base >> (8 * 1)) & 0xFF; |
randalthor | 2:af816ffd33df | 42 | *(outbuffer + offset + 2) = (u_encoder_1.base >> (8 * 2)) & 0xFF; |
randalthor | 2:af816ffd33df | 43 | *(outbuffer + offset + 3) = (u_encoder_1.base >> (8 * 3)) & 0xFF; |
randalthor | 2:af816ffd33df | 44 | offset += sizeof(this->encoder_1); |
randalthor | 2:af816ffd33df | 45 | union { |
randalthor | 2:af816ffd33df | 46 | int32_t real; |
randalthor | 2:af816ffd33df | 47 | uint32_t base; |
randalthor | 2:af816ffd33df | 48 | } u_encoder_2; |
randalthor | 2:af816ffd33df | 49 | u_encoder_2.real = this->encoder_2; |
randalthor | 2:af816ffd33df | 50 | *(outbuffer + offset + 0) = (u_encoder_2.base >> (8 * 0)) & 0xFF; |
randalthor | 2:af816ffd33df | 51 | *(outbuffer + offset + 1) = (u_encoder_2.base >> (8 * 1)) & 0xFF; |
randalthor | 2:af816ffd33df | 52 | *(outbuffer + offset + 2) = (u_encoder_2.base >> (8 * 2)) & 0xFF; |
randalthor | 2:af816ffd33df | 53 | *(outbuffer + offset + 3) = (u_encoder_2.base >> (8 * 3)) & 0xFF; |
randalthor | 2:af816ffd33df | 54 | offset += sizeof(this->encoder_2); |
randalthor | 2:af816ffd33df | 55 | union { |
randalthor | 2:af816ffd33df | 56 | int32_t real; |
randalthor | 2:af816ffd33df | 57 | uint32_t base; |
randalthor | 2:af816ffd33df | 58 | } u_encoder_3; |
randalthor | 2:af816ffd33df | 59 | u_encoder_3.real = this->encoder_3; |
randalthor | 2:af816ffd33df | 60 | *(outbuffer + offset + 0) = (u_encoder_3.base >> (8 * 0)) & 0xFF; |
randalthor | 2:af816ffd33df | 61 | *(outbuffer + offset + 1) = (u_encoder_3.base >> (8 * 1)) & 0xFF; |
randalthor | 2:af816ffd33df | 62 | *(outbuffer + offset + 2) = (u_encoder_3.base >> (8 * 2)) & 0xFF; |
randalthor | 2:af816ffd33df | 63 | *(outbuffer + offset + 3) = (u_encoder_3.base >> (8 * 3)) & 0xFF; |
randalthor | 2:af816ffd33df | 64 | offset += sizeof(this->encoder_3); |
randalthor | 2:af816ffd33df | 65 | union { |
randalthor | 2:af816ffd33df | 66 | int32_t real; |
randalthor | 2:af816ffd33df | 67 | uint32_t base; |
randalthor | 2:af816ffd33df | 68 | } u_encoder_4; |
randalthor | 2:af816ffd33df | 69 | u_encoder_4.real = this->encoder_4; |
randalthor | 2:af816ffd33df | 70 | *(outbuffer + offset + 0) = (u_encoder_4.base >> (8 * 0)) & 0xFF; |
randalthor | 2:af816ffd33df | 71 | *(outbuffer + offset + 1) = (u_encoder_4.base >> (8 * 1)) & 0xFF; |
randalthor | 2:af816ffd33df | 72 | *(outbuffer + offset + 2) = (u_encoder_4.base >> (8 * 2)) & 0xFF; |
randalthor | 2:af816ffd33df | 73 | *(outbuffer + offset + 3) = (u_encoder_4.base >> (8 * 3)) & 0xFF; |
randalthor | 2:af816ffd33df | 74 | offset += sizeof(this->encoder_4); |
randalthor | 2:af816ffd33df | 75 | return offset; |
randalthor | 2:af816ffd33df | 76 | } |
randalthor | 2:af816ffd33df | 77 | |
randalthor | 2:af816ffd33df | 78 | virtual int deserialize(unsigned char *inbuffer) |
randalthor | 2:af816ffd33df | 79 | { |
randalthor | 2:af816ffd33df | 80 | int offset = 0; |
randalthor | 2:af816ffd33df | 81 | union { |
randalthor | 2:af816ffd33df | 82 | int32_t real; |
randalthor | 2:af816ffd33df | 83 | uint32_t base; |
randalthor | 2:af816ffd33df | 84 | } u_encoder_1; |
randalthor | 2:af816ffd33df | 85 | u_encoder_1.base = 0; |
randalthor | 2:af816ffd33df | 86 | u_encoder_1.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
randalthor | 2:af816ffd33df | 87 | u_encoder_1.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
randalthor | 2:af816ffd33df | 88 | u_encoder_1.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
randalthor | 2:af816ffd33df | 89 | u_encoder_1.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
randalthor | 2:af816ffd33df | 90 | this->encoder_1 = u_encoder_1.real; |
randalthor | 2:af816ffd33df | 91 | offset += sizeof(this->encoder_1); |
randalthor | 2:af816ffd33df | 92 | union { |
randalthor | 2:af816ffd33df | 93 | int32_t real; |
randalthor | 2:af816ffd33df | 94 | uint32_t base; |
randalthor | 2:af816ffd33df | 95 | } u_encoder_2; |
randalthor | 2:af816ffd33df | 96 | u_encoder_2.base = 0; |
randalthor | 2:af816ffd33df | 97 | u_encoder_2.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
randalthor | 2:af816ffd33df | 98 | u_encoder_2.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
randalthor | 2:af816ffd33df | 99 | u_encoder_2.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
randalthor | 2:af816ffd33df | 100 | u_encoder_2.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
randalthor | 2:af816ffd33df | 101 | this->encoder_2 = u_encoder_2.real; |
randalthor | 2:af816ffd33df | 102 | offset += sizeof(this->encoder_2); |
randalthor | 2:af816ffd33df | 103 | union { |
randalthor | 2:af816ffd33df | 104 | int32_t real; |
randalthor | 2:af816ffd33df | 105 | uint32_t base; |
randalthor | 2:af816ffd33df | 106 | } u_encoder_3; |
randalthor | 2:af816ffd33df | 107 | u_encoder_3.base = 0; |
randalthor | 2:af816ffd33df | 108 | u_encoder_3.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
randalthor | 2:af816ffd33df | 109 | u_encoder_3.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
randalthor | 2:af816ffd33df | 110 | u_encoder_3.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
randalthor | 2:af816ffd33df | 111 | u_encoder_3.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
randalthor | 2:af816ffd33df | 112 | this->encoder_3 = u_encoder_3.real; |
randalthor | 2:af816ffd33df | 113 | offset += sizeof(this->encoder_3); |
randalthor | 2:af816ffd33df | 114 | union { |
randalthor | 2:af816ffd33df | 115 | int32_t real; |
randalthor | 2:af816ffd33df | 116 | uint32_t base; |
randalthor | 2:af816ffd33df | 117 | } u_encoder_4; |
randalthor | 2:af816ffd33df | 118 | u_encoder_4.base = 0; |
randalthor | 2:af816ffd33df | 119 | u_encoder_4.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
randalthor | 2:af816ffd33df | 120 | u_encoder_4.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
randalthor | 2:af816ffd33df | 121 | u_encoder_4.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
randalthor | 2:af816ffd33df | 122 | u_encoder_4.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
randalthor | 2:af816ffd33df | 123 | this->encoder_4 = u_encoder_4.real; |
randalthor | 2:af816ffd33df | 124 | offset += sizeof(this->encoder_4); |
randalthor | 2:af816ffd33df | 125 | return offset; |
randalthor | 2:af816ffd33df | 126 | } |
randalthor | 2:af816ffd33df | 127 | |
randalthor | 2:af816ffd33df | 128 | const char * getType(){ return "openlab/RF"; }; |
randalthor | 2:af816ffd33df | 129 | const char * getMD5(){ return "72ef78eb5e9bafb28f2bd3ab6be8a6a5"; }; |
randalthor | 2:af816ffd33df | 130 | |
randalthor | 2:af816ffd33df | 131 | }; |
randalthor | 2:af816ffd33df | 132 | |
randalthor | 2:af816ffd33df | 133 | } |
randalthor | 2:af816ffd33df | 134 | #endif |