naostiffness_config_plugin.h

00001 
00002 /***************************************************************************
00003  *  naostiffness_config_plugin.h - Config plugin for the nao joint stiffnesses
00004  *
00005  *  Created: Tue Apr  7 15:15:15 2009
00006  *  Copyright  2009  Tobias Kellner
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  Read the full text in the LICENSE.GPL file in the doc directory.
00021  */
00022 
00023 #ifndef __TOOLS_CONFIG_EDITOR_NAOSTIFFNESS_CONFIG_PLUGIN_H_
00024 #define __TOOLS_CONFIG_EDITOR_NAOSTIFFNESS_CONFIG_PLUGIN_H_
00025 
00026 #include "config_editor_plugin.h"
00027 
00028 #include <gtkmm.h>
00029 #include <libglademm/xml.h>
00030 
00031 #include <string>
00032 #include <vector>
00033 
00034 class NaoStiffnessConfigDialog : public Gtk::Dialog
00035 {
00036 public:
00037  struct nao_stiffnesses /**< joint stiffness values */
00038  {
00039    float hy; /**< head yaw */
00040    float hp; /**< head pitch */
00041 
00042    float lsp; /**< left  shoulder pitch */
00043    float rsp; /**< right shoulder pitch */
00044    float lsr; /**< left  shoulder roll */
00045    float rsr; /**< right shoulder roll */
00046    float ley; /**< left  elbow yaw */
00047    float rey; /**< right elbow yaw */
00048    float ler; /**< left  elbow roll */
00049    float rer; /**< right elbow roll */
00050 
00051    float lhyp; /**< left  hip yaw/pitch */
00052    float rhyp; /**< right hip yaw/pitch */
00053    float lhr;  /**< left  hip roll */
00054    float rhr;  /**< right hip roll */
00055    float lhp;  /**< left  hip pitch */
00056    float rhp;  /**< right hip pitch */
00057    float lkp;  /**< left  knee pitch */
00058    float rkp;  /**< right knee pitch */
00059    float lar;  /**< left  ankle roll */
00060    float rar;  /**< right ankle roll */
00061    float lap;  /**< left  ankle pitch */
00062    float rap;  /**< right ankle pitch */
00063  };
00064 
00065  public:
00066   NaoStiffnessConfigDialog(BaseObjectType *cobject,
00067                            const Glib::RefPtr<Gnome::Glade::Xml> &ref_xml);
00068   virtual ~NaoStiffnessConfigDialog();
00069 
00070   virtual void set_stiffnesses(const nao_stiffnesses &vals);
00071   virtual void get_stiffnesses(nao_stiffnesses &vals);
00072 
00073   virtual void on_checkbutton_lock_toggled();
00074   virtual void on_combobox_behaviour_changed();
00075 
00076   virtual std::string get_cur_behaviour();
00077   virtual bool get_save_default();
00078   virtual void set_load_vals(sigc::slot<void> cb);
00079 
00080  private:
00081   Gtk::SpinButton *__hy;
00082   Gtk::SpinButton *__hp;
00083 
00084   Gtk::SpinButton *__lsp;
00085   Gtk::SpinButton *__rsp;
00086   Gtk::SpinButton *__lsr;
00087   Gtk::SpinButton *__rsr;
00088   Gtk::SpinButton *__ley;
00089   Gtk::SpinButton *__rey;
00090   Gtk::SpinButton *__ler;
00091   Gtk::SpinButton *__rer;
00092 
00093   Gtk::SpinButton *__lhyp;
00094   Gtk::SpinButton *__rhyp;
00095   Gtk::SpinButton *__lhr;
00096   Gtk::SpinButton *__rhr;
00097   Gtk::SpinButton *__lhp;
00098   Gtk::SpinButton *__rhp;
00099   Gtk::SpinButton *__lkp;
00100   Gtk::SpinButton *__rkp;
00101   Gtk::SpinButton *__lar;
00102   Gtk::SpinButton *__rar;
00103   Gtk::SpinButton *__lap;
00104   Gtk::SpinButton *__rap;
00105 
00106   Gtk::CheckButton *__def;
00107   Gtk::CheckButton *__lck;
00108   std::vector<sigc::connection> __connections;
00109 
00110   Gtk::ComboBox *__bhv;
00111   std::string __cur_bhv;
00112 
00113   sigc::slot<void> __load_vals;
00114 };
00115 
00116 class NaoStiffnessConfigPlugin : public ConfigEditorPlugin
00117 {
00118  public:
00119    NaoStiffnessConfigPlugin(std::string glade_path);
00120   virtual ~NaoStiffnessConfigPlugin();
00121 
00122  protected:
00123   virtual void pre_run();
00124   virtual void post_run(int response);
00125 
00126   virtual Gtk::Dialog* load_dialog();
00127 
00128  private:
00129   virtual void load_vals();
00130   virtual void save_vals();
00131 
00132  private:
00133    NaoStiffnessConfigDialog::nao_stiffnesses __initial_vals;
00134 };
00135 
00136 #endif /* __TOOLS_CONFIG_EDITOR_NAOSTIFFNESS_CONFIG_PLUGIN_H_ */