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 
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 
58  bool deserialise(ecl::PushAndPop<unsigned char> & byteStream)
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 
unsigned char acc[3]
Definition: inertia.hpp:41
const unsigned char length
struct kobuki::Inertia::Data data
void showMe()
Definition: inertia.hpp:87
Provides base class for payloads.
virtual ~Inertia()
Definition: inertia.hpp:44
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: inertia.hpp:58
payloadBase(const bool is_dynamic_=false, const unsigned char length_=0)
void buildVariable(T &V, ecl::PushAndPop< unsigned char > &buffer)
void buildBytes(const T &V, ecl::PushAndPop< unsigned char > &buffer)
bool constrain()
Definition: inertia.hpp:82
bool serialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: inertia.hpp:46


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Mon Mar 27 2017 01:02:59