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  */
59  public armarx::ArmarXComponentWidgetControllerTemplate<LookAtClickWidgetController>,
60  virtual public visionx::ImageProcessor,
61  virtual public RobotStateComponentPluginUser
62  {
63  Q_OBJECT
64 
65  public:
66  /**
67  * Controller Constructor
68  */
69  explicit LookAtClickWidgetController();
70 
71  /**
72  * Controller destructor
73  */
74  virtual ~LookAtClickWidgetController();
75 
76  /**
77  * @see ArmarXWidgetController::loadSettings()
78  */
79  void loadSettings(QSettings* settings) override;
80 
81  /**
82  * @see ArmarXWidgetController::saveSettings()
83  */
84  void saveSettings(QSettings* settings) override;
85 
86  /**
87  * Returns the Widget name displayed in the ArmarXGui to create an
88  * instance of this class.
89  */
90  static QString
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  void autoDetectRobotSpecificVariables();
122  void refreshWidgetData(float* factorPitch, float* factorYaw);
123  void determineNewAngles(const QPoint& offset,
125  NameControlModeMap& jointModes,
126  float factorPitch,
127  float factorYaw);
128  /**
129  * Widget Form
130  */
131 
132  Ui::LookAtClickWidget widget;
133 
134  LookAtClick* _turnOnClick{nullptr};
135 
136  VirtualRobot::RobotPtr _robot;
137 
138  std::string _pitchJointName;
139  std::string _yawJointName;
140  float _inverseYaw;
141  QPointer<SimpleConfigDialog> _dialog;
142 
143  KinematicUnitInterfacePrx kinematicUnitInterfacePrx;
144  std::string _robotStateUnitComponentName;
145  std::string _kinematicUnitInterfaceName;
146  visionx::ImageProviderInterfacePrx _imageProvider;
147  std::string _imageProviderName;
148  visionx::ImageProviderInfo _imageProviderInfo;
149  std::atomic_int _imageIndex{0};
150  std::atomic_int _numberOfImages{1};
151 
152  std::vector<visionx::CByteImageUPtr> _providerImagesOwner;
153  std::vector<void*> _providerImages;
154 
155  QImage _currentImage;
156  std::mutex _currentImageMutex;
157  std::atomic_bool _currentImageDirty{false};
158 
159  // ImageProcessor interface
160  protected:
161  void
163  {
164  }
165  };
166 } // namespace armarx
LookAtClick
Definition: LookAtClick.h:8
RobotStateComponentPlugin.h
visionx::ImageProcessor
The ImageProcessor class provides an interface for access to ImageProviders via Ice and shared memory...
Definition: ImageProcessor.h:98
LookAtClick.h
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
SimpleConfigDialog.h
visionx::ImageProviderInfo
Definition: ImageProcessor.h:479
ArmarXGuiPlugin.h
ArmarXComponentWidgetController.h
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
ImageProcessor.h
armarx::control::njoint_controller::platform::platform_follower_controller::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformFollowerController.h:88
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:162
armarx::RobotStateComponentPluginUser
Definition: RobotStateComponentPlugin.h:165
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:27
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:19
ImportExportComponent.h