Go to the documentation of this file.00001
00009
00010
00011
00012
00013 #ifndef KOBUKI_THREE_AXIS_GYRO_DATA_HPP__
00014 #define KOBUKI_THREE_AXIS_GYRO_DATA_HPP__
00015
00016
00017
00018
00019
00020 #include "../packet_handler/payload_base.hpp"
00021 #include "../packet_handler/payload_headers.hpp"
00022
00023
00024
00025
00026
00027 #define MAX_DATA_SIZE (3*8) //derived from ST_GYRO_MAX_DATA_SIZE in firmware
00028
00029
00030
00031
00032
00033 namespace kobuki
00034 {
00035
00036
00037
00038
00039
00040 class ThreeAxisGyro : public packet_handler::payloadBase
00041 {
00042 public:
00043 struct Data {
00044 unsigned char frame_id;
00045 unsigned char followed_data_length;
00046 unsigned short data[MAX_DATA_SIZE];
00047 } data;
00048
00049 virtual ~ThreeAxisGyro() {};
00050
00051 bool serialise(ecl::PushAndPop<unsigned char> & byteStream)
00052 {
00053 if (!(byteStream.size() > 0))
00054 {
00055
00056 return false;
00057 }
00058
00059 unsigned char length = 2 + 2 * data.followed_data_length;
00060 buildBytes(Header::ThreeAxisGyro, byteStream);
00061 buildBytes(length, byteStream);
00062 buildBytes(data.frame_id, byteStream);
00063 buildBytes(data.followed_data_length, byteStream);
00064 for (unsigned int i=0; i<data.followed_data_length; i++)
00065 buildBytes(data.data[i], byteStream);
00066 return true;
00067 }
00068
00069 bool deserialise(ecl::PushAndPop<unsigned char> & byteStream)
00070 {
00071 if (!(byteStream.size() > 0))
00072 {
00073
00074 return false;
00075 }
00076
00077 unsigned char header_id, length;
00078 buildVariable(header_id, byteStream);
00079 buildVariable(length, byteStream);
00080 buildVariable(data.frame_id, byteStream);
00081 buildVariable(data.followed_data_length, byteStream);
00082 for (unsigned int i=0; i<data.followed_data_length; i++)
00083 buildVariable(data.data[i], byteStream);
00084
00085 return true;
00086 }
00087 };
00088
00089 }
00090
00091 #endif
00092