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   Current() : packet_handler::payloadBase(false, 2) {};
00043   struct Data {
00044     Data() : current(2) {}
00045     std::vector<uint8_t> current;
00046   } data;
00047 
00048   bool serialise(ecl::PushAndPop<unsigned char> & byteStream)
00049   {
00050     buildBytes(Header::Current, byteStream);
00051     buildBytes(length, byteStream);
00052     buildBytes(data.current[0], byteStream);
00053     buildBytes(data.current[1], byteStream);
00054     return true;
00055   }
00056 
00057   bool deserialise(ecl::PushAndPop<unsigned char> & byteStream)
00058   {
00059     if (byteStream.size() < length+2)
00060     {
00061       //std::cout << "kobuki_node: kobuki_current: deserialise failed. not enough byte stream." << std::endl;
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::Current ) return false;
00069     if( length_packed != length ) return false;
00070 
00071     buildVariable(data.current[0], byteStream);
00072     buildVariable(data.current[1], byteStream);
00073 
00074     return constrain();
00075   }
00076 
00077   bool constrain()
00078   {
00079     return true;
00080   }
00081 
00082   void showMe()
00083   {
00084     //printf("--[%02x || %03d | %03d | %03d]\n", data.bump, current[2], current[1], current[0] );
00085   }
00086 };
00087 
00088 } // namespace kobuki
00089 
00090 #endif /* KOBUKI_CURRENT_DATA_HPP__ */


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Thu Aug 27 2015 13:43:57