core_sensors.hpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Preprocessor
11 *****************************************************************************/
12 
13 #ifndef KOBUKI_CORE_SENSORS_HPP__
14 #define KOBUKI_CORE_SENSORS_HPP__
15 
16 /*****************************************************************************
17 ** Include
18 *****************************************************************************/
19 
20 #include "../packet_handler/payload_base.hpp"
21 #include "../macros.hpp"
22 #include <stdint.h>
23 
24 /*****************************************************************************
25 ** Namespaces
26 *****************************************************************************/
27 
28 namespace kobuki
29 {
30 
31 /*****************************************************************************
32 ** Interface
33 *****************************************************************************/
34 
36 {
37 public:
38  CoreSensors() : packet_handler::payloadBase(false, 15) {};
39 
40  struct Data {
41  uint16_t time_stamp;
42  uint8_t bumper;
43  uint8_t wheel_drop;
44  uint8_t cliff;
45  uint16_t left_encoder;
46  uint16_t right_encoder;
47  char left_pwm;
48  char right_pwm;
49  uint8_t buttons;
50  uint8_t charger;
51  uint8_t battery;
52  uint8_t over_current;
53  } data;
54 
55  struct Flags {
56  // buttons
57  static const uint8_t Button0 = 0x01;
58  static const uint8_t Button1 = 0x02;
59  static const uint8_t Button2 = 0x04;
60 
61  // bumper
62  static const uint8_t LeftBumper = 0x04;
63  static const uint8_t CenterBumper = 0x02;
64  static const uint8_t RightBumper = 0x01;
65 
66  // cliff sensor
67  static const uint8_t LeftCliff = 0x04;
68  static const uint8_t CenterCliff = 0x02;
69  static const uint8_t RightCliff = 0x01;
70 
71  // wheel drop sensor
72  static const uint8_t LeftWheel = 0x02;
73  static const uint8_t RightWheel = 0x01;
74 
75  // Charging source
76  // - first four bits distinguish between adapter or docking base charging
77  static const uint8_t AdapterType = 0x10;
78  // - last 4 bits specified the charging status (see Battery.hpp for details)
79  static const uint8_t BatteryStateMask = 0x0F;
80  static const uint8_t Discharging = 0x00;
81  static const uint8_t Charged = 0x02;
82  static const uint8_t Charging = 0x06;
83 
84  // wheel drop sensor
85  static const uint8_t LeftWheel_OC = 0x01;
86  static const uint8_t RightWheel_OC = 0x02;
87 
88  };
89 
90  bool serialise(ecl::PushAndPop<unsigned char> & byteStream);
91  bool deserialise(ecl::PushAndPop<unsigned char> & byteStream);
92 };
93 
94 } // namespace kobuki
95 
96 #endif /* KOBUKI_CORE_SENSORS_HPP__ */
Provides base class for payloads.
#define kobuki_PUBLIC
Definition: macros.hpp:39


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Fri Sep 18 2020 03:22:01