Go to the documentation of this file.00001
00009
00010
00011
00012
00013 #ifndef KOBUKI_CONTROLLER_INFO_HPP__
00014 #define KOBUKI_CONTROLLER_INFO_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 ControllerInfo : public packet_handler::payloadBase
00035 {
00036 public:
00037 ControllerInfo() : packet_handler::payloadBase(false, 13) {};
00038 struct Data {
00039 Data() : type(0), p_gain(100*1000), i_gain(100), d_gain(2*1000) {}
00040 unsigned char type;
00041 unsigned int p_gain;
00042 unsigned int i_gain;
00043 unsigned int d_gain;
00044 } data;
00045
00046 bool serialise(ecl::PushAndPop<unsigned char> & byteStream)
00047 {
00048 buildBytes(Header::ControllerInfo, byteStream);
00049 buildBytes(length, byteStream);
00050 buildBytes(data.type, byteStream);
00051 buildBytes(data.p_gain, byteStream);
00052 buildBytes(data.i_gain, byteStream);
00053 buildBytes(data.d_gain, byteStream);
00054 return true;
00055 }
00056
00057 bool deserialise(ecl::PushAndPop<unsigned char> & byteStream)
00058 {
00059 if (byteStream.size() < length+2)
00060 {
00061
00062 return false;
00063 }
00064
00065 unsigned char header_id, length_packed;
00066 buildVariable(header_id, byteStream);
00067 buildVariable(length_packed, byteStream);
00068 if( header_id != Header::ControllerInfo ) return false;
00069 if( length_packed != length ) return false;
00070
00071 buildVariable(data.type, byteStream);
00072 buildVariable(data.p_gain, byteStream);
00073 buildVariable(data.i_gain, byteStream);
00074 buildVariable(data.d_gain, byteStream);
00075
00076
00077 return constrain();
00078 }
00079
00080 bool constrain()
00081 {
00082 return true;
00083 }
00084
00085 void showMe()
00086 {
00087 }
00088 };
00089
00090 }
00091
00092 #endif