.. _program_listing_file__tmp_ws_src_kobuki_core_include_kobuki_core_packets_cliff.hpp: Program Listing for File cliff.hpp ================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/kobuki_core/include/kobuki_core/packets/cliff.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /***************************************************************************** ** Preprocessor *****************************************************************************/ #ifndef KOBUKI_CORE_CLIFF_DATA_HPP__ #define KOBUKI_CORE_CLIFF_DATA_HPP__ /***************************************************************************** ** Include *****************************************************************************/ #include #include "../packet_handler/payload_base.hpp" #include "../packet_handler/payload_headers.hpp" /***************************************************************************** ** Namespace *****************************************************************************/ namespace kobuki { /***************************************************************************** ** Interface *****************************************************************************/ class Cliff : public packet_handler::payloadBase { public: Cliff() : packet_handler::payloadBase(false, 6) {}; struct Data { Data() : bottom(3) {} std::vector bottom; } data; bool serialise(ecl::PushAndPop & byteStream) { buildBytes((unsigned char)Header::Cliff, byteStream); buildBytes(length, byteStream); buildBytes(data.bottom[0], byteStream); buildBytes(data.bottom[1], byteStream); buildBytes(data.bottom[2], byteStream); return true; } bool deserialise(ecl::PushAndPop & byteStream) { if (byteStream.size() < static_cast(length)+2) { //std::cout << "kobuki_node: kobuki_cliff: deserialise failed. not enough byte stream." << std::endl; return false; } unsigned char header_id(0x00), length_packed(0x00); buildVariable(header_id, byteStream); buildVariable(length_packed, byteStream); if( header_id != Header::Cliff ) return false; if( length_packed != length ) return false; buildVariable(data.bottom[0], byteStream); buildVariable(data.bottom[1], byteStream); buildVariable(data.bottom[2], byteStream); //showMe(); return constrain(); } bool constrain() { return true; } void showMe() { //printf("--[%02x || %03d | %03d | %03d]\n", data.bump, bottom[2], bottom[1], bottom[0] ); } }; } // namespace kobuki #endif /* KOBUKI_CORE_IR_DATA_HPP__ */