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