Weber Yang / Mbed 2 deprecated AGV_SMT

Dependencies:   MPU6050-DMP mbed ros_lib_kinetic

Fork of AGV_0411 by Weber Yang

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers tinyVector.h Source File

tinyVector.h

00001 #ifndef _ROS_tiny_msgs_tinyVector_h
00002 #define _ROS_tiny_msgs_tinyVector_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 
00009 namespace tiny_msgs
00010 {
00011 
00012   class tinyVector : public ros::Msg
00013   {
00014     public:
00015       typedef int16_t _x_type;
00016       _x_type x;
00017       typedef int16_t _y_type;
00018       _y_type y;
00019       typedef int16_t _z_type;
00020       _z_type z;
00021 
00022     tinyVector():
00023       x(0),
00024       y(0),
00025       z(0)
00026     {
00027     }
00028 
00029     virtual int serialize(unsigned char *outbuffer) const
00030     {
00031       int offset = 0;
00032       union {
00033         int16_t real;
00034         uint16_t base;
00035       } u_x;
00036       u_x.real = this->x;
00037       *(outbuffer + offset + 0) = (u_x.base >> (8 * 0)) & 0xFF;
00038       *(outbuffer + offset + 1) = (u_x.base >> (8 * 1)) & 0xFF;
00039       offset += sizeof(this->x);
00040       union {
00041         int16_t real;
00042         uint16_t base;
00043       } u_y;
00044       u_y.real = this->y;
00045       *(outbuffer + offset + 0) = (u_y.base >> (8 * 0)) & 0xFF;
00046       *(outbuffer + offset + 1) = (u_y.base >> (8 * 1)) & 0xFF;
00047       offset += sizeof(this->y);
00048       union {
00049         int16_t real;
00050         uint16_t base;
00051       } u_z;
00052       u_z.real = this->z;
00053       *(outbuffer + offset + 0) = (u_z.base >> (8 * 0)) & 0xFF;
00054       *(outbuffer + offset + 1) = (u_z.base >> (8 * 1)) & 0xFF;
00055       offset += sizeof(this->z);
00056       return offset;
00057     }
00058 
00059     virtual int deserialize(unsigned char *inbuffer)
00060     {
00061       int offset = 0;
00062       union {
00063         int16_t real;
00064         uint16_t base;
00065       } u_x;
00066       u_x.base = 0;
00067       u_x.base |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
00068       u_x.base |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00069       this->x = u_x.real;
00070       offset += sizeof(this->x);
00071       union {
00072         int16_t real;
00073         uint16_t base;
00074       } u_y;
00075       u_y.base = 0;
00076       u_y.base |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
00077       u_y.base |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00078       this->y = u_y.real;
00079       offset += sizeof(this->y);
00080       union {
00081         int16_t real;
00082         uint16_t base;
00083       } u_z;
00084       u_z.base = 0;
00085       u_z.base |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
00086       u_z.base |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00087       this->z = u_z.real;
00088       offset += sizeof(this->z);
00089      return offset;
00090     }
00091 
00092     const char * getType(){ return "tinyVector"; };
00093     const char * getMD5(){ return "85729383565f7e059d4a213b3db1317b"; };
00094 
00095   };
00096 
00097 }
00098 #endif