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