Fawkes API  Fawkes Development Version
naogui.h
1 
2 /***************************************************************************
3  * naogui.h - Nao GUI
4  *
5  * Created: Mon Oct 27 17:10:58 2008
6  * Copyright 2008-2011 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __PLUGINS_NAO_TOOLS_NAOGUI_NAOGUI_H_
24 #define __PLUGINS_NAO_TOOLS_NAOGUI_NAOGUI_H_
25 
26 #include <gui_utils/connection_dispatcher.h>
27 
28 #include <gtkmm.h>
29 
30 namespace fawkes {
31  class BlackBoard;
32  class Interface;
33  class NaoJointPositionInterface;
34  class NaoJointStiffnessInterface;
35  class NaoSensorInterface;
36  class NavigatorInterface;
37  class HumanoidMotionInterface;
38  class SpeechSynthInterface;
39  class InterfaceDispatcher;
40  class LedInterface;
41  class SwitchInterface;
42 }
43 
44 class NaoGuiGtkWindow : public Gtk::Window
45 {
46  public:
47  NaoGuiGtkWindow(BaseObjectType* cobject,
48  const Glib::RefPtr<Gtk::Builder> &builder);
49  ~NaoGuiGtkWindow();
50 
51  private:
52  void update_servo_value(Gtk::HScale *hsc, Gtk::Label *label, float value);
53  void update_sensor_value(Gtk::Label *label, float value, bool show_decimal=true);
54  void update_entry_value(Gtk::Entry *ent, float value, unsigned int width = 2);
55  void update_ultrasonic_direction();
56  void send_servo_msg(Gtk::HScale *hsc, unsigned int servo);
57  void update_values(bool force = false);
58  void update_jointpos_values(bool force = false);
59  void update_sensor_values(bool force = false);
60  bool servos_enabled() const;
61  void update_tts();
62 
63  void on_led_data_changed(fawkes::Interface *iface);
64  void on_button_data_changed(fawkes::Interface *iface);
65 
66  void on_stiffness_clicked();
67  void on_control_toggled();
68  void on_sv_copy_clicked();
69  void on_us_emit_clicked();
70  void on_us_auto_toggled();
71  void on_goto_parkpos_clicked();
72  void on_goto_zero_all_clicked();
73  void on_get_up_clicked();
74  void on_walkvel_exec_clicked();
75  void on_ws_exec_clicked();
76  void on_wsw_exec_clicked();
77  void on_kick_exec_clicked();
78  void on_standup_exec_clicked();
79  void on_nav_exec_clicked();
80  void on_wa_exec_clicked();
81  void on_turn_exec_clicked();
82  void on_motion_stop_clicked();
83  void on_cf_read_clicked();
84  void on_cf_write_clicked();
85  void on_stiffness_write_clicked();
86  void on_stiffness_read_clicked();
87  void on_stiffness_global_toggled();
88  void on_tts_exec_clicked();
89  void on_slider_changed(Gtk::HScale *hsc, Gtk::Label *lab, unsigned int servo);
90  void on_changed_speed();
91  void on_connection_clicked();
92  void on_connect();
93  void on_disconnect();
94  void on_exit_clicked();
95 
96  void on_control_leds_toggled();
97  void on_led_tb_toggled(std::string iface_id, Gtk::ToggleButton *tb);
98  void on_led_slider_changed(std::string iface_id, Gtk::Scale *scl);
99  bool on_led_slider_button_release(GdkEventButton *event,
100  std::string iface_id, Gtk::Scale *scl);
101 
102  void on_button_click_pressed(std::string iface_id);
103  void on_button_click_released(std::string iface_id);
104 
105  bool convert_str2float(Glib::ustring sn, float *f);
106  Glib::ustring convert_float2str(float f, unsigned int width = 2);
107 
108  void init();
109 
110 
111  private:
112  fawkes::BlackBoard *bb;
113  fawkes::InterfaceDispatcher *ifd_jointpos;
114  fawkes::InterfaceDispatcher *ifd_sensor;
116  fawkes::InterfaceDispatcher *ifd_leds;
117  fawkes::InterfaceDispatcher *ifd_buttons;
119  fawkes::NaoJointStiffnessInterface *jointstiff_if;
120  fawkes::NaoSensorInterface *sensor_if;
121  fawkes::NavigatorInterface *nao_navi_if;
122  fawkes::SpeechSynthInterface *speechsynth_if;
123  fawkes::HumanoidMotionInterface *hummot_fawkes_if;
124  fawkes::HumanoidMotionInterface *hummot_naoqi_if;
125  fawkes::ConnectionDispatcher connection_dispatcher;
126 
127  std::map<std::string, fawkes::LedInterface *> led_ifs;
128  std::map<std::string, Gtk::Scale *> led_scales;
129  std::map<std::string, Gtk::ToggleButton *> led_buttons;
130 
131  bool servo_enabled;
132  bool global_stiffness_enabled;
133 
134  Gtk::Frame *frm_servos;
135  Gtk::Frame *frm_sensors;
136  Gtk::Frame *frm_ultrasonic;
137 
138  Gtk::HScale *hsc_HeadYaw;
139  Gtk::Label *lab_HeadYaw;
140  Gtk::HScale *hsc_HeadPitch;
141  Gtk::Label *lab_HeadPitch;
142  Gtk::HScale *hsc_RShoulderPitch;
143  Gtk::Label *lab_RShoulderPitch;
144  Gtk::HScale *hsc_RShoulderRoll;
145  Gtk::Label *lab_RShoulderRoll;
146  Gtk::HScale *hsc_RElbowYaw;
147  Gtk::Label *lab_RElbowYaw;
148  Gtk::HScale *hsc_RElbowRoll;
149  Gtk::Label *lab_RElbowRoll;
150  Gtk::HScale *hsc_RWristYaw;
151  Gtk::Label *lab_RWristYaw;
152  Gtk::HScale *hsc_RHand;
153  Gtk::Label *lab_RHand;
154  Gtk::HScale *hsc_LShoulderPitch;
155  Gtk::Label *lab_LShoulderPitch;
156  Gtk::HScale *hsc_LShoulderRoll;
157  Gtk::Label *lab_LShoulderRoll;
158  Gtk::HScale *hsc_LElbowYaw;
159  Gtk::Label *lab_LElbowYaw;
160  Gtk::HScale *hsc_LElbowRoll;
161  Gtk::Label *lab_LElbowRoll;
162  Gtk::HScale *hsc_LWristYaw;
163  Gtk::Label *lab_LWristYaw;
164  Gtk::HScale *hsc_LHand;
165  Gtk::Label *lab_LHand;
166  Gtk::HScale *hsc_RHipYawPitch;
167  Gtk::Label *lab_RHipYawPitch;
168  Gtk::HScale *hsc_RHipPitch;
169  Gtk::Label *lab_RHipPitch;
170  Gtk::HScale *hsc_RHipRoll;
171  Gtk::Label *lab_RHipRoll;
172  Gtk::HScale *hsc_RKneePitch;
173  Gtk::Label *lab_RKneePitch;
174  Gtk::HScale *hsc_RAnklePitch;
175  Gtk::Label *lab_RAnklePitch;
176  Gtk::HScale *hsc_RAnkleRoll;
177  Gtk::Label *lab_RAnkleRoll;
178  Gtk::HScale *hsc_LHipYawPitch;
179  Gtk::Label *lab_LHipYawPitch;
180  Gtk::HScale *hsc_LHipPitch;
181  Gtk::Label *lab_LHipPitch;
182  Gtk::HScale *hsc_LHipRoll;
183  Gtk::Label *lab_LHipRoll;
184  Gtk::HScale *hsc_LKneePitch;
185  Gtk::Label *lab_LKneePitch;
186  Gtk::HScale *hsc_LAnklePitch;
187  Gtk::Label *lab_LAnklePitch;
188  Gtk::HScale *hsc_LAnkleRoll;
189  Gtk::Label *lab_LAnkleRoll;
190  Gtk::HScale *hsc_speed;
191  Gtk::Label *lab_speed;
192  Gtk::ToolButton *tb_connection;
193  Gtk::ToolButton *tb_stiffness;
194  Gtk::ToggleToolButton *tb_control;
195  Gtk::ToolButton *tb_getup;
196  Gtk::ToolButton *tb_parkpos;
197  Gtk::ToolButton *tb_zeroall;
198  Gtk::ToolButton *tb_exit;
199  Gtk::Label *lab_l_fsr_fl;
200  Gtk::Label *lab_l_fsr_fr;
201  Gtk::Label *lab_l_fsr_rl;
202  Gtk::Label *lab_l_fsr_rr;
203  Gtk::Label *lab_r_fsr_fl;
204  Gtk::Label *lab_r_fsr_fr;
205  Gtk::Label *lab_r_fsr_rl;
206  Gtk::Label *lab_r_fsr_rr;
207  Gtk::Label *lab_r_cop;
208  Gtk::Label *lab_l_cop;
209  Gtk::Label *lab_r_total_weight;
210  Gtk::Label *lab_l_total_weight;
211  Gtk::Label *lab_chest_button;
212  Gtk::Label *lab_touch_front;
213  Gtk::Label *lab_touch_middle;
214  Gtk::Label *lab_touch_rear;
215  Gtk::Label *lab_l_bumper_l;
216  Gtk::Label *lab_l_bumper_r;
217  Gtk::Label *lab_r_bumper_l;
218  Gtk::Label *lab_r_bumper_r;
219  Gtk::Label *lab_accel_x;
220  Gtk::Label *lab_accel_y;
221  Gtk::Label *lab_accel_z;
222  Gtk::Label *lab_gyro_x;
223  Gtk::Label *lab_gyro_y;
224  Gtk::Label *lab_gyro_ref;
225  Gtk::Label *lab_angles_xy;
226  Gtk::Label *lab_ultrasonic_direction;
227  Gtk::Label *lab_ultrasonic_left0;
228  Gtk::Label *lab_ultrasonic_left1;
229  Gtk::Label *lab_ultrasonic_left2;
230  Gtk::Label *lab_ultrasonic_left3;
231  Gtk::Label *lab_ultrasonic_right0;
232  Gtk::Label *lab_ultrasonic_right1;
233  Gtk::Label *lab_ultrasonic_right2;
234  Gtk::Label *lab_ultrasonic_right3;
235  Gtk::Label *lab_battery_charge;
236  Gtk::ToggleButton *but_us_auto;
237  Gtk::Button *but_us_emit;
238  Gtk::ComboBox *cmb_us_direction;
239 
240  Gtk::Button *but_sv_copy;
241 
242  Gtk::Button *but_stiffness_read;
243  Gtk::Button *but_stiffness_write;
244  Gtk::SpinButton *spb_stiffness_global;
245  Gtk::CheckButton *chb_stiffness_global;
246  Gtk::SpinButton *spb_HeadYaw;
247  Gtk::SpinButton *spb_HeadPitch;
248  Gtk::SpinButton *spb_RShoulderPitch;
249  Gtk::SpinButton *spb_RShoulderRoll;
250  Gtk::SpinButton *spb_RElbowYaw;
251  Gtk::SpinButton *spb_RElbowRoll;
252  Gtk::SpinButton *spb_RWristYaw;
253  Gtk::SpinButton *spb_RHand;
254  Gtk::SpinButton *spb_LShoulderPitch;
255  Gtk::SpinButton *spb_LShoulderRoll;
256  Gtk::SpinButton *spb_LElbowYaw;
257  Gtk::SpinButton *spb_LElbowRoll;
258  Gtk::SpinButton *spb_LWristYaw;
259  Gtk::SpinButton *spb_LHand;
260  Gtk::SpinButton *spb_RHipYawPitch;
261  Gtk::SpinButton *spb_RHipPitch;
262  Gtk::SpinButton *spb_RHipRoll;
263  Gtk::SpinButton *spb_RKneePitch;
264  Gtk::SpinButton *spb_RAnklePitch;
265  Gtk::SpinButton *spb_RAnkleRoll;
266  Gtk::SpinButton *spb_LHipYawPitch;
267  Gtk::SpinButton *spb_LHipPitch;
268  Gtk::SpinButton *spb_LHipRoll;
269  Gtk::SpinButton *spb_LKneePitch;
270  Gtk::SpinButton *spb_LAnklePitch;
271  Gtk::SpinButton *spb_LAnkleRoll;
272 
273  Gtk::Label *lab_stiff_HeadYaw;
274  Gtk::Label *lab_stiff_HeadPitch;
275  Gtk::Label *lab_stiff_RShoulderPitch;
276  Gtk::Label *lab_stiff_RShoulderRoll;
277  Gtk::Label *lab_stiff_RElbowYaw;
278  Gtk::Label *lab_stiff_RElbowRoll;
279  Gtk::Label *lab_stiff_RWristYaw;
280  Gtk::Label *lab_stiff_RHand;
281  Gtk::Label *lab_stiff_LShoulderPitch;
282  Gtk::Label *lab_stiff_LShoulderRoll;
283  Gtk::Label *lab_stiff_LElbowYaw;
284  Gtk::Label *lab_stiff_LElbowRoll;
285  Gtk::Label *lab_stiff_LWristYaw;
286  Gtk::Label *lab_stiff_LHand;
287  Gtk::Label *lab_stiff_RHipYawPitch;
288  Gtk::Label *lab_stiff_RHipPitch;
289  Gtk::Label *lab_stiff_RHipRoll;
290  Gtk::Label *lab_stiff_RKneePitch;
291  Gtk::Label *lab_stiff_RAnklePitch;
292  Gtk::Label *lab_stiff_RAnkleRoll;
293  Gtk::Label *lab_stiff_LHipYawPitch;
294  Gtk::Label *lab_stiff_LHipPitch;
295  Gtk::Label *lab_stiff_LHipRoll;
296  Gtk::Label *lab_stiff_LKneePitch;
297  Gtk::Label *lab_stiff_LAnklePitch;
298  Gtk::Label *lab_stiff_LAnkleRoll;
299 
300  Gtk::RadioButton *rad_motion_fawkes;
301  Gtk::RadioButton *rad_motion_naoqi;
302  Gtk::Button *but_stop;
303  Gtk::Entry *ent_ws_distance;
304  Gtk::Button *but_ws_exec;
305  Gtk::Entry *ent_wsw_distance;
306  Gtk::Button *but_wsw_exec;
307  Gtk::Entry *ent_wa_angle;
308  Gtk::Entry *ent_wa_radius;
309  Gtk::Button *but_wa_exec;
310  Gtk::Entry *ent_turn_angle;
311  Gtk::Button *but_turn_exec;
312  Gtk::ComboBox *cmb_kick_leg;
313  Gtk::Entry *ent_kick_strength;
314  Gtk::Button *but_kick_exec;
315  Gtk::ComboBox *cmb_standup_from;
316  Gtk::Button *but_standup_exec;
317 
318  Gtk::Entry *ent_walkvel_x;
319  Gtk::Entry *ent_walkvel_y;
320  Gtk::Entry *ent_walkvel_theta;
321  Gtk::Entry *ent_walkvel_speed;
322  Gtk::Button *but_walkvel_exec;
323 
324  Gtk::Entry *ent_nav_x;
325  Gtk::Entry *ent_nav_y;
326  Gtk::Entry *ent_nav_ori;
327  Gtk::Button *but_nav_exec;
328 
329  Gtk::Entry *ent_tts;
330  Gtk::Button *but_tts_exec;
331  Gtk::Label *lab_tts_active;
332 
333  Gtk::Scale *scl_chest_r;
334  Gtk::Scale *scl_chest_g;
335  Gtk::Scale *scl_chest_b;
336  Gtk::Scale *scl_left_eye_r;
337  Gtk::Scale *scl_left_eye_g;
338  Gtk::Scale *scl_left_eye_b;
339  Gtk::Scale *scl_right_eye_r;
340  Gtk::Scale *scl_right_eye_g;
341  Gtk::Scale *scl_right_eye_b;
342  Gtk::Scale *scl_left_foot_r;
343  Gtk::Scale *scl_left_foot_g;
344  Gtk::Scale *scl_left_foot_b;
345  Gtk::Scale *scl_right_foot_r;
346  Gtk::Scale *scl_right_foot_g;
347  Gtk::Scale *scl_right_foot_b;
348 
349  Gtk::ToggleButton *tb_left_ear_0;
350  Gtk::ToggleButton *tb_left_ear_36;
351  Gtk::ToggleButton *tb_left_ear_72;
352  Gtk::ToggleButton *tb_left_ear_108;
353  Gtk::ToggleButton *tb_left_ear_144;
354  Gtk::ToggleButton *tb_left_ear_180;
355  Gtk::ToggleButton *tb_left_ear_216;
356  Gtk::ToggleButton *tb_left_ear_252;
357  Gtk::ToggleButton *tb_left_ear_288;
358  Gtk::ToggleButton *tb_left_ear_324;
359 
360  Gtk::ToggleButton *tb_right_ear_0;
361  Gtk::ToggleButton *tb_right_ear_36;
362  Gtk::ToggleButton *tb_right_ear_72;
363  Gtk::ToggleButton *tb_right_ear_108;
364  Gtk::ToggleButton *tb_right_ear_144;
365  Gtk::ToggleButton *tb_right_ear_180;
366  Gtk::ToggleButton *tb_right_ear_216;
367  Gtk::ToggleButton *tb_right_ear_252;
368  Gtk::ToggleButton *tb_right_ear_288;
369  Gtk::ToggleButton *tb_right_ear_324;
370 
371  Gtk::ToggleButton *tb_control_leds;
372 
373  Gtk::Button *but_chestbut;
374  Gtk::Button *but_head_front;
375  Gtk::Button *but_head_middle;
376  Gtk::Button *but_head_rear;
377  Gtk::Button *but_lfoot_bumper;
378  Gtk::Button *but_rfoot_bumper;
379 
380  /// @cond INTERNALS
381  typedef struct {
382  Gtk::Label *lab_enabled;
383  Gtk::Label *lab_history;
384  Gtk::Label *lab_value;
385  Gtk::Label *lab_short;
386  Gtk::Label *lab_long;
387  Gtk::Label *lab_total;
388  } ButtonLabelSet;
389  /// @endcond
390  std::map<std::string, ButtonLabelSet> button_labels;
391  std::map<std::string, fawkes::SwitchInterface *> button_ifs;
392 
393  unsigned int update_cycle;
394 };
395 
396 #endif
NaoJointPositionInterface Fawkes BlackBoard Interface.
Fawkes library namespace.
NaoSensorInterface Fawkes BlackBoard Interface.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
NaoJointStiffnessInterface Fawkes BlackBoard Interface.
HumanoidMotionInterface Fawkes BlackBoard Interface.
Nao GUI main window.
Definition: naogui.h:44
The BlackBoard abstract class.
Definition: blackboard.h:48
Watches network client events and dispatches them as signals.
Interface listener with dispatcher.
SpeechSynthInterface Fawkes BlackBoard Interface.
NavigatorInterface Fawkes BlackBoard Interface.