RobotIKGuiPlugin.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::
17* @author Philipp Schmidt
18* @date 2015
19* @license http://www.gnu.org/licenses/gpl-2.0.txt
20* GNU General Public License
21
22*/
23
24#pragma once
25
26//Gui
27#include <RobotComponents/gui-plugins/RobotIKPlugin/ui_RobotIKGuiPlugin.h>
28
29//Visualization
31
32//ArmarX includes
34
38
39#include <RobotAPI/interface/core/RobotState.h>
41
42#include <RobotComponents/interface/components/RobotIK.h>
43
44//Qt includes
45#include <QObject>
46
47//VirtualRobot includes
48#include <VirtualRobot/Robot.h>
49#include <VirtualRobot/Visualization/CoinVisualization/CoinVisualization.h>
50
51//Inventor includes
52#include <Inventor/manips/SoTransformerManip.h>
53#include <Inventor/nodes/SoMaterial.h>
54#include <Inventor/nodes/SoSphere.h>
55#include <Inventor/sensors/SoTimerSensor.h>
56
57namespace armarx
58{
59
61 {
62 Q_OBJECT
63 Q_INTERFACES(ArmarXGuiInterface)
64 Q_PLUGIN_METADATA(IID "ArmarXGuiInterface/1.00")
65 public:
67
68 QString
69 getPluginName() override
70 {
71 return "RobotIKGuiPlugin";
72 }
73 };
74
75 /**
76 * \class RobotIKWidget
77 * \page RobotComponents-GuiPlugins-RobotIK "The RobotIK Gui Plugin"
78 *
79 * \brief The RobotIK Gui Plugin can be used for IK computation.
80 *
81 * This gui plugin can be used for Cartesian control of a robot (arm). It connects to the KinemticUnit of the robot
82 * in order to execute the computed configurations via position control.
83 * Via the plugin the kinematic chain of the robot can be specified allowing to move different end effectors with varying subsets of the robot's joints.
84 *
85 *
86 * \image html RobotIKGui_small.png "The RobotIK Gui Plugin is used to move the right end effector of Armar-III."
87 *
88 * Demonstration video of the RobotIK Gui:
89 * \htmlonly
90 * <p align="middle">
91 * <iframe align="center" width="560" height="315" src="https://www.youtube.com/embed/jyPdg5QlcH4?rel=0?ecver=1" frameborder="0" allowfullscreen></iframe>
92 * </p>
93 * \endhtmlonly
94 *
95 *
96 */
97 // * \ingroup RobotAPI-ArmarXGuiPlugins ArmarXGuiPlugins
98
100 public ArmarXComponentWidgetControllerTemplate<RobotIKWidgetController>
101 {
102 Q_OBJECT
103
104 public:
106
108 {
109 }
110
111 // inherited from Component
112 void onInitComponent() override;
113 void onConnectComponent() override;
114 void onDisconnectComponent() override;
115 void onExitComponent() override;
116
117 // inherited of ArmarXWidget
118 static QString
120 {
121 return "RobotControl.RobotIK";
122 }
123
124 QPointer<QDialog> getConfigDialog(QWidget* parent = 0) override;
125 void loadSettings(QSettings* settings) override;
126 void saveSettings(QSettings* settings) override;
127 void configured() override;
128
129 public slots:
130 void initWidget();
131 void solveIK();
132 void kinematicChainChanged(const QString& arg1);
133 void caertesianSelectionChanged(const QString& arg1);
134 void autoFollowChanged(bool checked);
135 void resetManip();
137 void showCurrentRobotChanged(bool checked);
138 void showPreviewRobotChanged(bool checked);
139
140 protected:
142 KinematicUnitInterfacePrx kinematicUnitInterfacePrx;
143 RobotIKInterfacePrx robotIKPrx;
144
145 Ui::RobotIKGuiPlugin ui;
146
147 private slots:
148 void on_btnCopyCurrentPoseToClipboard_clicked();
149 void onDisconnect();
150
151 void updatePreviewRobot();
152 void on_btnSetDesiredPose_clicked();
153 void executeMotion();
154
155 private:
156 void ikCallbackExecuteMotion(const Ice::AsyncResultPtr& r);
157 void ikCallbackDisplaySolution(const Ice::AsyncResultPtr& r);
158 void connectSlots();
159 std::string robotStateComponentName;
160 std::string kinematicUnitComponentName;
161 std::string robotIKComponentName;
162
163 QPointer<SimpleConfigDialog> dialog;
164
166 Ice::StringSeq getIncludePaths() const;
167 VirtualRobot::RobotPtr loadRobot(Ice::StringSeq includePaths);
168
169 ManipulatorVisualization* visualization;
170
171 static void manipFinishCallback(void* data, SoDragger* manip);
172 static void manipMovedCallback(void* data, SoDragger* manip);
173
174 SoTimerSensor* robotUpdateSensor;
175 static void robotUpdateTimerCB(void* data, SoSensor* sensor);
176
177 SoTimerSensor* textFieldUpdateSensor;
178 static void textFieldUpdateTimerCB(void* data, SoSensor* sensor);
179
180 SoTimerSensor* autoFollowSensor;
181 static void autoFollowSensorTimerCB(void* data, SoSensor* sensor);
182 bool manipulatorMoved;
183
184 static void startIKSolving(RobotIKWidgetController* controller);
185 ExtendedIKResult improveCurrentSolution(ExtendedIKResult& solution);
186 VirtualRobot::RobotPtr cartesianControlRobot;
187 ExtendedIKResult getIKSolution() const;
188
189 CartesianSelection convertOption(std::string option) const;
190
191 bool startUpCameraPositioningFlag;
192 Mutex solutionMutex;
193 armarx::ExtendedIKResult currentSolution;
194
195 VirtualRobot::RobotPtr previewRobot;
196 VirtualRobot::CoinVisualizationPtr previewRobotVisualization;
197 VirtualRobot::CoinVisualizationPtr currentRobotVisualization;
198 };
199
200 using RobotIKGuiPluginPtr = std::shared_ptr<RobotIKWidgetController>;
202} // namespace armarx
#define option(type, fn)
The main gui interface.
QString getPluginName() override
void onInitComponent() override
Pure virtual hook for the subclass.
void caertesianSelectionChanged(const QString &arg1)
void onDisconnectComponent() override
Hook for subclass.
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
void kinematicChainChanged(const QString &arg1)
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
QPointer< QDialog > getConfigDialog(QWidget *parent=0) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
void onConnectComponent() override
Pure virtual hook for the subclass.
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
RobotStateComponentInterfacePrx robotStateComponentPrx
void onExitComponent() override
Hook for subclass.
KinematicUnitInterfacePrx kinematicUnitInterfacePrx
boost::mutex Mutex
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx
std::shared_ptr< RobotIKWidgetController > RobotIKGuiPluginPtr
boost::shared_ptr< VirtualRobot::CoinVisualization > CoinVisualizationPtr