catchrobo2022 mbed LPC1768 メインプログラム
Dependencies: mbed
AndroidSensor.h
00001 #ifndef _ROS_jsk_gui_msgs_AndroidSensor_h 00002 #define _ROS_jsk_gui_msgs_AndroidSensor_h 00003 00004 #include <stdint.h> 00005 #include <string.h> 00006 #include <stdlib.h> 00007 #include "ros/msg.h" 00008 00009 namespace jsk_gui_msgs 00010 { 00011 00012 class AndroidSensor : public ros::Msg 00013 { 00014 public: 00015 typedef double _accel_x_type; 00016 _accel_x_type accel_x; 00017 typedef double _accel_y_type; 00018 _accel_y_type accel_y; 00019 typedef double _accel_z_type; 00020 _accel_z_type accel_z; 00021 typedef double _orientation_x_type; 00022 _orientation_x_type orientation_x; 00023 typedef double _orientation_y_type; 00024 _orientation_y_type orientation_y; 00025 typedef double _orientation_z_type; 00026 _orientation_z_type orientation_z; 00027 00028 AndroidSensor(): 00029 accel_x(0), 00030 accel_y(0), 00031 accel_z(0), 00032 orientation_x(0), 00033 orientation_y(0), 00034 orientation_z(0) 00035 { 00036 } 00037 00038 virtual int serialize(unsigned char *outbuffer) const 00039 { 00040 int offset = 0; 00041 union { 00042 double real; 00043 uint64_t base; 00044 } u_accel_x; 00045 u_accel_x.real = this->accel_x; 00046 *(outbuffer + offset + 0) = (u_accel_x.base >> (8 * 0)) & 0xFF; 00047 *(outbuffer + offset + 1) = (u_accel_x.base >> (8 * 1)) & 0xFF; 00048 *(outbuffer + offset + 2) = (u_accel_x.base >> (8 * 2)) & 0xFF; 00049 *(outbuffer + offset + 3) = (u_accel_x.base >> (8 * 3)) & 0xFF; 00050 *(outbuffer + offset + 4) = (u_accel_x.base >> (8 * 4)) & 0xFF; 00051 *(outbuffer + offset + 5) = (u_accel_x.base >> (8 * 5)) & 0xFF; 00052 *(outbuffer + offset + 6) = (u_accel_x.base >> (8 * 6)) & 0xFF; 00053 *(outbuffer + offset + 7) = (u_accel_x.base >> (8 * 7)) & 0xFF; 00054 offset += sizeof(this->accel_x); 00055 union { 00056 double real; 00057 uint64_t base; 00058 } u_accel_y; 00059 u_accel_y.real = this->accel_y; 00060 *(outbuffer + offset + 0) = (u_accel_y.base >> (8 * 0)) & 0xFF; 00061 *(outbuffer + offset + 1) = (u_accel_y.base >> (8 * 1)) & 0xFF; 00062 *(outbuffer + offset + 2) = (u_accel_y.base >> (8 * 2)) & 0xFF; 00063 *(outbuffer + offset + 3) = (u_accel_y.base >> (8 * 3)) & 0xFF; 00064 *(outbuffer + offset + 4) = (u_accel_y.base >> (8 * 4)) & 0xFF; 00065 *(outbuffer + offset + 5) = (u_accel_y.base >> (8 * 5)) & 0xFF; 00066 *(outbuffer + offset + 6) = (u_accel_y.base >> (8 * 6)) & 0xFF; 00067 *(outbuffer + offset + 7) = (u_accel_y.base >> (8 * 7)) & 0xFF; 00068 offset += sizeof(this->accel_y); 00069 union { 00070 double real; 00071 uint64_t base; 00072 } u_accel_z; 00073 u_accel_z.real = this->accel_z; 00074 *(outbuffer + offset + 0) = (u_accel_z.base >> (8 * 0)) & 0xFF; 00075 *(outbuffer + offset + 1) = (u_accel_z.base >> (8 * 1)) & 0xFF; 00076 *(outbuffer + offset + 2) = (u_accel_z.base >> (8 * 2)) & 0xFF; 00077 *(outbuffer + offset + 3) = (u_accel_z.base >> (8 * 3)) & 0xFF; 00078 *(outbuffer + offset + 4) = (u_accel_z.base >> (8 * 4)) & 0xFF; 00079 *(outbuffer + offset + 5) = (u_accel_z.base >> (8 * 5)) & 0xFF; 00080 *(outbuffer + offset + 6) = (u_accel_z.base >> (8 * 6)) & 0xFF; 00081 *(outbuffer + offset + 7) = (u_accel_z.base >> (8 * 7)) & 0xFF; 00082 offset += sizeof(this->accel_z); 00083 union { 00084 double real; 00085 uint64_t base; 00086 } u_orientation_x; 00087 u_orientation_x.real = this->orientation_x; 00088 *(outbuffer + offset + 0) = (u_orientation_x.base >> (8 * 0)) & 0xFF; 00089 *(outbuffer + offset + 1) = (u_orientation_x.base >> (8 * 1)) & 0xFF; 00090 *(outbuffer + offset + 2) = (u_orientation_x.base >> (8 * 2)) & 0xFF; 00091 *(outbuffer + offset + 3) = (u_orientation_x.base >> (8 * 3)) & 0xFF; 00092 *(outbuffer + offset + 4) = (u_orientation_x.base >> (8 * 4)) & 0xFF; 00093 *(outbuffer + offset + 5) = (u_orientation_x.base >> (8 * 5)) & 0xFF; 00094 *(outbuffer + offset + 6) = (u_orientation_x.base >> (8 * 6)) & 0xFF; 00095 *(outbuffer + offset + 7) = (u_orientation_x.base >> (8 * 7)) & 0xFF; 00096 offset += sizeof(this->orientation_x); 00097 union { 00098 double real; 00099 uint64_t base; 00100 } u_orientation_y; 00101 u_orientation_y.real = this->orientation_y; 00102 *(outbuffer + offset + 0) = (u_orientation_y.base >> (8 * 0)) & 0xFF; 00103 *(outbuffer + offset + 1) = (u_orientation_y.base >> (8 * 1)) & 0xFF; 00104 *(outbuffer + offset + 2) = (u_orientation_y.base >> (8 * 2)) & 0xFF; 00105 *(outbuffer + offset + 3) = (u_orientation_y.base >> (8 * 3)) & 0xFF; 00106 *(outbuffer + offset + 4) = (u_orientation_y.base >> (8 * 4)) & 0xFF; 00107 *(outbuffer + offset + 5) = (u_orientation_y.base >> (8 * 5)) & 0xFF; 00108 *(outbuffer + offset + 6) = (u_orientation_y.base >> (8 * 6)) & 0xFF; 00109 *(outbuffer + offset + 7) = (u_orientation_y.base >> (8 * 7)) & 0xFF; 00110 offset += sizeof(this->orientation_y); 00111 union { 00112 double real; 00113 uint64_t base; 00114 } u_orientation_z; 00115 u_orientation_z.real = this->orientation_z; 00116 *(outbuffer + offset + 0) = (u_orientation_z.base >> (8 * 0)) & 0xFF; 00117 *(outbuffer + offset + 1) = (u_orientation_z.base >> (8 * 1)) & 0xFF; 00118 *(outbuffer + offset + 2) = (u_orientation_z.base >> (8 * 2)) & 0xFF; 00119 *(outbuffer + offset + 3) = (u_orientation_z.base >> (8 * 3)) & 0xFF; 00120 *(outbuffer + offset + 4) = (u_orientation_z.base >> (8 * 4)) & 0xFF; 00121 *(outbuffer + offset + 5) = (u_orientation_z.base >> (8 * 5)) & 0xFF; 00122 *(outbuffer + offset + 6) = (u_orientation_z.base >> (8 * 6)) & 0xFF; 00123 *(outbuffer + offset + 7) = (u_orientation_z.base >> (8 * 7)) & 0xFF; 00124 offset += sizeof(this->orientation_z); 00125 return offset; 00126 } 00127 00128 virtual int deserialize(unsigned char *inbuffer) 00129 { 00130 int offset = 0; 00131 union { 00132 double real; 00133 uint64_t base; 00134 } u_accel_x; 00135 u_accel_x.base = 0; 00136 u_accel_x.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); 00137 u_accel_x.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); 00138 u_accel_x.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); 00139 u_accel_x.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); 00140 u_accel_x.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); 00141 u_accel_x.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); 00142 u_accel_x.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); 00143 u_accel_x.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); 00144 this->accel_x = u_accel_x.real; 00145 offset += sizeof(this->accel_x); 00146 union { 00147 double real; 00148 uint64_t base; 00149 } u_accel_y; 00150 u_accel_y.base = 0; 00151 u_accel_y.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); 00152 u_accel_y.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); 00153 u_accel_y.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); 00154 u_accel_y.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); 00155 u_accel_y.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); 00156 u_accel_y.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); 00157 u_accel_y.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); 00158 u_accel_y.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); 00159 this->accel_y = u_accel_y.real; 00160 offset += sizeof(this->accel_y); 00161 union { 00162 double real; 00163 uint64_t base; 00164 } u_accel_z; 00165 u_accel_z.base = 0; 00166 u_accel_z.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); 00167 u_accel_z.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); 00168 u_accel_z.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); 00169 u_accel_z.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); 00170 u_accel_z.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); 00171 u_accel_z.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); 00172 u_accel_z.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); 00173 u_accel_z.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); 00174 this->accel_z = u_accel_z.real; 00175 offset += sizeof(this->accel_z); 00176 union { 00177 double real; 00178 uint64_t base; 00179 } u_orientation_x; 00180 u_orientation_x.base = 0; 00181 u_orientation_x.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); 00182 u_orientation_x.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); 00183 u_orientation_x.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); 00184 u_orientation_x.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); 00185 u_orientation_x.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); 00186 u_orientation_x.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); 00187 u_orientation_x.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); 00188 u_orientation_x.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); 00189 this->orientation_x = u_orientation_x.real; 00190 offset += sizeof(this->orientation_x); 00191 union { 00192 double real; 00193 uint64_t base; 00194 } u_orientation_y; 00195 u_orientation_y.base = 0; 00196 u_orientation_y.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); 00197 u_orientation_y.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); 00198 u_orientation_y.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); 00199 u_orientation_y.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); 00200 u_orientation_y.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); 00201 u_orientation_y.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); 00202 u_orientation_y.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); 00203 u_orientation_y.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); 00204 this->orientation_y = u_orientation_y.real; 00205 offset += sizeof(this->orientation_y); 00206 union { 00207 double real; 00208 uint64_t base; 00209 } u_orientation_z; 00210 u_orientation_z.base = 0; 00211 u_orientation_z.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); 00212 u_orientation_z.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); 00213 u_orientation_z.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); 00214 u_orientation_z.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); 00215 u_orientation_z.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); 00216 u_orientation_z.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); 00217 u_orientation_z.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); 00218 u_orientation_z.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); 00219 this->orientation_z = u_orientation_z.real; 00220 offset += sizeof(this->orientation_z); 00221 return offset; 00222 } 00223 00224 virtual const char * getType(){ return "jsk_gui_msgs/AndroidSensor"; }; 00225 virtual const char * getMD5(){ return "d832dbe3be7e7f061d963f2188f1a407"; }; 00226 00227 }; 00228 00229 } 00230 #endif
Generated on Mon Sep 26 2022 13:46:59 by
1.7.2