controller_info.hpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Preprocessor
11 *****************************************************************************/
12 
13 #ifndef KOBUKI_CONTROLLER_INFO_HPP__
14 #define KOBUKI_CONTROLLER_INFO_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 
35 {
36 public:
38  struct Data {
39  Data() : type(0), p_gain(100*1000), i_gain(100), d_gain(2*1000) {}
40  unsigned char type;
41  unsigned int p_gain; //default value: 100 * 1000
42  unsigned int i_gain; //default value: 0.1 * 1000
43  unsigned int d_gain; //default value: 2 * 1000
44  } data;
45 
47  {
49  buildBytes(length, byteStream);
50  buildBytes(data.type, byteStream);
51  buildBytes(data.p_gain, byteStream);
52  buildBytes(data.i_gain, byteStream);
53  buildBytes(data.d_gain, byteStream);
54  return true;
55  }
56 
58  {
59  if (byteStream.size() < length+2)
60  {
61  //std::cout << "kobuki_node: kobuki_controller_info: 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::ControllerInfo ) return false;
69  if( length_packed != length ) return false;
70 
71  buildVariable(data.type, byteStream);
72  buildVariable(data.p_gain, byteStream);
73  buildVariable(data.i_gain, byteStream);
74  buildVariable(data.d_gain, byteStream);
75 
76  //showMe();
77  return constrain();
78  }
79 
80  bool constrain()
81  {
82  return true;
83  }
84 
85  void showMe()
86  {
87  }
88 };
89 
90 } // namespace kobuki
91 
92 #endif /* KOBUKI_CONTROLLER_INFO_HPP__ */
bool serialise(ecl::PushAndPop< unsigned char > &byteStream)
unsigned int size() const
struct kobuki::ControllerInfo::Data data
const unsigned char length
Provides base class for payloads.
payloadBase(const bool is_dynamic_=false, const unsigned char length_=0)
void buildVariable(T &V, ecl::PushAndPop< unsigned char > &buffer)
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
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