dock_ir.hpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Preprocessor
11 *****************************************************************************/
12 
13 #ifndef KOBUKI_DOCK_IR_DATA_HPP__
14 #define KOBUKI_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 
27 namespace kobuki
28 {
29 
30 /*****************************************************************************
31 ** Interface
32 *****************************************************************************/
33 
35 {
36 public:
37  DockIR() : packet_handler::payloadBase(false, 3) {};
38  struct Data {
39  Data() : docking(3) {}
40  std::vector<uint8_t> docking;
41  } data;
42 
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 
54  {
55  if (byteStream.size() < 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, length_packed;
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_IR_DATA_HPP__ */
unsigned int size() const
std::vector< uint8_t > docking
Definition: dock_ir.hpp:40
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: dock_ir.hpp:53
const unsigned char length
void showMe()
Definition: dock_ir.hpp:80
Provides base class for payloads.
payloadBase(const bool is_dynamic_=false, const unsigned char length_=0)
bool serialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: dock_ir.hpp:43
void buildVariable(T &V, ecl::PushAndPop< unsigned char > &buffer)
void buildBytes(const T &V, ecl::PushAndPop< unsigned char > &buffer)
struct kobuki::DockIR::Data data
bool constrain()
Definition: dock_ir.hpp:75


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Fri Sep 18 2020 03:22:01