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 */
28
31
32#include <RobotAPI/interface/units/HandUnitInterface.h>
33
34/* Qt headers */
35#include <string>
36
37#include <QMainWindow>
38
40
41// C++ includes
42#include <memory>
43
44// ui_HandUnitGuiPlugin.h is included by the .cpp, not here: moc textually inlines every
45// #include it can resolve, and parsing the uic-generated header alongside this one
46// makes moc mis-qualify this class as Ui::armarx::*.
47namespace Ui
48{
49 class HandUnitGuiPlugin;
50}
51
52namespace armarx
53{
55
56 /**
57 \class HandUnitGuiPlugin
58 \brief This plugin offers a widget witch which the HandUnit can be controlled.
59 \see HandUnitWidget
60 */
62 {
63 Q_OBJECT
64 Q_INTERFACES(ArmarXGuiInterface)
65 Q_PLUGIN_METADATA(IID "ArmarXGuiInterface/1.00")
66 public:
68
69 QString
70 getPluginName() override
71 {
72 return "HandUnitGuiPlugin";
73 }
74 };
75
76 /*!
77 * \page RobotAPI-GuiPlugins-HandUnitWidget HandUnitGuiPlugin
78 * \brief With this widget the HandUnit can be controlled.
79 * \image html HandUnitGUI.png
80 * You can either select a preshape from the drop-down-menu on top or set each
81 * joint individually.
82 * When you add the widget to the Gui, you need to specify the following parameters:
83 *
84 * Parameter Name | Example Value | Required? | Description
85 * :---------------- | :-------------: | :-------------- |:--------------------
86 * Proxy | LeftHandUnit | Yes | The hand unit you want to control.
87 */
89 public ArmarXComponentWidgetControllerTemplate<HandUnitWidget>,
90 public HandUnitListener
91 {
92 Q_OBJECT
93 public:
95
96 // Defined in the .cpp, where Ui::HandUnitGuiPlugin is complete.
97 ~HandUnitWidget() override;
98 // inherited from Component
99 void onInitComponent() override;
100 void onConnectComponent() override;
101 void onDisconnectComponent() override;
102 void onExitComponent() override;
103
104 // HandUnitListener interface
105 void reportHandShaped(const std::string&, const std::string&, const Ice::Current&) override;
106 void reportNewHandShapeName(const std::string&,
107 const std::string&,
108 const Ice::Current&) override;
109
110 // inherited of ArmarXWidget
111 static QString
113 {
114 return "RobotControl.HandUnitGUI";
115 }
116
117 static QIcon
119 {
120 return QIcon("://icons/hand.svg");
121 }
122
123 QPointer<QDialog> getConfigDialog(QWidget* parent = 0) override;
124 void loadSettings(QSettings* settings) override;
125 void saveSettings(QSettings* settings) override;
126 void configured() override;
127
128 enum class side
129 {
132 };
133
134 public slots:
135
136 void preshapeLeftHand();
137 void preshapeRightHand();
142 void openLeftHand();
143 void openRightHand();
144 void closeLeftHand();
145 void closeRightHand();
146 void relaxLeftHand();
147 void relaxRightHand();
148 void updateInfoLabel();
150 void setExpertMode(side side, int state);
151 void tareHand(bool checked, side side);
152 void rebootHand(side side);
153 void selectLeftHandJoint(int i);
154 void selectRightHandJoint(int i);
155
156 void reloadPreshapes();
157
158 private:
159 void setLeftHandPreshape(std::string preshape);
160 void setRightHandPreshape(std::string preshape);
161
162 protected:
163 void initGUIJointFrames();
164
165 std::unique_ptr<Ui::HandUnitGuiPlugin> ui;
166
167 private:
168 std::string leftHandName;
169 std::string rightHandName;
170 //std::string preshapeName;
171
172 std::string leftHandUnitProxyName;
173 std::string rightHandUnitProxyName;
174 HandUnitInterfacePrx leftHandUnitProxy;
175 HandUnitInterfacePrx rightHandUnitProxy;
176
177 //QPointer<QWidget> __widget;
178 QPointer<HandUnitConfigDialog> dialog;
179
180 PeriodicTask<HandUnitWidget>::pointer_type setLeftHandJointAngleUpdateTask;
181 PeriodicTask<HandUnitWidget>::pointer_type setRightHandJointAngleUpdateTask;
182 PeriodicTask<HandUnitWidget>::pointer_type displayJointAngleUpdateTask;
183 QTimer* updateInfoTimer;
184 bool setLeftHandJointAnglesFlag;
185 bool setRightHandJointAnglesFlag;
186 std::basic_string<char> currentLeftHandJoint;
187 std::basic_string<char> currentRightHandJoint;
188 double leftHandConversionFactor = 1.0 / 100.0;
189 double rightHandConversionFactor = 1.0 / 100.0;
190
191 // HandUnitListener interface
192 public:
193 void reportJointAngles(const ::armarx::NameValueMap& actualJointAngles,
194 const Ice::Current&) override;
195 void reportJointPressures(const ::armarx::NameValueMap& actualJointPressures,
196 const Ice::Current&) override;
197 };
198
199 using HandUnitGuiPluginPtr = std::shared_ptr<HandUnitWidget>;
200} // namespace armarx
The main gui interface.
QString getPluginName() override
void tareHand(bool checked, side side)
void onInitComponent() override
Pure virtual hook for the subclass.
void onDisconnectComponent() override
Hook for subclass.
std::unique_ptr< Ui::HandUnitGuiPlugin > ui
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
void reportJointPressures(const ::armarx::NameValueMap &actualJointPressures, const Ice::Current &) override
QPointer< QDialog > getConfigDialog(QWidget *parent=0) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
void reportHandShaped(const std::string &, const std::string &, const Ice::Current &) override
void onConnectComponent() override
Pure virtual hook for the subclass.
void setExpertMode(side side, int state)
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
void reportNewHandShapeName(const std::string &, const std::string &, const Ice::Current &) override
static QString GetWidgetName()
void onExitComponent() override
Hook for subclass.
~HandUnitWidget() override
void reportJointAngles(const ::armarx::NameValueMap &actualJointAngles, const Ice::Current &) override
IceUtil::Handle< PeriodicTask< T > > pointer_type
Shared pointer type for convenience.
ArmarX Headers.
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< HandUnitWidget > HandUnitGuiPluginPtr