Kobuki 1.0.0
C++ API for the Kobuki research robot
Loading...
Searching...
No Matches
cliff.hpp
Go to the documentation of this file.
1
9/*****************************************************************************
10** Preprocessor
11*****************************************************************************/
12
13#ifndef KOBUKI_CORE_CLIFF_DATA_HPP__
14#define KOBUKI_CORE_CLIFF_DATA_HPP__
15
16/*****************************************************************************
17** Include
18*****************************************************************************/
19
20#include <vector>
21#include "../packet_handler/payload_base.hpp"
22#include "../packet_handler/payload_headers.hpp"
23
24/*****************************************************************************
25** Namespace
26*****************************************************************************/
27
28namespace kobuki
29{
30
31/*****************************************************************************
32** Interface
33*****************************************************************************/
34
36{
37public:
38 Cliff() : packet_handler::payloadBase(false, 6) {};
39
40 struct Data {
41 Data() : bottom(3) {}
42 std::vector<uint16_t> bottom;
43 } data;
44
45 bool serialise(ecl::PushAndPop<unsigned char> & byteStream)
46 {
47 buildBytes((unsigned char)Header::Cliff, byteStream);
48 buildBytes(length, byteStream);
49 buildBytes(data.bottom[0], byteStream);
50 buildBytes(data.bottom[1], byteStream);
51 buildBytes(data.bottom[2], byteStream);
52 return true;
53 }
54
55 bool deserialise(ecl::PushAndPop<unsigned char> & byteStream)
56 {
57 if (byteStream.size() < static_cast<unsigned int>(length)+2)
58 {
59 //std::cout << "kobuki_node: kobuki_cliff: deserialise failed. not enough byte stream." << std::endl;
60 return false;
61 }
62
63 unsigned char header_id(0x00), length_packed(0x00);
64 buildVariable(header_id, byteStream);
65 buildVariable(length_packed, byteStream);
66 if( header_id != Header::Cliff ) return false;
67 if( length_packed != length ) return false;
68
69 buildVariable(data.bottom[0], byteStream);
70 buildVariable(data.bottom[1], byteStream);
71 buildVariable(data.bottom[2], byteStream);
72
73 //showMe();
74 return constrain();
75 }
76
77 bool constrain()
78 {
79 return true;
80 }
81
82 void showMe()
83 {
84 //printf("--[%02x || %03d | %03d | %03d]\n", data.bump, bottom[2], bottom[1], bottom[0] );
85 }
86};
87
88} // namespace kobuki
89
90#endif /* KOBUKI_CORE_IR_DATA_HPP__ */
Definition cliff.hpp:36
Provides base class for payloads.
Definition payload_base.hpp:39
const unsigned char length
Definition payload_base.hpp:59
Definition cliff.hpp:40