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