event_manager.hpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Ifdefs
11 *****************************************************************************/
12 
13 #ifndef KOBUKI_BUTTON_EVENT_HPP_
14 #define KOBUKI_BUTTON_EVENT_HPP_
15 
16 /*****************************************************************************
17 ** Includes
18 *****************************************************************************/
19 
20 #include <stdint.h>
21 #include <vector>
22 #include <ecl/sigslots.hpp>
23 
24 #include "packets/core_sensors.hpp"
25 #include "macros.hpp"
26 
27 /*****************************************************************************
28 ** Namespaces
29 *****************************************************************************/
30 
31 namespace kobuki {
32 
33 /*****************************************************************************
34 ** Event Structures
35 *****************************************************************************/
36 
37 struct ButtonEvent {
38  enum State {
41  } state;
42  enum Button {
46  } button;
47 };
48 
49 struct BumperEvent {
50  enum State {
53  } state;
54  enum Bumper {
57  Right
58  } bumper;
59 };
60 
61 struct CliffEvent {
62  enum State {
65  } state;
66  enum Sensor {
69  Right
70  } sensor;
71  uint16_t bottom;
72 };
73 
74 struct WheelEvent {
75  enum State {
77  Dropped
78  } state;
79  enum Wheel {
81  Right
82  } wheel;
83 };
84 
85 struct PowerEvent {
86  enum Event {
87  Unplugged = 0,
88  PluggedToAdapter = 1,
89  PluggedToDockbase = 2,
90  ChargeCompleted = 3,
91  BatteryLow = 4,
92  BatteryCritical = 5
93  } event;
94 };
95 
96 struct InputEvent {
97  bool values[4];
98 };
99 
100 struct RobotEvent {
101  enum State {
104  Unknown // at startup
105  } state;
106 };
107 
108 /*****************************************************************************
109 ** Interfaces
110 *****************************************************************************/
111 
113 public:
115  last_state.buttons = 0;
116  last_state.bumper = 0;
117  last_state.cliff = 0;
118  last_state.wheel_drop = 0;
119  last_state.charger = 0;
120  last_state.battery = 0;
121  last_digital_input = 0;
122  last_robot_state = RobotEvent::Unknown;
123  }
124 
125  void init(const std::string &sigslots_namespace);
126  void update(const CoreSensors::Data &new_state, const std::vector<uint16_t> &cliff_data);
127  void update(const uint16_t &digital_input);
128  void update(bool is_plugged, bool is_alive);
129 
130 private:
134 
135  ecl::Signal<const ButtonEvent&> sig_button_event;
136  ecl::Signal<const BumperEvent&> sig_bumper_event;
137  ecl::Signal<const CliffEvent&> sig_cliff_event;
138  ecl::Signal<const WheelEvent&> sig_wheel_event;
139  ecl::Signal<const PowerEvent&> sig_power_event;
140  ecl::Signal<const InputEvent&> sig_input_event;
141  ecl::Signal<const RobotEvent&> sig_robot_event;
142 };
143 
144 
145 } // namespace kobuki
146 
147 #endif /* KOBUKI_BUTTON_EVENT_HPP_ */
ecl::Signal< const InputEvent & > sig_input_event
ecl::Signal< const ButtonEvent & > sig_button_event
ecl::Signal< const CliffEvent & > sig_cliff_event
ecl::Signal< const RobotEvent & > sig_robot_event
CoreSensors::Data last_state
#define kobuki_PUBLIC
Definition: macros.hpp:39
enum kobuki::ButtonEvent::Button button
RobotEvent::State last_robot_state
Macros for kobuki_driver.
ecl::Signal< const WheelEvent & > sig_wheel_event
Core sensor packet payloads.
ecl::Signal< const BumperEvent & > sig_bumper_event
enum kobuki::ButtonEvent::State state
ecl::Signal< const PowerEvent & > sig_power_event


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