LookAtClickWidgetController.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 VisionX::gui-plugins::LookAtClickWidgetController
17  * @author [Author Name] ( [Author Email] )
18  * @date 2020
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 #pragma once
23 
25 
29 
30 #include <RobotAPI/interface/units/KinematicUnitInterface.h>
32 
34 #include <VisionX/gui-plugins/LookAtClick/ui_LookAtClickWidget.h>
35 
36 #include "LookAtClick.h"
37 
38 namespace armarx
39 {
40  /**
41  \page VisionX-GuiPlugins-LookAtClick LookAtClick
42  \brief The LookAtClick allows visualizing ...
43 
44  \image html LookAtClick.png
45  The user can
46 
47  API Documentation \ref LookAtClickWidgetController
48 
49  \see LookAtClickGuiPlugin
50  */
51 
52  /**
53  * \class LookAtClickWidgetController
54  * \brief LookAtClickWidgetController brief one line description
55  *
56  * Detailed description
57  */
60  public armarx::ArmarXComponentWidgetControllerTemplate < LookAtClickWidgetController >,
61  virtual public visionx::ImageProcessor,
62  virtual public RobotStateComponentPluginUser
63  {
64  Q_OBJECT
65 
66  public:
67  /**
68  * Controller Constructor
69  */
70  explicit LookAtClickWidgetController();
71 
72  /**
73  * Controller destructor
74  */
75  virtual ~LookAtClickWidgetController();
76 
77  /**
78  * @see ArmarXWidgetController::loadSettings()
79  */
80  void loadSettings(QSettings* settings) override;
81 
82  /**
83  * @see ArmarXWidgetController::saveSettings()
84  */
85  void saveSettings(QSettings* settings) override;
86 
87  /**
88  * Returns the Widget name displayed in the ArmarXGui to create an
89  * instance of this class.
90  */
91  static QString GetWidgetName()
92  {
93  return "RobotControl.LookAtClick";
94  }
95 
96  /**
97  * \see armarx::Component::onInitImageProcessor()
98  */
99  void onInitImageProcessor() override;
100 
101  /**
102  * \see armarx::Component::onConnectImageProcessor()
103  */
104  void onConnectImageProcessor() override;
105 
106  void process();
107  QPointer<QDialog> getConfigDialog(QWidget* parent) override;
108  void configured() override;
109 
110 
111  void timerEvent(QTimerEvent*);
112 
113  public slots:
114  /* QT slot declarations */
115  void clickedAt(const QPoint& point);
116  signals:
117  /* QT signal declarations */
118 
119  protected:
120  private:
121 
122  void autoDetectRobotSpecificVariables();
123  void refreshWidgetData(float* factorPitch, float* factorYaw);
124  void determineNewAngles(const QPoint& offset, NameValueMap& jointAngles, NameControlModeMap& jointModes, float factorPitch, float factorYaw);
125  /**
126  * Widget Form
127  */
128 
129  Ui::LookAtClickWidget widget;
130 
131  LookAtClick* _turnOnClick{nullptr};
132 
133  VirtualRobot::RobotPtr _robot;
134 
135  std::string _pitchJointName;
136  std::string _yawJointName;
137  float _inverseYaw;
138  QPointer<SimpleConfigDialog> _dialog;
139 
140  KinematicUnitInterfacePrx kinematicUnitInterfacePrx;
141  std::string _robotStateUnitComponentName;
142  std::string _kinematicUnitInterfaceName;
143  visionx::ImageProviderInterfacePrx _imageProvider;
144  std::string _imageProviderName;
145  visionx::ImageProviderInfo _imageProviderInfo;
146  std::atomic_int _imageIndex{0};
147  std::atomic_int _numberOfImages{1};
148 
149  std::vector<visionx::CByteImageUPtr> _providerImagesOwner;
150  std::vector<void*> _providerImages;
151 
152  QImage _currentImage;
153  std::mutex _currentImageMutex;
154  std::atomic_bool _currentImageDirty{false};
155 
156  // ImageProcessor interface
157  protected:
159  };
160 }
161 
162 
LookAtClick
Definition: LookAtClick.h:9
RobotStateComponentPlugin.h
visionx::ImageProcessor
The ImageProcessor class provides an interface for access to ImageProviders via Ice and shared memory...
Definition: ImageProcessor.h:87
LookAtClick.h
armarx::navigation::platform_controller::platform_global_trajectory::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformGlobalTrajectoryController.h:93
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
SimpleConfigDialog.h
visionx::ImageProviderInfo
Definition: ImageProcessor.h:466
ArmarXGuiPlugin.h
ArmarXComponentWidgetController.h
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
ImageProcessor.h
armarx::channels::KinematicUnitObserver::jointAngles
const KinematicUnitDatafieldCreator jointAngles("jointAngles")
armarx::LookAtClickWidgetController
LookAtClickWidgetController brief one line description.
Definition: LookAtClickWidgetController.h:58
armarx::LookAtClickWidgetController::onExitImageProcessor
void onExitImageProcessor()
Exit the ImapeProcessor component.
Definition: LookAtClickWidgetController.h:158
armarx::RobotStateComponentPluginUser
Definition: RobotStateComponentPlugin.h:167
armarx::LookAtClickWidgetController::GetWidgetName
static QString GetWidgetName()
Returns the Widget name displayed in the ArmarXGui to create an instance of this class.
Definition: LookAtClickWidgetController.h:91
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
ImportExportComponent.h