Go to the documentation of this file.00001 #ifndef _ROS_ric_robot_ric_raw_h
00002 #define _ROS_ric_robot_ric_raw_h
00003
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008
00009 namespace ric_robot
00010 {
00011
00012 class ric_raw : public ros::Msg
00013 {
00014 public:
00015 float orientation[4];
00016 int16_t linear_acceleration[3];
00017 int16_t angular_velocity[3];
00018 int16_t magnetometer[3];
00019 int32_t encoders[2];
00020 float urf[3];
00021
00022 virtual int serialize(unsigned char *outbuffer) const
00023 {
00024 int offset = 0;
00025 for( uint8_t i = 0; i < 4; i++){
00026 union {
00027 float real;
00028 uint32_t base;
00029 } u_orientationi;
00030 u_orientationi.real = this->orientation[i];
00031 *(outbuffer + offset + 0) = (u_orientationi.base >> (8 * 0)) & 0xFF;
00032 *(outbuffer + offset + 1) = (u_orientationi.base >> (8 * 1)) & 0xFF;
00033 *(outbuffer + offset + 2) = (u_orientationi.base >> (8 * 2)) & 0xFF;
00034 *(outbuffer + offset + 3) = (u_orientationi.base >> (8 * 3)) & 0xFF;
00035 offset += sizeof(this->orientation[i]);
00036 }
00037 for( uint8_t i = 0; i < 3; i++){
00038 union {
00039 int16_t real;
00040 uint16_t base;
00041 } u_linear_accelerationi;
00042 u_linear_accelerationi.real = this->linear_acceleration[i];
00043 *(outbuffer + offset + 0) = (u_linear_accelerationi.base >> (8 * 0)) & 0xFF;
00044 *(outbuffer + offset + 1) = (u_linear_accelerationi.base >> (8 * 1)) & 0xFF;
00045 offset += sizeof(this->linear_acceleration[i]);
00046 }
00047 for( uint8_t i = 0; i < 3; i++){
00048 union {
00049 int16_t real;
00050 uint16_t base;
00051 } u_angular_velocityi;
00052 u_angular_velocityi.real = this->angular_velocity[i];
00053 *(outbuffer + offset + 0) = (u_angular_velocityi.base >> (8 * 0)) & 0xFF;
00054 *(outbuffer + offset + 1) = (u_angular_velocityi.base >> (8 * 1)) & 0xFF;
00055 offset += sizeof(this->angular_velocity[i]);
00056 }
00057 for( uint8_t i = 0; i < 3; i++){
00058 union {
00059 int16_t real;
00060 uint16_t base;
00061 } u_magnetometeri;
00062 u_magnetometeri.real = this->magnetometer[i];
00063 *(outbuffer + offset + 0) = (u_magnetometeri.base >> (8 * 0)) & 0xFF;
00064 *(outbuffer + offset + 1) = (u_magnetometeri.base >> (8 * 1)) & 0xFF;
00065 offset += sizeof(this->magnetometer[i]);
00066 }
00067 for( uint8_t i = 0; i < 2; i++){
00068 union {
00069 int32_t real;
00070 uint32_t base;
00071 } u_encodersi;
00072 u_encodersi.real = this->encoders[i];
00073 *(outbuffer + offset + 0) = (u_encodersi.base >> (8 * 0)) & 0xFF;
00074 *(outbuffer + offset + 1) = (u_encodersi.base >> (8 * 1)) & 0xFF;
00075 *(outbuffer + offset + 2) = (u_encodersi.base >> (8 * 2)) & 0xFF;
00076 *(outbuffer + offset + 3) = (u_encodersi.base >> (8 * 3)) & 0xFF;
00077 offset += sizeof(this->encoders[i]);
00078 }
00079 for( uint8_t i = 0; i < 3; i++){
00080 union {
00081 float real;
00082 uint32_t base;
00083 } u_urfi;
00084 u_urfi.real = this->urf[i];
00085 *(outbuffer + offset + 0) = (u_urfi.base >> (8 * 0)) & 0xFF;
00086 *(outbuffer + offset + 1) = (u_urfi.base >> (8 * 1)) & 0xFF;
00087 *(outbuffer + offset + 2) = (u_urfi.base >> (8 * 2)) & 0xFF;
00088 *(outbuffer + offset + 3) = (u_urfi.base >> (8 * 3)) & 0xFF;
00089 offset += sizeof(this->urf[i]);
00090 }
00091 return offset;
00092 }
00093
00094 virtual int deserialize(unsigned char *inbuffer)
00095 {
00096 int offset = 0;
00097 for( uint8_t i = 0; i < 4; i++){
00098 union {
00099 float real;
00100 uint32_t base;
00101 } u_orientationi;
00102 u_orientationi.base = 0;
00103 u_orientationi.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00104 u_orientationi.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00105 u_orientationi.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00106 u_orientationi.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00107 this->orientation[i] = u_orientationi.real;
00108 offset += sizeof(this->orientation[i]);
00109 }
00110 for( uint8_t i = 0; i < 3; i++){
00111 union {
00112 int16_t real;
00113 uint16_t base;
00114 } u_linear_accelerationi;
00115 u_linear_accelerationi.base = 0;
00116 u_linear_accelerationi.base |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
00117 u_linear_accelerationi.base |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00118 this->linear_acceleration[i] = u_linear_accelerationi.real;
00119 offset += sizeof(this->linear_acceleration[i]);
00120 }
00121 for( uint8_t i = 0; i < 3; i++){
00122 union {
00123 int16_t real;
00124 uint16_t base;
00125 } u_angular_velocityi;
00126 u_angular_velocityi.base = 0;
00127 u_angular_velocityi.base |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
00128 u_angular_velocityi.base |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00129 this->angular_velocity[i] = u_angular_velocityi.real;
00130 offset += sizeof(this->angular_velocity[i]);
00131 }
00132 for( uint8_t i = 0; i < 3; i++){
00133 union {
00134 int16_t real;
00135 uint16_t base;
00136 } u_magnetometeri;
00137 u_magnetometeri.base = 0;
00138 u_magnetometeri.base |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
00139 u_magnetometeri.base |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00140 this->magnetometer[i] = u_magnetometeri.real;
00141 offset += sizeof(this->magnetometer[i]);
00142 }
00143 for( uint8_t i = 0; i < 2; i++){
00144 union {
00145 int32_t real;
00146 uint32_t base;
00147 } u_encodersi;
00148 u_encodersi.base = 0;
00149 u_encodersi.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00150 u_encodersi.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00151 u_encodersi.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00152 u_encodersi.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00153 this->encoders[i] = u_encodersi.real;
00154 offset += sizeof(this->encoders[i]);
00155 }
00156 for( uint8_t i = 0; i < 3; i++){
00157 union {
00158 float real;
00159 uint32_t base;
00160 } u_urfi;
00161 u_urfi.base = 0;
00162 u_urfi.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00163 u_urfi.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00164 u_urfi.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00165 u_urfi.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00166 this->urf[i] = u_urfi.real;
00167 offset += sizeof(this->urf[i]);
00168 }
00169 return offset;
00170 }
00171
00172 const char * getType(){ return "ric_robot/ric_raw"; };
00173 const char * getMD5(){ return "717e58ef32c83e8c93ceae03d4826367"; };
00174
00175 };
00176
00177 }
00178 #endif