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 
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 
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__ */
struct kobuki::Cliff::Data data
bool serialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: cliff.hpp:45
unsigned int size() const
const unsigned char length
std::vector< uint16_t > bottom
Definition: cliff.hpp:42
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: cliff.hpp:55
Provides base class for payloads.
payloadBase(const bool is_dynamic_=false, const unsigned char length_=0)
void showMe()
Definition: cliff.hpp:82
void buildVariable(T &V, ecl::PushAndPop< unsigned char > &buffer)
bool constrain()
Definition: cliff.hpp:77
void buildBytes(const T &V, ecl::PushAndPop< unsigned char > &buffer)


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