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