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   struct Data {
00038     Data() : docking(3) {}
00039     std::vector<uint8_t> docking;
00040   } data;
00041 
00042   bool serialise(ecl::PushAndPop<unsigned char> & byteStream)
00043   {
00044     if (!(byteStream.size() > 0))
00045     {
00046       printf("kobuki_node: kobuki_dock_ir: serialise failed. empty byte stream.");
00047       return false;
00048     }
00049 
00050     unsigned char length = 3;
00051     buildBytes(Header::DockInfraRed, byteStream);
00052     buildBytes(length, byteStream);
00053     buildBytes(data.docking[0], byteStream);
00054     buildBytes(data.docking[1], byteStream);
00055     buildBytes(data.docking[2], byteStream);
00056     return true;
00057   }
00058 
00059   bool deserialise(ecl::PushAndPop<unsigned char> & byteStream)
00060   {
00061     if (!(byteStream.size() > 0))
00062     {
00063       printf("kobuki_node: kobuki_dock_ir: deserialise failed. empty byte stream.");
00064       return false;
00065     }
00066 
00067     unsigned char header_id, length;
00068     buildVariable(header_id, byteStream);
00069     buildVariable(length, byteStream);
00070     buildVariable(data.docking[0], byteStream);
00071     buildVariable(data.docking[1], byteStream);
00072     buildVariable(data.docking[2], byteStream);
00073 
00074     //showMe();
00075     return constrain();
00076   }
00077 
00078   bool constrain()
00079   {
00080     return true;
00081   }
00082 
00083   void showMe()
00084   {
00085     //printf("--[%02x || %03d | %03d | %03d]\n", data.bump, docking[2], docking[1], docking[0] );
00086   }
00087 };
00088 
00089 } // namespace kobuki
00090 
00091 #endif /* KOBUKI_IR_DATA_HPP__ */


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Mon Oct 6 2014 01:31:09