dock_ir.hpp
Go to the documentation of this file.
00001 
00009 /*****************************************************************************
00010 ** Preprocessor
00011 *****************************************************************************/
00012 
00013 #ifndef KOBUKI_DOCK_IR_DATA_HPP__
00014 #define KOBUKI_DOCK_IR_DATA_HPP__
00015 
00016 /*****************************************************************************
00017 ** Include
00018 *****************************************************************************/
00019 
00020 #include "../packet_handler/payload_base.hpp"
00021 #include "../packet_handler/payload_headers.hpp"
00022 
00023 /*****************************************************************************
00024 ** Namespace
00025 *****************************************************************************/
00026 
00027 namespace kobuki
00028 {
00029 
00030 /*****************************************************************************
00031 ** Interface
00032 *****************************************************************************/
00033 
00034 class DockIR : public packet_handler::payloadBase
00035 {
00036 public:
00037   DockIR() : packet_handler::payloadBase(false, 3) {};
00038   struct Data {
00039     Data() : docking(3) {}
00040     std::vector<uint8_t> docking;
00041   } data;
00042 
00043   bool serialise(ecl::PushAndPop<unsigned char> & byteStream)
00044   {
00045     buildBytes(Header::DockInfraRed, byteStream);
00046     buildBytes(length, byteStream);
00047     buildBytes(data.docking[0], byteStream);
00048     buildBytes(data.docking[1], byteStream);
00049     buildBytes(data.docking[2], byteStream);
00050     return true;
00051   }
00052 
00053   bool deserialise(ecl::PushAndPop<unsigned char> & byteStream)
00054   {
00055     if (byteStream.size() < length+2)
00056     {
00057       //std::cout << "kobuki_node: kobuki_dock_ir: deserialise failed. not enough byte stream." << std::endl;
00058       return false;
00059     }
00060 
00061     unsigned char header_id, length_packed;
00062     buildVariable(header_id, byteStream);
00063     buildVariable(length_packed, byteStream);
00064     if( header_id != Header::DockInfraRed ) return false;
00065     if( length_packed != length ) return false;
00066 
00067     buildVariable(data.docking[0], byteStream);
00068     buildVariable(data.docking[1], byteStream);
00069     buildVariable(data.docking[2], byteStream);
00070 
00071     //showMe();
00072     return constrain();
00073   }
00074 
00075   bool constrain()
00076   {
00077     return true;
00078   }
00079 
00080   void showMe()
00081   {
00082     //printf("--[%02x || %03d | %03d | %03d]\n", data.bump, docking[2], docking[1], docking[0] );
00083   }
00084 };
00085 
00086 } // namespace kobuki
00087 
00088 #endif /* KOBUKI_IR_DATA_HPP__ */


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Thu Jun 6 2019 20:24:37