cliff.hpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Preprocessor
11 *****************************************************************************/
12 
13 #ifndef KOBUKI_CLIFF_DATA_HPP__
14 #define KOBUKI_CLIFF_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 
28 namespace kobuki
29 {
30 
31 /*****************************************************************************
32 ** Interface
33 *****************************************************************************/
34 
35 class Cliff : public packet_handler::payloadBase
36 {
37 public:
38  Cliff() : packet_handler::payloadBase(false, 6) {};
39 
40  struct Data {
41  Data() : bottom(3) {}
42  std::vector<uint16_t> bottom;
43  } data;
44 
45  bool serialise(ecl::PushAndPop<unsigned char> & byteStream)
46  {
47  buildBytes((unsigned char)Header::Cliff, byteStream);
48  buildBytes(length, byteStream);
49  buildBytes(data.bottom[0], byteStream);
50  buildBytes(data.bottom[1], byteStream);
51  buildBytes(data.bottom[2], byteStream);
52  return true;
53  }
54 
56  {
57  if (byteStream.size() < length+2)
58  {
59  //std::cout << "kobuki_node: kobuki_cliff: deserialise failed. not enough byte stream." << std::endl;
60  return false;
61  }
62 
63  unsigned char header_id, length_packed;
64  buildVariable(header_id, byteStream);
65  buildVariable(length_packed, byteStream);
66  if( header_id != Header::Cliff ) return false;
67  if( length_packed != length ) return false;
68 
69  buildVariable(data.bottom[0], byteStream);
70  buildVariable(data.bottom[1], byteStream);
71  buildVariable(data.bottom[2], byteStream);
72 
73  //showMe();
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, bottom[2], bottom[1], bottom[0] );
85  }
86 };
87 
88 } // namespace kobuki
89 
90 #endif /* KOBUKI_IR_DATA_HPP__ */
packet_handler::payloadBase::length
const unsigned char length
Definition: payload_base.hpp:73
kobuki::Cliff::Cliff
Cliff()
Definition: cliff.hpp:52
kobuki
Definition: command.hpp:31
kobuki::Cliff::Data::bottom
std::vector< uint16_t > bottom
Definition: cliff.hpp:56
packet_handler::payloadBase::payloadBase
payloadBase(const bool is_dynamic_=false, const unsigned char length_=0)
Definition: payload_base.hpp:78
kobuki::Cliff::serialise
bool serialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: cliff.hpp:59
packet_handler::payloadBase
Provides base class for payloads.
Definition: payload_base.hpp:44
kobuki::Cliff::constrain
bool constrain()
Definition: cliff.hpp:91
kobuki::Cliff::showMe
void showMe()
Definition: cliff.hpp:96
packet_handler::payloadBase::buildVariable
void buildVariable(T &V, ecl::PushAndPop< unsigned char > &buffer)
Definition: payload_base.hpp:96
packet_handler::payloadBase::buildBytes
void buildBytes(const T &V, ecl::PushAndPop< unsigned char > &buffer)
Definition: payload_base.hpp:110
kobuki::Cliff::Data::Data
Data()
Definition: cliff.hpp:55
kobuki::Cliff::data
struct kobuki::Cliff::Data data
ecl::PushAndPop< unsigned char >
kobuki::Header::Cliff
@ Cliff
Definition: payload_headers.hpp:51
kobuki::Cliff::deserialise
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: cliff.hpp:69
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