Go to the documentation of this file.00001
00009
00010
00011
00012
00013 #ifndef KOBUKI_INERTIA_DATA_HPP__
00014 #define KOBUKI_INERTIA_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 namespace kobuki
00028 {
00029
00030
00031
00032
00033
00034 class Inertia : public packet_handler::payloadBase
00035 {
00036 public:
00037 struct Data {
00038 int16_t angle;
00039 int16_t angle_rate;
00040 unsigned char acc[3];
00041 } data;
00042
00043 virtual ~Inertia() {};
00044
00045 bool serialise(ecl::PushAndPop<unsigned char> & byteStream)
00046 {
00047 if (!(byteStream.size() > 0))
00048 {
00049
00050 return false;
00051 }
00052
00053 unsigned char length = 7;
00054 buildBytes(Header::Inertia, byteStream);
00055 buildBytes(length, byteStream);
00056 buildBytes(data.angle, byteStream);
00057 buildBytes(data.angle_rate, byteStream);
00058 buildBytes(data.acc[0], byteStream);
00059 buildBytes(data.acc[1], byteStream);
00060 buildBytes(data.acc[2], byteStream);
00061 return true;
00062 }
00063
00064 bool deserialise(ecl::PushAndPop<unsigned char> & byteStream)
00065 {
00066 if (!(byteStream.size() > 0))
00067 {
00068
00069 return false;
00070 }
00071
00072 unsigned char header_id, length;
00073 buildVariable(header_id, byteStream);
00074 buildVariable(length, byteStream);
00075 buildVariable(data.angle, byteStream);
00076 buildVariable(data.angle_rate, byteStream);
00077 buildVariable(data.acc[0], byteStream);
00078 buildVariable(data.acc[1], byteStream);
00079 buildVariable(data.acc[2], byteStream);
00080
00081 return true;
00082 }
00083 };
00084
00085 }
00086
00087 #endif
00088