NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
led_widget.h
1 // Small rqt plugin to show the robot buttons and LEDs
2 // Author: Dmytro Pavlichenko
3 
4 #ifndef LED_WIDGET_H
5 #define LED_WIDGET_H
6 
7 #include <led_widget/led.h>
8 #include <rqt_gui_cpp/plugin.h>
9 #include <ros/publisher.h>
10 #include <ros/subscriber.h>
11 #include <ros/node_handle.h>
12 #include <nimbro_op_interface/LEDCommand.h>
13 #include <config_server/parameter.h>
14 #include <QTimer>
15 
16 namespace Ui { class LEDWidget; }
17 
18 namespace led_widget
19 {
20 
21 class LEDWidget : public rqt_gui_cpp::Plugin
22 {
23 Q_OBJECT
24 public:
25  LEDWidget();
26  virtual ~LEDWidget();
27 
28  virtual void initPlugin(qt_gui_cpp::PluginContext& context);
29  virtual void shutdownPlugin();
30 
31 private Q_SLOTS:
32  void handleBlinkTimerTimeout();
33 
34  void handleButton_0();
35  void handleButton_1();
36  void handleButton_2();
37 
38 private:
39  void stateReceived(const nimbro_op_interface::LEDCommandConstPtr& state);
40  void updateLED(int led, bool state);
41  void updateBlinking();
42 
43 private:
44  QWidget *view;
45  Ui::LEDWidget *ui;
46 
47  std::vector<LED *> leds;
48 
49  ros::NodeHandle n;
50  ros::Subscriber subscriber;
51 
52  QTimer m_blinkTimer;
53  bool m_blinkState;
54 
55  config_server::Parameter<bool> m_pressButton0;
56  config_server::Parameter<bool> m_pressButton1;
57  config_server::Parameter<bool> m_pressButton2;
58 };
59 
60 }
61 
62 #endif