inertia.hpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Preprocessor
11 *****************************************************************************/
12 
13 #ifndef KOBUKI_INERTIA_DATA_HPP__
14 #define KOBUKI_INERTIA_DATA_HPP__
15 
16 /*****************************************************************************
17 ** Includes
18 *****************************************************************************/
19 
20 #include "../packet_handler/payload_base.hpp"
21 #include "../packet_handler/payload_headers.hpp"
22 
23 /*****************************************************************************
24 ** Namespaces
25 *****************************************************************************/
26 
27 namespace kobuki
28 {
29 
30 /*****************************************************************************
31 ** Interface
32 *****************************************************************************/
33 
34 class Inertia : public packet_handler::payloadBase
35 {
36 public:
37  Inertia() : packet_handler::payloadBase(false, 7) {};
38  struct Data {
39  int16_t angle;
40  int16_t angle_rate;
41  unsigned char acc[3];
42  } data;
43 
44  virtual ~Inertia() {};
45 
46  bool serialise(ecl::PushAndPop<unsigned char> & byteStream)
47  {
48  buildBytes(Header::Inertia, byteStream);
49  buildBytes(length, byteStream);
50  buildBytes(data.angle, byteStream);
51  buildBytes(data.angle_rate, byteStream);
52  buildBytes(data.acc[0], byteStream);
53  buildBytes(data.acc[1], byteStream);
54  buildBytes(data.acc[2], byteStream);
55  return true;
56  }
57 
59  {
60  if (byteStream.size() < length+2)
61  {
62  //std::cout << "kobuki_node: kobuki_inertia: deserialise failed. not enough byte stream." << std::endl;
63  return false;
64  }
65 
66  unsigned char header_id, length_packed;
67  buildVariable(header_id, byteStream);
68  buildVariable(length_packed, byteStream);
69  if( header_id != Header::Inertia ) return false;
70  if( length_packed != length ) return false;
71 
72  buildVariable(data.angle, byteStream);
73  buildVariable(data.angle_rate, byteStream);
74  buildVariable(data.acc[0], byteStream);
75  buildVariable(data.acc[1], byteStream);
76  buildVariable(data.acc[2], byteStream);
77 
78  //showMe();
79  return constrain();
80  }
81 
82  bool constrain()
83  {
84  return true;
85  }
86 
87  void showMe()
88  {
89  }
90 };
91 
92 } // namespace kobuki
93 
94 #endif /* KOBUKI_INERTIA_DATA_HPP__ */
95 
kobuki::Inertia::deserialise
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: inertia.hpp:72
kobuki::Inertia::Inertia
Inertia()
Definition: inertia.hpp:51
packet_handler::payloadBase::length
const unsigned char length
Definition: payload_base.hpp:73
kobuki
Definition: command.hpp:31
kobuki::Inertia::constrain
bool constrain()
Definition: inertia.hpp:96
kobuki::Inertia::serialise
bool serialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: inertia.hpp:60
kobuki::Inertia::showMe
void showMe()
Definition: inertia.hpp:101
packet_handler::payloadBase::payloadBase
payloadBase(const bool is_dynamic_=false, const unsigned char length_=0)
Definition: payload_base.hpp:78
kobuki::Inertia::Data::acc
unsigned char acc[3]
Definition: inertia.hpp:55
packet_handler::payloadBase
Provides base class for payloads.
Definition: payload_base.hpp:44
packet_handler::payloadBase::buildVariable
void buildVariable(T &V, ecl::PushAndPop< unsigned char > &buffer)
Definition: payload_base.hpp:96
kobuki::Header::Inertia
@ Inertia
Definition: payload_headers.hpp:51
kobuki::Inertia::Data::angle_rate
int16_t angle_rate
Definition: inertia.hpp:54
packet_handler::payloadBase::buildBytes
void buildBytes(const T &V, ecl::PushAndPop< unsigned char > &buffer)
Definition: payload_base.hpp:110
kobuki::Inertia::data
struct kobuki::Inertia::Data data
kobuki::Inertia::Data::angle
int16_t angle
Definition: inertia.hpp:53
ecl::PushAndPop< unsigned char >
kobuki::Inertia::~Inertia
virtual ~Inertia()
Definition: inertia.hpp:58
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