current.hpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Preprocessor
11 *****************************************************************************/
12 
13 #ifndef KOBUKI_CURRENT_DATA_HPP__
14 #define KOBUKI_CURRENT_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 *****************************************************************************/
40 {
41 public:
42  Current() : packet_handler::payloadBase(false, 2) {};
43  struct Data {
44  Data() : current(2) {}
45  std::vector<uint8_t> current;
46  } data;
47 
49  {
50  buildBytes(Header::Current, byteStream);
51  buildBytes(length, byteStream);
52  buildBytes(data.current[0], byteStream);
53  buildBytes(data.current[1], byteStream);
54  return true;
55  }
56 
58  {
59  if (byteStream.size() < length+2)
60  {
61  //std::cout << "kobuki_node: kobuki_current: deserialise failed. not enough byte stream." << std::endl;
62  return false;
63  }
64 
65  unsigned char header_id, length_packed;
66  buildVariable(header_id, byteStream);
67  buildVariable(length_packed, byteStream);
68  if( header_id != Header::Current ) return false;
69  if( length_packed != length ) return false;
70 
71  buildVariable(data.current[0], byteStream);
72  buildVariable(data.current[1], byteStream);
73 
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, current[2], current[1], current[0] );
85  }
86 };
87 
88 } // namespace kobuki
89 
90 #endif /* KOBUKI_CURRENT_DATA_HPP__ */
unsigned int size() const
std::vector< uint8_t > current
Definition: current.hpp:45
bool constrain()
Definition: current.hpp:77
struct kobuki::Current::Data data
const unsigned char length
bool serialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: current.hpp:48
Provides base class for payloads.
payloadBase(const bool is_dynamic_=false, const unsigned char length_=0)
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: current.hpp:57
void buildVariable(T &V, ecl::PushAndPop< unsigned char > &buffer)
void buildBytes(const T &V, ecl::PushAndPop< unsigned char > &buffer)
void showMe()
Definition: current.hpp:82


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