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 
34 class DockIR : public packet_handler::payloadBase
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 
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 
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__ */
kobuki::DockIR::showMe
void showMe()
Definition: dock_ir.hpp:94
packet_handler::payloadBase::length
const unsigned char length
Definition: payload_base.hpp:73
kobuki::DockIR::deserialise
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: dock_ir.hpp:67
kobuki
Definition: command.hpp:31
packet_handler::payloadBase::payloadBase
payloadBase(const bool is_dynamic_=false, const unsigned char length_=0)
Definition: payload_base.hpp:78
kobuki::DockIR::constrain
bool constrain()
Definition: dock_ir.hpp:89
kobuki::DockIR::serialise
bool serialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: dock_ir.hpp:57
kobuki::Header::DockInfraRed
@ DockInfraRed
Definition: payload_headers.hpp:51
kobuki::DockIR::Data::docking
std::vector< uint8_t > docking
Definition: dock_ir.hpp:54
packet_handler::payloadBase
Provides base class for payloads.
Definition: payload_base.hpp:44
packet_handler::payloadBase::buildVariable
void buildVariable(T &V, ecl::PushAndPop< unsigned char > &buffer)
Definition: payload_base.hpp:96
kobuki::DockIR::data
struct kobuki::DockIR::Data data
kobuki::DockIR::DockIR
DockIR()
Definition: dock_ir.hpp:51
packet_handler::payloadBase::buildBytes
void buildBytes(const T &V, ecl::PushAndPop< unsigned char > &buffer)
Definition: payload_base.hpp:110
ecl::PushAndPop< unsigned char >
kobuki::DockIR::Data::Data
Data()
Definition: dock_ir.hpp:53
packet_handler
Definition: payload_base.hpp:27
ecl::PushAndPop::size
unsigned int size() const


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Wed Mar 2 2022 00:26:14