cliff.hpp
Go to the documentation of this file.
00001 
00009 /*****************************************************************************
00010 ** Preprocessor
00011 *****************************************************************************/
00012 
00013 #ifndef KOBUKI_CLIFF_DATA_HPP__
00014 #define KOBUKI_CLIFF_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 *****************************************************************************/
00034 
00035 class Cliff : public packet_handler::payloadBase
00036 {
00037 public:
00038   Cliff() : packet_handler::payloadBase(false, 6) {};
00039 
00040   struct Data {
00041     Data() : bottom(3) {}
00042     std::vector<uint16_t> bottom;
00043   } data;
00044 
00045   bool serialise(ecl::PushAndPop<unsigned char> & byteStream)
00046   {
00047     buildBytes((unsigned char)Header::Cliff, byteStream);
00048     buildBytes(length, byteStream);
00049     buildBytes(data.bottom[0], byteStream);
00050     buildBytes(data.bottom[1], byteStream);
00051     buildBytes(data.bottom[2], byteStream);
00052     return true;
00053   }
00054 
00055   bool deserialise(ecl::PushAndPop<unsigned char> & byteStream)
00056   {
00057     if (byteStream.size() < length+2)
00058     {
00059       //std::cout << "kobuki_node: kobuki_cliff: deserialise failed. not enough byte stream." << std::endl;
00060       return false;
00061     }
00062 
00063     unsigned char header_id, length_packed;
00064     buildVariable(header_id, byteStream);
00065     buildVariable(length_packed, byteStream);
00066     if( header_id != Header::Cliff ) return false;
00067     if( length_packed != length ) return false;
00068 
00069     buildVariable(data.bottom[0], byteStream);
00070     buildVariable(data.bottom[1], byteStream);
00071     buildVariable(data.bottom[2], byteStream);
00072 
00073     //showMe();
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, bottom[2], bottom[1], bottom[0] );
00085   }
00086 };
00087 
00088 } // namespace kobuki
00089 
00090 #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