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


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