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 
34 class ControllerInfo : public packet_handler::payloadBase
35 {
36 public:
37  ControllerInfo() : packet_handler::payloadBase(false, 13) {};
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 
46  bool serialise(ecl::PushAndPop<unsigned char> & byteStream)
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__ */
kobuki::ControllerInfo::Data::p_gain
unsigned int p_gain
Definition: controller_info.hpp:55
kobuki::ControllerInfo::ControllerInfo
ControllerInfo()
Definition: controller_info.hpp:51
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::ControllerInfo::Data::i_gain
unsigned int i_gain
Definition: controller_info.hpp:56
kobuki::ControllerInfo::constrain
bool constrain()
Definition: controller_info.hpp:94
packet_handler::payloadBase
Provides base class for payloads.
Definition: payload_base.hpp:44
kobuki::Header::ControllerInfo
@ ControllerInfo
Definition: payload_headers.hpp:56
kobuki::ControllerInfo::Data::d_gain
unsigned int d_gain
Definition: controller_info.hpp:57
kobuki::ControllerInfo::Data::type
unsigned char type
Definition: controller_info.hpp:54
kobuki::ControllerInfo::data
struct kobuki::ControllerInfo::Data data
packet_handler::payloadBase::buildVariable
void buildVariable(T &V, ecl::PushAndPop< unsigned char > &buffer)
Definition: payload_base.hpp:96
kobuki::ControllerInfo::deserialise
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: controller_info.hpp:71
packet_handler::payloadBase::buildBytes
void buildBytes(const T &V, ecl::PushAndPop< unsigned char > &buffer)
Definition: payload_base.hpp:110
kobuki::ControllerInfo::showMe
void showMe()
Definition: controller_info.hpp:99
ecl::PushAndPop< unsigned char >
kobuki::ControllerInfo::serialise
bool serialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: controller_info.hpp:60
packet_handler
Definition: payload_base.hpp:27
ecl::PushAndPop::size
unsigned int size() const
kobuki::ControllerInfo::Data::Data
Data()
Definition: controller_info.hpp:53


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Wed Mar 2 2022 00:26:14