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
36 #include <RobotComponents/interface/components/RobotIK.h>
37 #include <RobotAPI/interface/core/RobotState.h>
40 
41 //Qt includes
42 #include <QObject>
43 
44 //VirtualRobot includes
45 #include <VirtualRobot/Robot.h>
46 #include <VirtualRobot/Visualization/CoinVisualization/CoinVisualization.h>
47 
48 //Inventor includes
49 #include <Inventor/sensors/SoTimerSensor.h>
50 #include <Inventor/manips/SoTransformerManip.h>
51 #include <Inventor/nodes/SoSphere.h>
52 #include <Inventor/nodes/SoMaterial.h>
53 
54 
55 namespace armarx
56 {
57 
59  {
60  Q_OBJECT
61  Q_INTERFACES(ArmarXGuiInterface)
62  Q_PLUGIN_METADATA(IID "ArmarXGuiInterface/1.00")
63  public:
65 
66  QString getPluginName() override
67  {
68  return "RobotIKGuiPlugin";
69  }
70  };
71 
94  // * \ingroup RobotAPI-ArmarXGuiPlugins ArmarXGuiPlugins
95 
96  class RobotIKWidgetController : public ArmarXComponentWidgetControllerTemplate<RobotIKWidgetController>
97  {
98  Q_OBJECT
99 
100  public:
103 
104  // inherited from Component
105  void onInitComponent() override;
106  void onConnectComponent() override;
107  void onDisconnectComponent() override;
108  void onExitComponent() override;
109 
110  // inherited of ArmarXWidget
111  static QString GetWidgetName()
112  {
113  return "RobotControl.RobotIK";
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  public slots:
121  void initWidget();
122  void solveIK();
123  void kinematicChainChanged(const QString& arg1);
124  void caertesianSelectionChanged(const QString& arg1);
125  void autoFollowChanged(bool checked);
126  void resetManip();
127  void updateSolutionDisplay();
128  void showCurrentRobotChanged(bool checked);
129  void showPreviewRobotChanged(bool checked);
130 
131  protected:
132  RobotStateComponentInterfacePrx robotStateComponentPrx;
133  KinematicUnitInterfacePrx kinematicUnitInterfacePrx;
134  RobotIKInterfacePrx robotIKPrx;
135 
136  Ui::RobotIKGuiPlugin ui;
137 
138  private slots:
139  void on_btnCopyCurrentPoseToClipboard_clicked();
140  void onDisconnect();
141 
142  void updatePreviewRobot();
143  void on_btnSetDesiredPose_clicked();
144  void executeMotion();
145 
146  private:
147  void ikCallbackExecuteMotion(const Ice::AsyncResultPtr& r);
148  void ikCallbackDisplaySolution(const Ice::AsyncResultPtr& r);
149  void connectSlots();
150  std::string robotStateComponentName;
151  std::string kinematicUnitComponentName;
152  std::string robotIKComponentName;
153 
154  QPointer<SimpleConfigDialog> dialog;
155 
156  VirtualRobot::RobotPtr robot;
157  Ice::StringSeq getIncludePaths() const;
158  VirtualRobot::RobotPtr loadRobot(Ice::StringSeq includePaths);
159 
160  ManipulatorVisualization* visualization;
161 
162  static void manipFinishCallback(void* data, SoDragger* manip);
163  static void manipMovedCallback(void* data, SoDragger* manip);
164 
165  SoTimerSensor* robotUpdateSensor;
166  static void robotUpdateTimerCB(void* data, SoSensor* sensor);
167 
168  SoTimerSensor* textFieldUpdateSensor;
169  static void textFieldUpdateTimerCB(void* data, SoSensor* sensor);
170 
171  SoTimerSensor* autoFollowSensor;
172  static void autoFollowSensorTimerCB(void* data, SoSensor* sensor);
173  bool manipulatorMoved;
174 
175  static void startIKSolving(RobotIKWidgetController* controller);
176  ExtendedIKResult improveCurrentSolution(ExtendedIKResult& solution);
177  VirtualRobot::RobotPtr cartesianControlRobot;
178  ExtendedIKResult getIKSolution() const;
179 
180  CartesianSelection convertOption(std::string option) const;
181 
182  bool startUpCameraPositioningFlag;
183  Mutex solutionMutex;
184  armarx::ExtendedIKResult currentSolution;
185 
186  VirtualRobot::RobotPtr previewRobot;
187  VirtualRobot::CoinVisualizationPtr previewRobotVisualization;
188  VirtualRobot::CoinVisualizationPtr currentRobotVisualization;
189  };
190  using RobotIKGuiPluginPtr = std::shared_ptr<RobotIKWidgetController>;
192 }
193 
armarx::RobotIKGuiPlugin::RobotIKGuiPlugin
RobotIKGuiPlugin()
Definition: RobotIKGuiPlugin.cpp:54
armarx::RobotIKWidgetController::showPreviewRobotChanged
void showPreviewRobotChanged(bool checked)
Definition: RobotIKGuiPlugin.cpp:388
RemoteRobot.h
armarx::RobotIKWidgetController::getConfigDialog
QPointer< QDialog > getConfigDialog(QWidget *parent=0) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
Definition: RobotIKGuiPlugin.cpp:208
armarx::RobotIKWidgetController::RobotIKWidgetController
RobotIKWidgetController()
Definition: RobotIKGuiPlugin.cpp:59
armarx::RobotIKWidgetController::initWidget
void initWidget()
Definition: RobotIKGuiPlugin.cpp:241
boost::shared_ptr< VirtualRobot::CoinVisualization >
armarx::RobotIKWidgetController::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: RobotIKGuiPlugin.cpp:203
armarx::ArmarXGuiPlugin
Definition: ArmarXGuiPlugin.h:46
armarx::RobotIKWidgetController::showCurrentRobotChanged
void showCurrentRobotChanged(bool checked)
Definition: RobotIKGuiPlugin.cpp:369
ManipulatorVisualization.h
armarx::RobotIKWidgetController::saveSettings
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
Definition: RobotIKGuiPlugin.cpp:227
armarx::RobotIKWidgetController::~RobotIKWidgetController
virtual ~RobotIKWidgetController()
Definition: RobotIKGuiPlugin.h:102
armarx::RobotIKWidgetController::caertesianSelectionChanged
void caertesianSelectionChanged(const QString &arg1)
Definition: RobotIKGuiPlugin.cpp:323
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
SimpleConfigDialog.h
armarx::RobotIKWidgetController::kinematicChainChanged
void kinematicChainChanged(const QString &arg1)
Definition: RobotIKGuiPlugin.cpp:290
ArmarXGuiInterface
The main gui interface.
Definition: ArmarXGuiInterface.h:74
armarx::RobotIKWidgetController::loadSettings
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
Definition: RobotIKGuiPlugin.cpp:220
ArmarXGuiPlugin.h
armarx::RobotIKWidgetController
Definition: RobotIKGuiPlugin.h:96
armarx::RobotIKWidgetController::resetManip
void resetManip()
Definition: RobotIKGuiPlugin.cpp:332
controller
Definition: AddOperation.h:39
ArmarXComponentWidgetController.h
armarx::RobotIKWidgetController::GetWidgetName
static QString GetWidgetName()
Definition: RobotIKGuiPlugin.h:111
CoinVisualizationPtr
boost::shared_ptr< VirtualRobot::CoinVisualization > CoinVisualizationPtr
Definition: ManipulatorVisualization.h:52
armarx::RobotIKWidgetController::robotStateComponentPrx
RobotStateComponentInterfacePrx robotStateComponentPrx
Definition: RobotIKGuiPlugin.h:132
armarx::RobotIKWidgetController::configured
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
Definition: RobotIKGuiPlugin.cpp:234
Synchronization.h
armarx::RobotIKGuiPlugin
Definition: RobotIKGuiPlugin.h:58
armarx::RobotIKGuiPluginPtr
std::shared_ptr< RobotIKWidgetController > RobotIKGuiPluginPtr
Definition: RobotIKGuiPlugin.h:190
option
#define option(type, fn)
armarx::RobotIKWidgetController::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: RobotIKGuiPlugin.cpp:198
armarx::RobotIKWidgetController::solveIK
void solveIK()
Definition: RobotIKGuiPlugin.cpp:254
armarx::RobotIKWidgetController::robotIKPrx
RobotIKInterfacePrx robotIKPrx
Definition: RobotIKGuiPlugin.h:134
armarx::RobotIKGuiPlugin::getPluginName
QString getPluginName() override
Definition: RobotIKGuiPlugin.h:66
armarx::ManipulatorVisualization
Definition: ManipulatorVisualization.h:51
armarx::RobotIKWidgetController::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: RobotIKGuiPlugin.cpp:83
armarx::Mutex
boost::mutex Mutex
Definition: Synchronization.h:131
armarx::RobotIKWidgetController::autoFollowChanged
void autoFollowChanged(bool checked)
Definition: RobotIKGuiPlugin.cpp:741
armarx::RobotIKWidgetController::kinematicUnitInterfacePrx
KinematicUnitInterfacePrx kinematicUnitInterfacePrx
Definition: RobotIKGuiPlugin.h:133
armarx::RobotIKWidgetController::updateSolutionDisplay
void updateSolutionDisplay()
Definition: RobotIKGuiPlugin.cpp:338
armarx::RobotIKWidgetController::ui
Ui::RobotIKGuiPlugin ui
Definition: RobotIKGuiPlugin.h:136
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::RobotIKWidgetController::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: RobotIKGuiPlugin.cpp:73