Kobuki 1.0.0
C++ API for the Kobuki research robot
Loading...
Searching...
No Matches
current.hpp
Go to the documentation of this file.
1
9/*****************************************************************************
10** Preprocessor
11*****************************************************************************/
12
13#ifndef KOBUKI_CORE_CURRENT_DATA_HPP__
14#define KOBUKI_CORE_CURRENT_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*****************************************************************************/
40{
41public:
42 Current() : packet_handler::payloadBase(false, 2) {};
43 struct Data {
44 Data() : current(2) {}
45 std::vector<uint8_t> current;
46 } data;
47
48 bool serialise(ecl::PushAndPop<unsigned char> & byteStream)
49 {
50 buildBytes(Header::Current, byteStream);
51 buildBytes(length, byteStream);
52 buildBytes(data.current[0], byteStream);
53 buildBytes(data.current[1], byteStream);
54 return true;
55 }
56
57 bool deserialise(ecl::PushAndPop<unsigned char> & byteStream)
58 {
59 if (byteStream.size() < static_cast<unsigned int>(length)+2)
60 {
61 //std::cout << "kobuki_node: kobuki_current: deserialise failed. not enough byte stream." << std::endl;
62 return false;
63 }
64
65 unsigned char header_id(0x00), length_packed(0x00);
66 buildVariable(header_id, byteStream);
67 buildVariable(length_packed, byteStream);
68 if( header_id != Header::Current ) return false;
69 if( length_packed != length ) return false;
70
71 buildVariable(data.current[0], byteStream);
72 buildVariable(data.current[1], byteStream);
73
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, current[2], current[1], current[0] );
85 }
86};
87
88} // namespace kobuki
89
90#endif /* KOBUKI_CORE_CURRENT_DATA_HPP__ */
Definition current.hpp:40
Provides base class for payloads.
Definition payload_base.hpp:39
const unsigned char length
Definition payload_base.hpp:59
Definition current.hpp:43