23 #include "naostiffness_config_plugin.h" 25 #include <config/config.h> 31 using Gtk::SpinButton;
32 using Gtk::CheckButton;
36 #define STIFFNESS_CFG_PATH "/naomotion/stiffness" 49 const Glib::RefPtr<Gtk::Builder> &builder)
50 : Gtk::Dialog(cobject)
52 builder->get_widget(
"hy", __hy);
53 builder->get_widget(
"hp", __hp);
55 builder->get_widget(
"lsp", __lsp);
56 builder->get_widget(
"rsp", __rsp);
57 builder->get_widget(
"lsr", __lsr);
58 builder->get_widget(
"rsr", __rsr);
59 builder->get_widget(
"ley", __ley);
60 builder->get_widget(
"rey", __rey);
61 builder->get_widget(
"ler", __ler);
62 builder->get_widget(
"rer", __rer);
64 builder->get_widget(
"lhyp", __lhyp);
65 builder->get_widget(
"rhyp", __rhyp);
66 builder->get_widget(
"lhr", __lhr);
67 builder->get_widget(
"rhr", __rhr);
68 builder->get_widget(
"lhp", __lhp);
69 builder->get_widget(
"rhp", __rhp);
70 builder->get_widget(
"lkp", __lkp);
71 builder->get_widget(
"rkp", __rkp);
72 builder->get_widget(
"lar", __lar);
73 builder->get_widget(
"rar", __rar);
74 builder->get_widget(
"lap", __lap);
75 builder->get_widget(
"rap", __rap);
77 builder->get_widget(
"checkbutton_default", __def);
78 builder->get_widget(
"checkbutton_lock", __lck);
83 builder->get_widget(
"combobox_behaviour", __bhv);
85 __bhv->get_active()->get_value(0, __cur_bhv);
99 __hy->set_value(vals.
hy);
100 __hp->set_value(vals.
hp);
102 __lsp->set_value(vals.
lsp);
103 __rsp->set_value(vals.
rsp);
104 __lsr->set_value(vals.
lsr);
105 __rsr->set_value(vals.
rsr);
106 __ley->set_value(vals.
ley);
107 __rey->set_value(vals.
rey);
108 __ler->set_value(vals.
ler);
109 __rer->set_value(vals.
rer);
111 __lhyp->set_value(vals.
lhyp);
112 __rhyp->set_value(vals.
rhyp);
113 __lhr->set_value(vals.
lhr);
114 __rhr->set_value(vals.
rhr);
115 __lhp->set_value(vals.
lhp);
116 __rhp->set_value(vals.
rhp);
117 __lkp->set_value(vals.
lkp);
118 __rkp->set_value(vals.
rkp);
119 __lar->set_value(vals.
lar);
120 __rar->set_value(vals.
rar);
121 __lap->set_value(vals.
lap);
122 __rap->set_value(vals.
rap);
125 __lsp->get_value() == __rsp->get_value() &&
126 __lsr->get_value() == __rsr->get_value() &&
127 __ley->get_value() == __rey->get_value() &&
128 __ler->get_value() == __rer->get_value() &&
129 __lhyp->get_value() == __rhyp->get_value() &&
130 __lhr->get_value() == __rhr->get_value() &&
131 __lhp->get_value() == __rhp->get_value() &&
132 __lkp->get_value() == __rkp->get_value() &&
133 __lar->get_value() == __rar->get_value() &&
134 __lap->get_value() == __rap->get_value()
143 vals.
hy = __hy ->get_value();
144 vals.
hp = __hp->get_value();
146 vals.
lsp = __lsp->get_value();
147 vals.
rsp = __rsp->get_value();
148 vals.
lsr = __lsr->get_value();
149 vals.
rsr = __rsr->get_value();
150 vals.
ley = __ley->get_value();
151 vals.
rey = __rey->get_value();
152 vals.
ler = __ler->get_value();
153 vals.
rer = __rer->get_value();
155 vals.
lhyp = __lhyp->get_value();
156 vals.
rhyp = __rhyp->get_value();
157 vals.
lhr = __lhr->get_value();
158 vals.
rhr = __rhr->get_value();
159 vals.
lhp = __lhp->get_value();
160 vals.
rhp = __rhp->get_value();
161 vals.
lkp = __lkp->get_value();
162 vals.
rkp = __rkp->get_value();
163 vals.
lar = __lar->get_value();
164 vals.
rar = __rar->get_value();
165 vals.
lap = __lap->get_value();
166 vals.
rap = __rap->get_value();
172 bool locked = __lck->get_active();
174 __rsp->set_sensitive(!locked);
175 __rsr->set_sensitive(!locked);
176 __rey->set_sensitive(!locked);
177 __rer->set_sensitive(!locked);
179 __rhyp->set_sensitive(!locked);
180 __rhr->set_sensitive(!locked);
181 __rhp->set_sensitive(!locked);
182 __rkp->set_sensitive(!locked);
183 __rar->set_sensitive(!locked);
184 __rap->set_sensitive(!locked);
188 __connections.push_back(__lsp->signal_value_changed().connect(compose(mem_fun(*__rsp, &SpinButton::set_value), mem_fun(*__lsp, &SpinButton::get_value))));
189 __connections.push_back(__lsr->signal_value_changed().connect(compose(mem_fun(*__rsr, &SpinButton::set_value), mem_fun(*__lsr, &SpinButton::get_value))));
190 __connections.push_back(__ley->signal_value_changed().connect(compose(mem_fun(*__rey, &SpinButton::set_value), mem_fun(*__ley, &SpinButton::get_value))));
191 __connections.push_back(__ler->signal_value_changed().connect(compose(mem_fun(*__rer, &SpinButton::set_value), mem_fun(*__ler, &SpinButton::get_value))));
193 __connections.push_back(__lhyp->signal_value_changed().connect(compose(mem_fun(*__rhyp, &SpinButton::set_value), mem_fun(*__lhyp, &SpinButton::get_value))));
194 __connections.push_back(__lhr->signal_value_changed().connect(compose(mem_fun(*__rhr, &SpinButton::set_value), mem_fun(*__lhr, &SpinButton::get_value))));
195 __connections.push_back(__lhp->signal_value_changed().connect(compose(mem_fun(*__rhp, &SpinButton::set_value), mem_fun(*__lhp, &SpinButton::get_value))));
196 __connections.push_back(__lkp->signal_value_changed().connect(compose(mem_fun(*__rkp, &SpinButton::set_value), mem_fun(*__lkp, &SpinButton::get_value))));
197 __connections.push_back(__lar->signal_value_changed().connect(compose(mem_fun(*__rar, &SpinButton::set_value), mem_fun(*__lar, &SpinButton::get_value))));
198 __connections.push_back(__lap->signal_value_changed().connect(compose(mem_fun(*__rap, &SpinButton::set_value), mem_fun(*__lap, &SpinButton::get_value))));
200 __rsp->set_value(__lsp->get_value());
201 __rsr->set_value(__lsr->get_value());
202 __rey->set_value(__ley->get_value());
203 __rer->set_value(__ler->get_value());
205 __rhyp->set_value(__lhyp->get_value());
206 __rhr->set_value(__lhr->get_value());
207 __rhp->set_value(__lhp->get_value());
208 __rkp->set_value(__lkp->get_value());
209 __rar->set_value(__lar->get_value());
210 __rap->set_value(__lap->get_value());
214 while (!__connections.empty())
216 __connections.back().disconnect();
217 __connections.pop_back();
225 __bhv->get_active()->get_value(0, __cur_bhv);
242 return __def->get_active();
275 NaoStiffnessConfigPlugin::load_vals()
312 printf(
"NaoStiffnessConfigPlugin: Could not read required config values.\n");
314 __initial_vals.
hy = -1.0;
315 __initial_vals.
hp = -1.0;
317 __initial_vals.
lsp = -1.0;
318 __initial_vals.
rsp = -1.0;
319 __initial_vals.
lsr = -1.0;
320 __initial_vals.
rsr = -1.0;
321 __initial_vals.
ley = -1.0;
322 __initial_vals.
rey = -1.0;
323 __initial_vals.
ler = -1.0;
324 __initial_vals.
rer = -1.0;
326 __initial_vals.
lhyp = -1.0;
327 __initial_vals.
rhyp = -1.0;
328 __initial_vals.
lhr = -1.0;
329 __initial_vals.
rhr = -1.0;
330 __initial_vals.
lhp = -1.0;
331 __initial_vals.
rhp = -1.0;
332 __initial_vals.
lkp = -1.0;
333 __initial_vals.
rkp = -1.0;
334 __initial_vals.
lar = -1.0;
335 __initial_vals.
rar = -1.0;
336 __initial_vals.
lap = -1.0;
337 __initial_vals.
rap = -1.0;
343 NaoStiffnessConfigPlugin::save_vals()
352 void (
Configuration::*my_set_float)(
const char *, float) = NULL;
354 if (dlg->
get_save_default()) my_set_float = &Configuration::set_default_float;
355 else my_set_float = &Configuration::set_float;
357 if (vals.
hy != __initial_vals.
hy) (
m_config->*my_set_float)(
string(path).append(
"/head_yaw").c_str(), vals.
hy);
358 if (vals.
hp != __initial_vals.
hp) (
m_config->*my_set_float)(
string(path).append(
"/head_pitch").c_str(), vals.
hp);
360 if (vals.
lsp != __initial_vals.
lsp) (
m_config->*my_set_float)(
string(path).append(
"/l_shoulder_pitch").c_str(), vals.
lsp);
361 if (vals.
rsp != __initial_vals.
rsp) (
m_config->*my_set_float)(
string(path).append(
"/r_shoulder_pitch").c_str(), vals.
rsp);
362 if (vals.
lsr != __initial_vals.
lsr) (
m_config->*my_set_float)(
string(path).append(
"/l_shoulder_roll").c_str(), vals.
lsr);
363 if (vals.
rsr != __initial_vals.
rsr) (
m_config->*my_set_float)(
string(path).append(
"/r_shoulder_roll").c_str(), vals.
rsr);
364 if (vals.
ley != __initial_vals.
ley) (
m_config->*my_set_float)(
string(path).append(
"/l_elbow_yaw").c_str(), vals.
ley);
365 if (vals.
rey != __initial_vals.
rey) (
m_config->*my_set_float)(
string(path).append(
"/r_elbow_yaw").c_str(), vals.
rey);
366 if (vals.
ler != __initial_vals.
ler) (
m_config->*my_set_float)(
string(path).append(
"/l_elbow_roll").c_str(), vals.
ler);
367 if (vals.
rer != __initial_vals.
rer) (
m_config->*my_set_float)(
string(path).append(
"/r_elbow_roll").c_str(), vals.
rer);
369 if (vals.
lhyp != __initial_vals.
lhyp) (
m_config->*my_set_float)(
string(path).append(
"/l_hip_yaw_pitch").c_str(), vals.
lhyp);
370 if (vals.
rhyp != __initial_vals.
rhyp) (
m_config->*my_set_float)(
string(path).append(
"/r_hip_yaw_pitch").c_str(), vals.
rhyp);
371 if (vals.
lhr != __initial_vals.
lhr) (
m_config->*my_set_float)(
string(path).append(
"/l_hip_roll").c_str(), vals.
lhr);
372 if (vals.
rhr != __initial_vals.
rhr) (
m_config->*my_set_float)(
string(path).append(
"/r_hip_roll").c_str(), vals.
rhr);
373 if (vals.
lhp != __initial_vals.
lhp) (
m_config->*my_set_float)(
string(path).append(
"/l_hip_roll").c_str(), vals.
lhp);
374 if (vals.
rhp != __initial_vals.
rhp) (
m_config->*my_set_float)(
string(path).append(
"/r_hip_roll").c_str(), vals.
rhp);
375 if (vals.
lkp != __initial_vals.
lkp) (
m_config->*my_set_float)(
string(path).append(
"/l_knee_pitch").c_str(), vals.
lkp);
376 if (vals.
rkp != __initial_vals.
rkp) (
m_config->*my_set_float)(
string(path).append(
"/r_knee_pitch").c_str(), vals.
rkp);
377 if (vals.
lar != __initial_vals.
lar) (
m_config->*my_set_float)(
string(path).append(
"/l_ankle_roll").c_str(), vals.
lar);
378 if (vals.
rar != __initial_vals.
rar) (
m_config->*my_set_float)(
string(path).append(
"/r_ankle_roll").c_str(), vals.
rar);
379 if (vals.
lap != __initial_vals.
lap) (
m_config->*my_set_float)(
string(path).append(
"/l_ankle_pitch").c_str(), vals.
lap);
380 if (vals.
rap != __initial_vals.
rap) (
m_config->*my_set_float)(
string(path).append(
"/r_ankle_pitch").c_str(), vals.
rap);
384 printf(
"NaoStiffnessConfigPlugin: Could not write required config values.\n");
400 case Gtk::RESPONSE_OK:
404 case Gtk::RESPONSE_CANCEL:
405 case Gtk::RESPONSE_DELETE_EVENT:
409 printf(
"Nao stiffness config plugin: unknown response\n");
418 m_builder->get_widget_derived(
"PluginDialog", dlg);
419 dlg->
set_load_vals(mem_fun(*
this, &NaoStiffnessConfigPlugin::load_vals));
NaoStiffnessConfigPlugin(std::string ui_path)
Constructor.
float rhyp
right hip yaw/pitch
float rkp
right knee pitch
virtual ~NaoStiffnessConfigPlugin()
Destructor.
virtual std::string get_cur_behaviour()
Return currently selected behaviour.
Fawkes library namespace.
Config dialog of the config editor plugin for the nao joint stiffnesses.
fawkes::Configuration * m_config
The fawkes::Configuration.
virtual ~NaoStiffnessConfigDialog()
Destructor.
float rer
right elbow roll
Glib::RefPtr< Gtk::Builder > m_builder
Gtk Builder created from the UI file of the plugin.
float rar
right ankle roll
NaoStiffnessConfigDialog(BaseObjectType *cobject, const Glib::RefPtr< Gtk::Builder > &builder)
Constructor.
virtual void on_checkbutton_lock_toggled()
Lock checkbox toggled handler.
float rsp
right shoulder pitch
Base class for exceptions in Fawkes.
virtual void post_run(int response)
This method is called after the dialog is closed.
void print_backtrace() const
Prints a backtrace.
float lap
left ankle pitch
float rsr
right shoulder roll
virtual void on_combobox_behaviour_changed()
Behaviour combobox changed handler.
virtual void set_load_vals(sigc::slot< void > cb)
Set the callback function for loading values in the plugin.
float lsp
left shoulder pitch
float lsr
left shoulder roll
virtual Gtk::Dialog * load_dialog()
In this function the (custom) dialog of the plugin needs to be initialized.
Gtk::Dialog * m_dialog
The (main-) dialog of the plugin.
virtual void get_stiffnesses(nao_stiffnesses &vals)
Get joint stiffness values from the dialog.
Base class for plugins for the Fawkes config editor.
virtual bool get_save_default()
Return whether default checkbox is checked.
Interface for configuration handling.
virtual float get_float(const char *path)=0
Get value from configuration which is of type float.
float lhyp
left hip yaw/pitch
virtual void pre_run()
Config editor plugins need to implement this function.
float rap
right ankle pitch
virtual void set_stiffnesses(const nao_stiffnesses &vals)
Set joint stiffness values in the dialog.