ROS Serial library for Mbed platforms for ROS Indigo Igloo. Check http://wiki.ros.org/rosserial_mbed/ for more information
Dependents: rosserial_mbed_hello_world_publisher rtos_base_control rosserial_mbed_F64MA ROS-RTOS ... more
Quaternion.h
00001 #ifndef _ROS_geometry_msgs_Quaternion_h 00002 #define _ROS_geometry_msgs_Quaternion_h 00003 00004 #include <stdint.h> 00005 #include <string.h> 00006 #include <stdlib.h> 00007 #include "ros/msg.h" 00008 00009 namespace geometry_msgs 00010 { 00011 00012 class Quaternion : public ros::Msg 00013 { 00014 public: 00015 double x; 00016 double y; 00017 double z; 00018 double w; 00019 00020 Quaternion(): 00021 x(0), 00022 y(0), 00023 z(0), 00024 w(0) 00025 { 00026 } 00027 00028 virtual int serialize(unsigned char *outbuffer) const 00029 { 00030 int offset = 0; 00031 union { 00032 double real; 00033 uint64_t base; 00034 } u_x; 00035 u_x.real = this->x; 00036 *(outbuffer + offset + 0) = (u_x.base >> (8 * 0)) & 0xFF; 00037 *(outbuffer + offset + 1) = (u_x.base >> (8 * 1)) & 0xFF; 00038 *(outbuffer + offset + 2) = (u_x.base >> (8 * 2)) & 0xFF; 00039 *(outbuffer + offset + 3) = (u_x.base >> (8 * 3)) & 0xFF; 00040 *(outbuffer + offset + 4) = (u_x.base >> (8 * 4)) & 0xFF; 00041 *(outbuffer + offset + 5) = (u_x.base >> (8 * 5)) & 0xFF; 00042 *(outbuffer + offset + 6) = (u_x.base >> (8 * 6)) & 0xFF; 00043 *(outbuffer + offset + 7) = (u_x.base >> (8 * 7)) & 0xFF; 00044 offset += sizeof(this->x); 00045 union { 00046 double real; 00047 uint64_t base; 00048 } u_y; 00049 u_y.real = this->y; 00050 *(outbuffer + offset + 0) = (u_y.base >> (8 * 0)) & 0xFF; 00051 *(outbuffer + offset + 1) = (u_y.base >> (8 * 1)) & 0xFF; 00052 *(outbuffer + offset + 2) = (u_y.base >> (8 * 2)) & 0xFF; 00053 *(outbuffer + offset + 3) = (u_y.base >> (8 * 3)) & 0xFF; 00054 *(outbuffer + offset + 4) = (u_y.base >> (8 * 4)) & 0xFF; 00055 *(outbuffer + offset + 5) = (u_y.base >> (8 * 5)) & 0xFF; 00056 *(outbuffer + offset + 6) = (u_y.base >> (8 * 6)) & 0xFF; 00057 *(outbuffer + offset + 7) = (u_y.base >> (8 * 7)) & 0xFF; 00058 offset += sizeof(this->y); 00059 union { 00060 double real; 00061 uint64_t base; 00062 } u_z; 00063 u_z.real = this->z; 00064 *(outbuffer + offset + 0) = (u_z.base >> (8 * 0)) & 0xFF; 00065 *(outbuffer + offset + 1) = (u_z.base >> (8 * 1)) & 0xFF; 00066 *(outbuffer + offset + 2) = (u_z.base >> (8 * 2)) & 0xFF; 00067 *(outbuffer + offset + 3) = (u_z.base >> (8 * 3)) & 0xFF; 00068 *(outbuffer + offset + 4) = (u_z.base >> (8 * 4)) & 0xFF; 00069 *(outbuffer + offset + 5) = (u_z.base >> (8 * 5)) & 0xFF; 00070 *(outbuffer + offset + 6) = (u_z.base >> (8 * 6)) & 0xFF; 00071 *(outbuffer + offset + 7) = (u_z.base >> (8 * 7)) & 0xFF; 00072 offset += sizeof(this->z); 00073 union { 00074 double real; 00075 uint64_t base; 00076 } u_w; 00077 u_w.real = this->w; 00078 *(outbuffer + offset + 0) = (u_w.base >> (8 * 0)) & 0xFF; 00079 *(outbuffer + offset + 1) = (u_w.base >> (8 * 1)) & 0xFF; 00080 *(outbuffer + offset + 2) = (u_w.base >> (8 * 2)) & 0xFF; 00081 *(outbuffer + offset + 3) = (u_w.base >> (8 * 3)) & 0xFF; 00082 *(outbuffer + offset + 4) = (u_w.base >> (8 * 4)) & 0xFF; 00083 *(outbuffer + offset + 5) = (u_w.base >> (8 * 5)) & 0xFF; 00084 *(outbuffer + offset + 6) = (u_w.base >> (8 * 6)) & 0xFF; 00085 *(outbuffer + offset + 7) = (u_w.base >> (8 * 7)) & 0xFF; 00086 offset += sizeof(this->w); 00087 return offset; 00088 } 00089 00090 virtual int deserialize(unsigned char *inbuffer) 00091 { 00092 int offset = 0; 00093 union { 00094 double real; 00095 uint64_t base; 00096 } u_x; 00097 u_x.base = 0; 00098 u_x.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); 00099 u_x.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); 00100 u_x.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); 00101 u_x.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); 00102 u_x.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); 00103 u_x.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); 00104 u_x.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); 00105 u_x.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); 00106 this->x = u_x.real; 00107 offset += sizeof(this->x); 00108 union { 00109 double real; 00110 uint64_t base; 00111 } u_y; 00112 u_y.base = 0; 00113 u_y.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); 00114 u_y.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); 00115 u_y.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); 00116 u_y.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); 00117 u_y.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); 00118 u_y.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); 00119 u_y.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); 00120 u_y.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); 00121 this->y = u_y.real; 00122 offset += sizeof(this->y); 00123 union { 00124 double real; 00125 uint64_t base; 00126 } u_z; 00127 u_z.base = 0; 00128 u_z.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); 00129 u_z.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); 00130 u_z.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); 00131 u_z.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); 00132 u_z.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); 00133 u_z.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); 00134 u_z.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); 00135 u_z.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); 00136 this->z = u_z.real; 00137 offset += sizeof(this->z); 00138 union { 00139 double real; 00140 uint64_t base; 00141 } u_w; 00142 u_w.base = 0; 00143 u_w.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); 00144 u_w.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); 00145 u_w.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); 00146 u_w.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); 00147 u_w.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); 00148 u_w.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); 00149 u_w.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); 00150 u_w.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); 00151 this->w = u_w.real; 00152 offset += sizeof(this->w); 00153 return offset; 00154 } 00155 00156 const char * getType(){ return "geometry_msgs/Quaternion"; }; 00157 const char * getMD5(){ return "a779879fadf0160734f906b8c19c7004"; }; 00158 00159 }; 00160 00161 } 00162 #endif
Generated on Tue Jul 12 2022 18:39:40 by 1.7.2