capstone_finish
Dependencies: BufferedSerial motor_sn7544
sensor_msgs/Imu.h@10:ca4e4062701a, 2019-11-26 (annotated)
- Committer:
- Jeonghoon
- Date:
- Tue Nov 26 15:30:27 2019 +0000
- Revision:
- 10:ca4e4062701a
- Parent:
- 3:2a3664dc6634
capstone finish
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jeonghoon | 3:2a3664dc6634 | 1 | #ifndef _ROS_sensor_msgs_Imu_h |
Jeonghoon | 3:2a3664dc6634 | 2 | #define _ROS_sensor_msgs_Imu_h |
Jeonghoon | 3:2a3664dc6634 | 3 | |
Jeonghoon | 3:2a3664dc6634 | 4 | #include <stdint.h> |
Jeonghoon | 3:2a3664dc6634 | 5 | #include <string.h> |
Jeonghoon | 3:2a3664dc6634 | 6 | #include <stdlib.h> |
Jeonghoon | 3:2a3664dc6634 | 7 | #include "ros/msg.h" |
Jeonghoon | 3:2a3664dc6634 | 8 | #include "std_msgs/Header.h" |
Jeonghoon | 3:2a3664dc6634 | 9 | #include "geometry_msgs/Quaternion.h" |
Jeonghoon | 3:2a3664dc6634 | 10 | #include "geometry_msgs/Vector3.h" |
Jeonghoon | 3:2a3664dc6634 | 11 | |
Jeonghoon | 3:2a3664dc6634 | 12 | namespace sensor_msgs |
Jeonghoon | 3:2a3664dc6634 | 13 | { |
Jeonghoon | 3:2a3664dc6634 | 14 | |
Jeonghoon | 3:2a3664dc6634 | 15 | class Imu : public ros::Msg |
Jeonghoon | 3:2a3664dc6634 | 16 | { |
Jeonghoon | 3:2a3664dc6634 | 17 | public: |
Jeonghoon | 3:2a3664dc6634 | 18 | typedef std_msgs::Header _header_type; |
Jeonghoon | 3:2a3664dc6634 | 19 | _header_type header; |
Jeonghoon | 3:2a3664dc6634 | 20 | typedef geometry_msgs::Quaternion _orientation_type; |
Jeonghoon | 3:2a3664dc6634 | 21 | _orientation_type orientation; |
Jeonghoon | 3:2a3664dc6634 | 22 | double orientation_covariance[9]; |
Jeonghoon | 3:2a3664dc6634 | 23 | typedef geometry_msgs::Vector3 _angular_velocity_type; |
Jeonghoon | 3:2a3664dc6634 | 24 | _angular_velocity_type angular_velocity; |
Jeonghoon | 3:2a3664dc6634 | 25 | double angular_velocity_covariance[9]; |
Jeonghoon | 3:2a3664dc6634 | 26 | typedef geometry_msgs::Vector3 _linear_acceleration_type; |
Jeonghoon | 3:2a3664dc6634 | 27 | _linear_acceleration_type linear_acceleration; |
Jeonghoon | 3:2a3664dc6634 | 28 | double linear_acceleration_covariance[9]; |
Jeonghoon | 3:2a3664dc6634 | 29 | |
Jeonghoon | 3:2a3664dc6634 | 30 | Imu(): |
Jeonghoon | 3:2a3664dc6634 | 31 | header(), |
Jeonghoon | 3:2a3664dc6634 | 32 | orientation(), |
Jeonghoon | 3:2a3664dc6634 | 33 | orientation_covariance(), |
Jeonghoon | 3:2a3664dc6634 | 34 | angular_velocity(), |
Jeonghoon | 3:2a3664dc6634 | 35 | angular_velocity_covariance(), |
Jeonghoon | 3:2a3664dc6634 | 36 | linear_acceleration(), |
Jeonghoon | 3:2a3664dc6634 | 37 | linear_acceleration_covariance() |
Jeonghoon | 3:2a3664dc6634 | 38 | { |
Jeonghoon | 3:2a3664dc6634 | 39 | } |
Jeonghoon | 3:2a3664dc6634 | 40 | |
Jeonghoon | 3:2a3664dc6634 | 41 | virtual int serialize(unsigned char *outbuffer) const |
Jeonghoon | 3:2a3664dc6634 | 42 | { |
Jeonghoon | 3:2a3664dc6634 | 43 | int offset = 0; |
Jeonghoon | 3:2a3664dc6634 | 44 | offset += this->header.serialize(outbuffer + offset); |
Jeonghoon | 3:2a3664dc6634 | 45 | offset += this->orientation.serialize(outbuffer + offset); |
Jeonghoon | 3:2a3664dc6634 | 46 | for( uint32_t i = 0; i < 9; i++){ |
Jeonghoon | 3:2a3664dc6634 | 47 | union { |
Jeonghoon | 3:2a3664dc6634 | 48 | double real; |
Jeonghoon | 3:2a3664dc6634 | 49 | uint64_t base; |
Jeonghoon | 3:2a3664dc6634 | 50 | } u_orientation_covariancei; |
Jeonghoon | 3:2a3664dc6634 | 51 | u_orientation_covariancei.real = this->orientation_covariance[i]; |
Jeonghoon | 3:2a3664dc6634 | 52 | *(outbuffer + offset + 0) = (u_orientation_covariancei.base >> (8 * 0)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 53 | *(outbuffer + offset + 1) = (u_orientation_covariancei.base >> (8 * 1)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 54 | *(outbuffer + offset + 2) = (u_orientation_covariancei.base >> (8 * 2)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 55 | *(outbuffer + offset + 3) = (u_orientation_covariancei.base >> (8 * 3)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 56 | *(outbuffer + offset + 4) = (u_orientation_covariancei.base >> (8 * 4)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 57 | *(outbuffer + offset + 5) = (u_orientation_covariancei.base >> (8 * 5)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 58 | *(outbuffer + offset + 6) = (u_orientation_covariancei.base >> (8 * 6)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 59 | *(outbuffer + offset + 7) = (u_orientation_covariancei.base >> (8 * 7)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 60 | offset += sizeof(this->orientation_covariance[i]); |
Jeonghoon | 3:2a3664dc6634 | 61 | } |
Jeonghoon | 3:2a3664dc6634 | 62 | offset += this->angular_velocity.serialize(outbuffer + offset); |
Jeonghoon | 3:2a3664dc6634 | 63 | for( uint32_t i = 0; i < 9; i++){ |
Jeonghoon | 3:2a3664dc6634 | 64 | union { |
Jeonghoon | 3:2a3664dc6634 | 65 | double real; |
Jeonghoon | 3:2a3664dc6634 | 66 | uint64_t base; |
Jeonghoon | 3:2a3664dc6634 | 67 | } u_angular_velocity_covariancei; |
Jeonghoon | 3:2a3664dc6634 | 68 | u_angular_velocity_covariancei.real = this->angular_velocity_covariance[i]; |
Jeonghoon | 3:2a3664dc6634 | 69 | *(outbuffer + offset + 0) = (u_angular_velocity_covariancei.base >> (8 * 0)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 70 | *(outbuffer + offset + 1) = (u_angular_velocity_covariancei.base >> (8 * 1)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 71 | *(outbuffer + offset + 2) = (u_angular_velocity_covariancei.base >> (8 * 2)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 72 | *(outbuffer + offset + 3) = (u_angular_velocity_covariancei.base >> (8 * 3)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 73 | *(outbuffer + offset + 4) = (u_angular_velocity_covariancei.base >> (8 * 4)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 74 | *(outbuffer + offset + 5) = (u_angular_velocity_covariancei.base >> (8 * 5)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 75 | *(outbuffer + offset + 6) = (u_angular_velocity_covariancei.base >> (8 * 6)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 76 | *(outbuffer + offset + 7) = (u_angular_velocity_covariancei.base >> (8 * 7)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 77 | offset += sizeof(this->angular_velocity_covariance[i]); |
Jeonghoon | 3:2a3664dc6634 | 78 | } |
Jeonghoon | 3:2a3664dc6634 | 79 | offset += this->linear_acceleration.serialize(outbuffer + offset); |
Jeonghoon | 3:2a3664dc6634 | 80 | for( uint32_t i = 0; i < 9; i++){ |
Jeonghoon | 3:2a3664dc6634 | 81 | union { |
Jeonghoon | 3:2a3664dc6634 | 82 | double real; |
Jeonghoon | 3:2a3664dc6634 | 83 | uint64_t base; |
Jeonghoon | 3:2a3664dc6634 | 84 | } u_linear_acceleration_covariancei; |
Jeonghoon | 3:2a3664dc6634 | 85 | u_linear_acceleration_covariancei.real = this->linear_acceleration_covariance[i]; |
Jeonghoon | 3:2a3664dc6634 | 86 | *(outbuffer + offset + 0) = (u_linear_acceleration_covariancei.base >> (8 * 0)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 87 | *(outbuffer + offset + 1) = (u_linear_acceleration_covariancei.base >> (8 * 1)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 88 | *(outbuffer + offset + 2) = (u_linear_acceleration_covariancei.base >> (8 * 2)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 89 | *(outbuffer + offset + 3) = (u_linear_acceleration_covariancei.base >> (8 * 3)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 90 | *(outbuffer + offset + 4) = (u_linear_acceleration_covariancei.base >> (8 * 4)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 91 | *(outbuffer + offset + 5) = (u_linear_acceleration_covariancei.base >> (8 * 5)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 92 | *(outbuffer + offset + 6) = (u_linear_acceleration_covariancei.base >> (8 * 6)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 93 | *(outbuffer + offset + 7) = (u_linear_acceleration_covariancei.base >> (8 * 7)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 94 | offset += sizeof(this->linear_acceleration_covariance[i]); |
Jeonghoon | 3:2a3664dc6634 | 95 | } |
Jeonghoon | 3:2a3664dc6634 | 96 | return offset; |
Jeonghoon | 3:2a3664dc6634 | 97 | } |
Jeonghoon | 3:2a3664dc6634 | 98 | |
Jeonghoon | 3:2a3664dc6634 | 99 | virtual int deserialize(unsigned char *inbuffer) |
Jeonghoon | 3:2a3664dc6634 | 100 | { |
Jeonghoon | 3:2a3664dc6634 | 101 | int offset = 0; |
Jeonghoon | 3:2a3664dc6634 | 102 | offset += this->header.deserialize(inbuffer + offset); |
Jeonghoon | 3:2a3664dc6634 | 103 | offset += this->orientation.deserialize(inbuffer + offset); |
Jeonghoon | 3:2a3664dc6634 | 104 | for( uint32_t i = 0; i < 9; i++){ |
Jeonghoon | 3:2a3664dc6634 | 105 | union { |
Jeonghoon | 3:2a3664dc6634 | 106 | double real; |
Jeonghoon | 3:2a3664dc6634 | 107 | uint64_t base; |
Jeonghoon | 3:2a3664dc6634 | 108 | } u_orientation_covariancei; |
Jeonghoon | 3:2a3664dc6634 | 109 | u_orientation_covariancei.base = 0; |
Jeonghoon | 3:2a3664dc6634 | 110 | u_orientation_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); |
Jeonghoon | 3:2a3664dc6634 | 111 | u_orientation_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Jeonghoon | 3:2a3664dc6634 | 112 | u_orientation_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Jeonghoon | 3:2a3664dc6634 | 113 | u_orientation_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Jeonghoon | 3:2a3664dc6634 | 114 | u_orientation_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); |
Jeonghoon | 3:2a3664dc6634 | 115 | u_orientation_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); |
Jeonghoon | 3:2a3664dc6634 | 116 | u_orientation_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); |
Jeonghoon | 3:2a3664dc6634 | 117 | u_orientation_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); |
Jeonghoon | 3:2a3664dc6634 | 118 | this->orientation_covariance[i] = u_orientation_covariancei.real; |
Jeonghoon | 3:2a3664dc6634 | 119 | offset += sizeof(this->orientation_covariance[i]); |
Jeonghoon | 3:2a3664dc6634 | 120 | } |
Jeonghoon | 3:2a3664dc6634 | 121 | offset += this->angular_velocity.deserialize(inbuffer + offset); |
Jeonghoon | 3:2a3664dc6634 | 122 | for( uint32_t i = 0; i < 9; i++){ |
Jeonghoon | 3:2a3664dc6634 | 123 | union { |
Jeonghoon | 3:2a3664dc6634 | 124 | double real; |
Jeonghoon | 3:2a3664dc6634 | 125 | uint64_t base; |
Jeonghoon | 3:2a3664dc6634 | 126 | } u_angular_velocity_covariancei; |
Jeonghoon | 3:2a3664dc6634 | 127 | u_angular_velocity_covariancei.base = 0; |
Jeonghoon | 3:2a3664dc6634 | 128 | u_angular_velocity_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); |
Jeonghoon | 3:2a3664dc6634 | 129 | u_angular_velocity_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Jeonghoon | 3:2a3664dc6634 | 130 | u_angular_velocity_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Jeonghoon | 3:2a3664dc6634 | 131 | u_angular_velocity_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Jeonghoon | 3:2a3664dc6634 | 132 | u_angular_velocity_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); |
Jeonghoon | 3:2a3664dc6634 | 133 | u_angular_velocity_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); |
Jeonghoon | 3:2a3664dc6634 | 134 | u_angular_velocity_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); |
Jeonghoon | 3:2a3664dc6634 | 135 | u_angular_velocity_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); |
Jeonghoon | 3:2a3664dc6634 | 136 | this->angular_velocity_covariance[i] = u_angular_velocity_covariancei.real; |
Jeonghoon | 3:2a3664dc6634 | 137 | offset += sizeof(this->angular_velocity_covariance[i]); |
Jeonghoon | 3:2a3664dc6634 | 138 | } |
Jeonghoon | 3:2a3664dc6634 | 139 | offset += this->linear_acceleration.deserialize(inbuffer + offset); |
Jeonghoon | 3:2a3664dc6634 | 140 | for( uint32_t i = 0; i < 9; i++){ |
Jeonghoon | 3:2a3664dc6634 | 141 | union { |
Jeonghoon | 3:2a3664dc6634 | 142 | double real; |
Jeonghoon | 3:2a3664dc6634 | 143 | uint64_t base; |
Jeonghoon | 3:2a3664dc6634 | 144 | } u_linear_acceleration_covariancei; |
Jeonghoon | 3:2a3664dc6634 | 145 | u_linear_acceleration_covariancei.base = 0; |
Jeonghoon | 3:2a3664dc6634 | 146 | u_linear_acceleration_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); |
Jeonghoon | 3:2a3664dc6634 | 147 | u_linear_acceleration_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Jeonghoon | 3:2a3664dc6634 | 148 | u_linear_acceleration_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Jeonghoon | 3:2a3664dc6634 | 149 | u_linear_acceleration_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Jeonghoon | 3:2a3664dc6634 | 150 | u_linear_acceleration_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); |
Jeonghoon | 3:2a3664dc6634 | 151 | u_linear_acceleration_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); |
Jeonghoon | 3:2a3664dc6634 | 152 | u_linear_acceleration_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); |
Jeonghoon | 3:2a3664dc6634 | 153 | u_linear_acceleration_covariancei.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); |
Jeonghoon | 3:2a3664dc6634 | 154 | this->linear_acceleration_covariance[i] = u_linear_acceleration_covariancei.real; |
Jeonghoon | 3:2a3664dc6634 | 155 | offset += sizeof(this->linear_acceleration_covariance[i]); |
Jeonghoon | 3:2a3664dc6634 | 156 | } |
Jeonghoon | 3:2a3664dc6634 | 157 | return offset; |
Jeonghoon | 3:2a3664dc6634 | 158 | } |
Jeonghoon | 3:2a3664dc6634 | 159 | |
Jeonghoon | 3:2a3664dc6634 | 160 | const char * getType(){ return "sensor_msgs/Imu"; }; |
Jeonghoon | 3:2a3664dc6634 | 161 | const char * getMD5(){ return "6a62c6daae103f4ff57a132d6f95cec2"; }; |
Jeonghoon | 3:2a3664dc6634 | 162 | |
Jeonghoon | 3:2a3664dc6634 | 163 | }; |
Jeonghoon | 3:2a3664dc6634 | 164 | |
Jeonghoon | 3:2a3664dc6634 | 165 | } |
Jeonghoon | 3:2a3664dc6634 | 166 | #endif |