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 *****************************************************************************/
39 class Current : public packet_handler::payloadBase
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 
48  bool serialise(ecl::PushAndPop<unsigned char> & byteStream)
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__ */
kobuki::Current::constrain
bool constrain()
Definition: current.hpp:91
packet_handler::payloadBase::length
const unsigned char length
Definition: payload_base.hpp:73
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::Current::Current
Current()
Definition: current.hpp:56
packet_handler::payloadBase
Provides base class for payloads.
Definition: payload_base.hpp:44
kobuki::Current::showMe
void showMe()
Definition: current.hpp:96
kobuki::Current::Data::current
std::vector< uint8_t > current
Definition: current.hpp:59
kobuki::Current::serialise
bool serialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: current.hpp:62
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::Current::data
struct kobuki::Current::Data data
ecl::PushAndPop< unsigned char >
kobuki::Header::Current
@ Current
Definition: payload_headers.hpp:51
kobuki::Current::Data::Data
Data()
Definition: current.hpp:58
kobuki::Current::deserialise
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: current.hpp:71
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