core_sensors.hpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Preprocessor
11 *****************************************************************************/
12 
13 #ifndef XBOT_CORE_SENSORS_HPP__
14 #define XBOT_CORE_SENSORS_HPP__
15 
16 /*****************************************************************************
17 ** Include
18 *****************************************************************************/
19 
20 #include "../packet_handler/payload_base.hpp"
21 #include "../macros.hpp"
22 #include "../lqueue.h"
23 #include <stdint.h>
24 
25 /*****************************************************************************
26 ** Namespaces
27 *****************************************************************************/
28 
29 namespace xbot
30 {
31 
32 /*****************************************************************************
33 ** Interface
34 *****************************************************************************/
35 
37 {
38 public:
39  CoreSensors() : packet_handler::payloadBase(false, 30),
40  queue_front_infrared(25),
41  queue_rear_infrared(25),
42  queue_front_echo(25),
43  queue_rear_echo(25)
44  {};
45 
46  struct Data {
47  uint16_t left_encoder;
48  uint16_t right_encoder;
50  unsigned char power_percent;
51  uint16_t front_echo;
52  uint16_t rear_echo;
53 // uint16_t right_echo;
54  uint16_t front_infrared;
55  uint16_t rear_infrared;
56 
60 
61  uint32_t timestamp;
62  uint16_t error_state;
63 
64  uint8_t version;
65 
66  } data;
67 
68 
69 // infrared queue
72 
73 // echo queue
76 
77 
78 
79 
80 
81  struct Flags {
82  // Charging source
83  // - first four bits distinguish between adapter or docking base charging
84  static const uint8_t AdapterType = 0x10;
85  // - last 4 bits specified the charging status (see Battery.hpp for details)
86  static const uint8_t BatteryStateMask = 0x0F;
87  static const uint8_t Discharging = 0x00;
88  static const uint8_t Charged = 0x02;
89  static const uint8_t Charging = 0x06;
90 
91 
92  };
93 
94 
95  bool serialise(ecl::PushAndPop<unsigned char> & byteStream);
96  bool deserialise(ecl::PushAndPop<unsigned char> & byteStream);
97  void build_special_variable(float &variable, ecl::PushAndPop<unsigned char> & byteStream);
98 };
99 
100 } // namespace xbot
101 
102 #endif /* XBOT_CORE_SENSORS_HPP__ */
lqueue< uint > queue_rear_echo
#define xbot_PUBLIC
unsigned char power_percent
Provides base class for payloads.
lqueue< uint > queue_front_echo
lqueue< uint > queue_rear_infrared
lqueue< uint > queue_front_infrared
Definition: command.hpp:30


xbot_driver
Author(s): Roc, wangpeng@droid.ac.cn
autogenerated on Sat Oct 10 2020 03:27:37