core_sensors.cpp
Go to the documentation of this file.
1 
10 /*****************************************************************************
11 ** Includes
12 *****************************************************************************/
13 
14 #include "../../include/kobuki_driver/packets/core_sensors.hpp"
15 #include "../../include/kobuki_driver/packet_handler/payload_headers.hpp"
16 
17 /*****************************************************************************
18 ** Namespaces
19 *****************************************************************************/
20 
21 namespace kobuki {
22 
23 /*****************************************************************************
24 ** Implementation
25 *****************************************************************************/
26 
28 {
29  buildBytes(Header::CoreSensors, byteStream);
30  buildBytes(length, byteStream);
31  buildBytes(data.time_stamp, byteStream); //2
32  buildBytes(data.bumper, byteStream); //1
33  buildBytes(data.wheel_drop, byteStream); //1
34  buildBytes(data.cliff, byteStream); //1
35  buildBytes(data.left_encoder, byteStream); //2
36  buildBytes(data.right_encoder, byteStream); //2
37  buildBytes(data.left_pwm, byteStream); //1
38  buildBytes(data.right_pwm, byteStream); //1
39  buildBytes(data.buttons, byteStream); //1
40  buildBytes(data.charger, byteStream); //1
41  buildBytes(data.battery, byteStream); //1
42  buildBytes(data.over_current, byteStream); //1
43 
44  return true;
45 }
47 {
48  if (byteStream.size() < length+2)
49  {
50  //std::cout << "kobuki_node: kobuki_default: deserialise failed. not enough byte stream." << std::endl;
51  return false;
52  }
53 
54  unsigned char header_id, length_packed;
55  buildVariable(header_id, byteStream);
56  buildVariable(length_packed, byteStream);
57  if( header_id != Header::CoreSensors ) return false;
58  if( length_packed != length ) return false;
59 
60  buildVariable(data.time_stamp, byteStream);
61  buildVariable(data.bumper, byteStream);
62  buildVariable(data.wheel_drop, byteStream);
63  buildVariable(data.cliff, byteStream);
64  buildVariable(data.left_encoder, byteStream);
65  buildVariable(data.right_encoder, byteStream);
66  buildVariable(data.left_pwm, byteStream);
67  buildVariable(data.right_pwm, byteStream);
68  buildVariable(data.buttons, byteStream);
69  buildVariable(data.charger, byteStream);
70  buildVariable(data.battery, byteStream);
71  buildVariable(data.over_current, byteStream);
72 
73  return true;
74 }
75 
76 
77 
78 } // namespace kobuki
bool serialise(ecl::PushAndPop< unsigned char > &byteStream)
unsigned int size() const
struct kobuki::CoreSensors::Data data
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
const unsigned char length
void buildVariable(T &V, ecl::PushAndPop< unsigned char > &buffer)
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