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
packet_handler::payloadBase::length
const unsigned char length
Definition: payload_base.hpp:73
kobuki::CoreSensors::Data::charger
uint8_t charger
Definition: core_sensors.hpp:64
kobuki::CoreSensors::Data::left_pwm
char left_pwm
Definition: core_sensors.hpp:61
kobuki
Definition: command.hpp:31
kobuki::CoreSensors::Data::bumper
uint8_t bumper
Definition: core_sensors.hpp:56
kobuki::CoreSensors::serialise
bool serialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: core_sensors.cpp:31
kobuki::CoreSensors::Data::buttons
uint8_t buttons
Definition: core_sensors.hpp:63
kobuki::CoreSensors::data
struct kobuki::CoreSensors::Data data
kobuki::CoreSensors::Data::battery
uint8_t battery
Definition: core_sensors.hpp:65
kobuki::CoreSensors::Data::left_encoder
uint16_t left_encoder
Definition: core_sensors.hpp:59
kobuki::Header::CoreSensors
@ CoreSensors
Definition: payload_headers.hpp:51
kobuki::CoreSensors::Data::right_pwm
char right_pwm
Definition: core_sensors.hpp:62
packet_handler::payloadBase::buildVariable
void buildVariable(T &V, ecl::PushAndPop< unsigned char > &buffer)
Definition: payload_base.hpp:96
packet_handler::payloadBase::buildBytes
void buildBytes(const T &V, ecl::PushAndPop< unsigned char > &buffer)
Definition: payload_base.hpp:110
kobuki::CoreSensors::Data::right_encoder
uint16_t right_encoder
Definition: core_sensors.hpp:60
ecl::PushAndPop< unsigned char >
kobuki::CoreSensors::Data::over_current
uint8_t over_current
Definition: core_sensors.hpp:66
kobuki::CoreSensors::Data::wheel_drop
uint8_t wheel_drop
Definition: core_sensors.hpp:57
kobuki::CoreSensors::Data::cliff
uint8_t cliff
Definition: core_sensors.hpp:58
kobuki::CoreSensors::Data::time_stamp
uint16_t time_stamp
Definition: core_sensors.hpp:55
ecl::PushAndPop::size
unsigned int size() const
kobuki::CoreSensors::deserialise
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: core_sensors.cpp:50


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