CartesianNaturalPositionControllerWidgetController.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 RobotAPI::gui-plugins::CartesianNaturalPositionControllerWidgetController
17  * @author armar-user ( armar-user at kit dot edu )
18  * @date 2020
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 #pragma once
23 
24 #include <mutex>
25 
26 #include <VirtualRobot/Robot.h>
27 
29 
33 
34 #include <RobotAPI/gui-plugins/CartesianNaturalPositionController/ui_CartesianNaturalPositionControllerWidget.h>
35 #include <RobotAPI/interface/core/RobotState.h>
36 #include <RobotAPI/interface/units/RobotUnit/RobotUnitInterface.h>
38 
39 namespace armarx
40 {
41  /**
42  \page armarx_control-GuiPlugins-CartesianNaturalPositionController CartesianNaturalPositionController
43  \brief The CartesianNaturalPositionController allows visualizing ...
44 
45  \image html CartesianNaturalPositionController.png
46  The user can
47 
48  API Documentation \ref CartesianNaturalPositionControllerWidgetController
49 
50  \see CartesianNaturalPositionControllerGuiPlugin
51  */
52 
53  /**
54  * \class CartesianNaturalPositionControllerWidgetController
55  * \brief CartesianNaturalPositionControllerWidgetController brief one line description
56  *
57  * Detailed description
58  */
61  CartesianNaturalPositionControllerWidgetController>
62  {
63  Q_OBJECT
64 
65  public:
67  {
68  QCheckBox* checkBox;
69  QSlider* slider;
70  QLabel* label;
71  size_t i;
72  };
73 
74  /**
75  * Controller Constructor
76  */
78 
79  /**
80  * Controller destructor
81  */
83 
84  /**
85  * @see ArmarXWidgetController::loadSettings()
86  */
87  void loadSettings(QSettings* settings) override;
88 
89  /**
90  * @see ArmarXWidgetController::saveSettings()
91  */
92  void saveSettings(QSettings* settings) override;
93 
94  /**
95  * Returns the Widget name displayed in the ArmarXGui to create an
96  * instance of this class.
97  */
98  static QString
100  {
101  return "RobotControl.NJointControllers.CartesianNaturalPositionController";
102  }
103 
104  void onInitComponent() override;
105  void onConnectComponent() override;
106  void onDisconnectComponent() override;
107 
108  QPointer<QDialog> getConfigDialog(QWidget* parent) override;
109  void configured() override;
110 
111  public slots:
112  /* QT slot declarations */
113  void onConnectComponentQt();
114  void on_pushButtonCreateController_clicked();
115  void on_anyDeltaPushButton_clicked();
116  void on_sliders_valueChanged(int);
117  void on_checkBoxAutoKp_stateChanged(int);
118  void on_checkBoxSetOri_stateChanged(int);
119  void on_anyNullspaceCheckbox_stateChanged(int);
120  void on_anyNullspaceSlider_valueChanged(int);
121  void on_horizontalSliderPosVel_valueChanged(int);
122 
123  signals:
124  /* QT signal declarations */
125  void invokeConnectComponentQt();
126  void invokeDisconnectComponentQt();
127 
128  private:
129  void deleteOldController();
130  void readRunCfgFromUi(CartesianNaturalPositionControllerConfig& runCfg);
131  void timerEvent(QTimerEvent*) override;
132  void updateTarget(const Eigen::Matrix4f& newTarget);
133  void updateKpSliders(const CartesianNaturalPositionControllerConfig& runCfg);
134  void updateKpSliderLabels(const CartesianNaturalPositionControllerConfig& runCfg);
135  void updateNullspaceTargets();
136 
137 
138  std::string _robotStateComponentName;
139  std::string _robotUnitName;
140  RobotStateComponentInterfacePrx _robotStateComponent;
141  RobotUnitInterfacePrx _robotUnit;
142  Ui::CartesianNaturalPositionControllerWidget _ui;
143  QPointer<SimpleConfigDialog> _dialog;
145  std::string _controllerName;
146  VirtualRobot::RobotPtr _robot;
147  std::vector<Eigen::Matrix4f> _lastParsedWPs;
148  bool _supportsFT{false};
149  bool _setOri = true;
150  mutable std::recursive_mutex _allMutex;
151  int _timer;
152  Eigen::Matrix4f _tcpTarget;
153 
154  std::map<QObject*, Eigen::Vector3f> _deltaMapPos;
155  std::map<QObject*, Eigen::Vector3f> _deltaMapOri;
156  //CartesianNaturalPositionControllerConfig _runCfg;
157 
158  std::vector<NullspaceTarget> _nullspaceTargets;
159  };
160 } // namespace armarx
armarx::CartesianNaturalPositionControllerWidgetController::NullspaceTarget::i
size_t i
Definition: CartesianNaturalPositionControllerWidgetController.h:71
CartesianNaturalPositionControllerProxy.h
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
SimpleConfigDialog.h
armarx::CartesianNaturalPositionControllerWidgetController
CartesianNaturalPositionControllerWidgetController brief one line description.
Definition: CartesianNaturalPositionControllerWidgetController.h:59
ArmarXGuiPlugin.h
armarx::CartesianNaturalPositionControllerWidgetController::NullspaceTarget::checkBox
QCheckBox * checkBox
Definition: CartesianNaturalPositionControllerWidgetController.h:68
ArmarXComponentWidgetController.h
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
armarx::CartesianNaturalPositionControllerWidgetController::NullspaceTarget::slider
QSlider * slider
Definition: CartesianNaturalPositionControllerWidgetController.h:69
armarx::CartesianNaturalPositionControllerWidgetController::NullspaceTarget::label
QLabel * label
Definition: CartesianNaturalPositionControllerWidgetController.h:70
armarx::CartesianNaturalPositionControllerWidgetController::NullspaceTarget
Definition: CartesianNaturalPositionControllerWidgetController.h:66
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
armarx::CartesianNaturalPositionControllerProxyPtr
std::shared_ptr< class CartesianNaturalPositionControllerProxy > CartesianNaturalPositionControllerProxyPtr
Definition: CartesianNaturalPositionControllerProxy.h:36
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::CartesianNaturalPositionControllerWidgetController::GetWidgetName
static QString GetWidgetName()
Returns the Widget name displayed in the ArmarXGui to create an instance of this class.
Definition: CartesianNaturalPositionControllerWidgetController.h:99
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
ImportExportComponent.h