HandUnitGuiPlugin.h
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarX::Component::ObjectExaminerGuiPlugin
17 * @author Nikolaus Vahrenkamp ( vahrenkamp at kit dot edu)
18 * @copyright 2012
19 * @license http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 
22 */
23 
24 #pragma once
25 
26 /* ArmarX headers */
27 #include <RobotAPI/gui-plugins/HandUnitPlugin/ui_HandUnitGuiPlugin.h>
31 
32 #include <RobotAPI/interface/units/HandUnitInterface.h>
33 
34 /* Qt headers */
35 #include <QMainWindow>
36 
37 #include <string>
38 
40 
41 
42 namespace armarx
43 {
44  class HandUnitConfigDialog;
45 
46  /**
47  \class HandUnitGuiPlugin
48  \brief This plugin offers a widget witch which the HandUnit can be controlled.
49  \see HandUnitWidget
50  */
52  public ArmarXGuiPlugin
53  {
54  Q_OBJECT
55  Q_INTERFACES(ArmarXGuiInterface)
56  Q_PLUGIN_METADATA(IID "ArmarXGuiInterface/1.00")
57  public:
59  QString getPluginName() override
60  {
61  return "HandUnitGuiPlugin";
62  }
63  };
64 
65  /*!
66  * \page RobotAPI-GuiPlugins-HandUnitWidget HandUnitGuiPlugin
67  * \brief With this widget the HandUnit can be controlled.
68  * \image html HandUnitGUI.png
69  * You can either select a preshape from the drop-down-menu on top or set each
70  * joint individually.
71  * When you add the widget to the Gui, you need to specify the following parameters:
72  *
73  * Parameter Name | Example Value | Required? | Description
74  * :---------------- | :-------------: | :-------------- |:--------------------
75  * Proxy | LeftHandUnit | Yes | The hand unit you want to control.
76  */
78  public ArmarXComponentWidgetControllerTemplate<HandUnitWidget>,
79  public HandUnitListener
80  {
81  Q_OBJECT
82  public:
84  ~HandUnitWidget() override
85  {}
86 
87  // inherited from Component
88  void onInitComponent() override;
89  void onConnectComponent() override;
90  void onDisconnectComponent() override;
91  void onExitComponent() override;
92 
93  // HandUnitListener interface
94  void reportHandShaped(const std::string&, const std::string&, const Ice::Current&) override;
95  void reportNewHandShapeName(const std::string&, const std::string&, const Ice::Current&) override;
96 
97 
98  // inherited of ArmarXWidget
99  static QString GetWidgetName()
100  {
101  return "RobotControl.HandUnitGUI";
102  }
103  static QIcon GetWidgetIcon()
104  {
105  return QIcon("://icons/hand.svg");
106  }
107 
108  QPointer<QDialog> getConfigDialog(QWidget* parent = 0) override;
109  void loadSettings(QSettings* settings) override;
110  void saveSettings(QSettings* settings) override;
111  void configured() override;
112 
113  public slots:
114 
115  void preshapeLeftHand();
116  void preshapeRightHand();
117  void setLeftHandJointAngles();
121  void openLeftHand();
122  void openRightHand();
123  void closeLeftHand();
124  void closeRightHand();
125  void relaxLeftHand();
126  void relaxRightHand();
127  void updateInfoLabel();
128  void updateJointValueTable();
129  void selectLeftHandJoint(int i);
130  void selectRightHandJoint(int i);
131 
132  private:
133  void setLeftHandPreshape(std::string preshape);
134  void setRightHandPreshape(std::string preshape);
135 
136  protected:
137  void initGUIJointFrames();
138 
139  Ui::HandUnitGuiPlugin ui;
140 
141  private:
142  std::string leftHandName;
143  std::string rightHandName;
144  //std::string preshapeName;
145 
146  std::string leftHandUnitProxyName;
147  std::string rightHandUnitProxyName;
148  HandUnitInterfacePrx leftHandUnitProxy;
149  HandUnitInterfacePrx rightHandUnitProxy;
150 
151  //QPointer<QWidget> __widget;
152  QPointer<HandUnitConfigDialog> dialog;
153 
154  PeriodicTask<HandUnitWidget>::pointer_type setLeftHandJointAngleUpdateTask;
155  PeriodicTask<HandUnitWidget>::pointer_type setRightHandJointAngleUpdateTask;
156  PeriodicTask<HandUnitWidget>::pointer_type displayJointAngleUpdateTask;
157  QTimer* updateInfoTimer;
158  bool setLeftHandJointAnglesFlag;
159  bool setRightHandJointAnglesFlag;
160  std::basic_string<char> currentLeftHandJoint;
161  std::basic_string<char> currentRightHandJoint;
162  double leftHandConversionFactor= 1.0 / 100.0;
163  double rightHandConversionFactor = 1.0 / 100.0;
164 
165 
166  // HandUnitListener interface
167  public:
168  void reportJointAngles(const::armarx::NameValueMap& actualJointAngles, const Ice::Current&) override;
169  void reportJointPressures(const::armarx::NameValueMap& actualJointPressures, const Ice::Current&) override;
170  };
171  using HandUnitGuiPluginPtr = std::shared_ptr<HandUnitWidget>;
172 }
173 
armarx::HandUnitWidget::selectLeftHandJoint
void selectLeftHandJoint(int i)
Definition: HandUnitGuiPlugin.cpp:355
armarx::HandUnitWidget::GetWidgetName
static QString GetWidgetName()
Definition: HandUnitGuiPlugin.h:99
armarx::HandUnitWidget::setRightHandJointAngles
void setRightHandJointAngles()
Definition: HandUnitGuiPlugin.cpp:233
armarx::HandUnitWidget::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: HandUnitGuiPlugin.cpp:76
armarx::HandUnitWidget::selectRightHandJoint
void selectRightHandJoint(int i)
Definition: HandUnitGuiPlugin.cpp:376
armarx::ArmarXGuiPlugin
Definition: ArmarXGuiPlugin.h:46
armarx::HandUnitGuiPluginPtr
std::shared_ptr< HandUnitWidget > HandUnitGuiPluginPtr
Definition: HandUnitGuiPlugin.h:171
armarx::HandUnitWidget::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: HandUnitGuiPlugin.cpp:148
armarx::HandUnitWidget::requestSetLeftHandJointAngles
void requestSetLeftHandJointAngles()
Definition: HandUnitGuiPlugin.cpp:278
armarx::HandUnitWidget
Definition: HandUnitGuiPlugin.h:77
PeriodicTask.h
armarx::HandUnitGuiPlugin
This plugin offers a widget witch which the HandUnit can be controlled.
Definition: HandUnitGuiPlugin.h:51
armarx::HandUnitWidget::updateJointValueTable
void updateJointValueTable()
Definition: HandUnitGuiPlugin.cpp:324
armarx::HandUnitWidget::loadSettings
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
Definition: HandUnitGuiPlugin.cpp:409
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
armarx::HandUnitWidget::reportJointAngles
void reportJointAngles(const ::armarx::NameValueMap &actualJointAngles, const Ice::Current &) override
Definition: HandUnitGuiPlugin.cpp:507
armarx::HandUnitWidget::openLeftHand
void openLeftHand()
Definition: HandUnitGuiPlugin.cpp:288
armarx::HandUnitWidget::openRightHand
void openRightHand()
Definition: HandUnitGuiPlugin.cpp:293
armarx::HandUnitWidget::preshapeRightHand
void preshapeRightHand()
Definition: HandUnitGuiPlugin.cpp:183
armarx::HandUnitWidget::reportJointPressures
void reportJointPressures(const ::armarx::NameValueMap &actualJointPressures, const Ice::Current &) override
Definition: HandUnitGuiPlugin.cpp:512
ArmarXGuiInterface
The main gui interface.
Definition: ArmarXGuiInterface.h:74
ArmarXGuiPlugin.h
armarx::HandUnitWidget::saveSettings
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
Definition: HandUnitGuiPlugin.cpp:417
ArmarXComponentWidgetController.h
armarx::HandUnitGuiPlugin::HandUnitGuiPlugin
HandUnitGuiPlugin()
Definition: HandUnitGuiPlugin.cpp:46
armarx::HandUnitWidget::setLeftHandJointAngles
void setLeftHandJointAngles()
Definition: HandUnitGuiPlugin.cpp:188
armarx::HandUnitGuiPlugin::getPluginName
QString getPluginName() override
Definition: HandUnitGuiPlugin.h:59
armarx::HandUnitWidget::closeRightHand
void closeRightHand()
Definition: HandUnitGuiPlugin.cpp:303
armarx::HandUnitWidget::getConfigDialog
QPointer< QDialog > getConfigDialog(QWidget *parent=0) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
Definition: HandUnitGuiPlugin.cpp:160
armarx::HandUnitWidget::GetWidgetIcon
static QIcon GetWidgetIcon()
Definition: HandUnitGuiPlugin.h:103
armarx::HandUnitWidget::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: HandUnitGuiPlugin.cpp:68
armarx::HandUnitWidget::ui
Ui::HandUnitGuiPlugin ui
Definition: HandUnitGuiPlugin.h:139
armarx::HandUnitWidget::reportHandShaped
void reportHandShaped(const std::string &, const std::string &, const Ice::Current &) override
Definition: HandUnitGuiPlugin.cpp:497
armarx::HandUnitWidget::relaxRightHand
void relaxRightHand()
Definition: HandUnitGuiPlugin.cpp:313
armarx::HandUnitWidget::HandUnitWidget
HandUnitWidget()
Definition: HandUnitGuiPlugin.cpp:51
Component.h
armarx::HandUnitWidget::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: HandUnitGuiPlugin.cpp:156
armarx::control::njoint_controller::platform::platform_follower_controller::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformFollowerController.h:91
armarx::HandUnitWidget::relaxLeftHand
void relaxLeftHand()
Definition: HandUnitGuiPlugin.cpp:308
IceUtil::Handle
Definition: forward_declarations.h:29
armarx::HandUnitWidget::updateInfoLabel
void updateInfoLabel()
Definition: HandUnitGuiPlugin.cpp:318
armarx::HandUnitWidget::reportNewHandShapeName
void reportNewHandShapeName(const std::string &, const std::string &, const Ice::Current &) override
Definition: HandUnitGuiPlugin.cpp:502
armarx::HandUnitWidget::closeLeftHand
void closeLeftHand()
Definition: HandUnitGuiPlugin.cpp:298
armarx::HandUnitWidget::initGUIJointFrames
void initGUIJointFrames()
Definition: HandUnitGuiPlugin.cpp:426
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::HandUnitWidget::requestSetRightHandJointAngles
void requestSetRightHandJointAngles()
Definition: HandUnitGuiPlugin.cpp:283
armarx::HandUnitWidget::~HandUnitWidget
~HandUnitWidget() override
Definition: HandUnitGuiPlugin.h:84
armarx::HandUnitWidget::configured
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
Definition: HandUnitGuiPlugin.cpp:172
armarx::HandUnitWidget::preshapeLeftHand
void preshapeLeftHand()
Definition: HandUnitGuiPlugin.cpp:178