LaserScannerSelfLocalisationWidgetController.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 RobotComponents::gui-plugins::LaserScannerSelfLocalisationWidgetController
17  * @author Fabian Paus ( fabian dot paus at kit dot edu )
18  * @date 2017
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
25 #include <atomic>
26 
27 #include <Eigen/Eigen>
28 
31 #include <ArmarXCore/interface/core/ArmarXManagerInterface.h>
32 
36 
38 #include <RobotComponents/gui-plugins/LaserScannerSelfLocalisation/ui_LaserScannerSelfLocalisationWidget.h>
39 #include <RobotComponents/interface/components/LaserScannerSelfLocalisation.h>
40 
41 namespace armarx
42 {
43  /**
44  \page RobotComponents-GuiPlugins-LaserScannerSelfLocalisation LaserScannerSelfLocalisation
45  \brief The LaserScannerSelfLocalisation allows visualizing and configuring the self localisation process
46 
47  API Documentation \ref LaserScannerSelfLocalisationWidgetController
48 
49  \see LaserScannerSelfLocalisationGuiPlugin
50  */
51 
52  /**
53  * \class LaserScannerSelfLocalisationWidgetController
54  * \brief LaserScannerSelfLocalisationWidgetController brief one line description
55  *
56  * Detailed description
57  */
60  public armarx::LaserScannerSelfLocalisationListener
61  {
62  Q_OBJECT
63 
64  public:
65  /**
66  * Controller Constructor
67  */
69 
70  /**
71  * Controller destructor
72  */
74 
75  /**
76  * @see ArmarXWidgetController::loadSettings()
77  */
78  void loadSettings(QSettings* settings) override;
79 
80  /**
81  * @see ArmarXWidgetController::saveSettings()
82  */
83  void saveSettings(QSettings* settings) override;
84 
85  /**
86  * Returns the Widget name displayed in the ArmarXGui to create an
87  * instance of this class.
88  */
89  QString
90  getWidgetName() const override
91  {
92  return "RobotControl.LaserScannerSelfLocalisation";
93  }
94 
95  /**
96  * \see armarx::Component::onInitComponent()
97  */
98  void onInitComponent() override;
99 
100  /**
101  * \see armarx::Component::onConnectComponent()
102  */
103  void onConnectComponent() override;
104 
105  QPointer<QDialog> getConfigDialog(QWidget* parent) override;
106 
107  void configured() override;
108 
109  void onPaintCanvas(QPainter& painter, QSize size);
110 
111  // LaserScannerSelfLocalisationListener interface
112  void reportCorrectedPose(Ice::Float x,
113  Ice::Float y,
114  Ice::Float theta,
115  const Ice::Current&) override;
116  void reportPoseUncertainty(Ice::Float x,
117  Ice::Float y,
118  Ice::Float theta,
119  const Ice::Current&) override;
120 
121  //void reportExtractedEdges(const LineSegment2DSeq& edges, const Ice::Current&) override;
122  void reportLaserScanPoints(const Vector2fSeq& globalPoints, const Ice::Current&) override;
123  void reportExtractedEdges(const LineSegment2DSeq&, const Ice::Current&) override;
124 
125  public slots:
126  void onSpinBoxChanged(int value);
127  void onSpinBoxChanged(double value);
128  void onNewDataReported();
129  void onSetPoseClick();
130  void onCanvasClick(QPoint p);
131 
132  signals:
133  /* QT signal declarations */
134  void newDataReported();
135 
136  private:
137  void updateProperties();
138  void readProperties();
139 
140  enum class SetPoseState
141  {
142  None,
143  Position,
144  Wait,
145  Orientation,
146  Finished,
147  };
148 
149  protected:
150  void timerEvent(QTimerEvent* event) override;
151 
152  private:
153  Ui::LaserScannerSelfLocalisationWidget widget;
154  QPointer<SimpleConfigDialog> dialog;
155  QPainterWidget* painterWidget;
156  int paintTimerId;
157 
158  std::string localisationName;
159  LaserScannerSelfLocalisationInterfacePrx localisation;
160  ArmarXManagerInterfacePrx localisationManager;
161  Ice::PropertiesAdminPrx localisationAdmin;
162  LineSegment2DSeq map;
163 
164  std::atomic<float> poseX;
165  std::atomic<float> poseY;
166  std::atomic<float> poseTheta;
167 
168  std::atomic<float> poseUncertaintyX;
169  std::atomic<float> poseUncertaintyY;
170  std::atomic<float> poseUncertaintyTheta;
171 
172 
173  Mutex pointsMutex;
174  Vector2fSeq points;
175  LineSegment2DSeq edges;
176 
177  std::vector<QLine> lines;
178  std::vector<QPoint> qpoints;
179  std::vector<QLine> qedges;
180 
181  SetPoseState setPoseState;
182  QPoint setPosition;
183  QPoint setOrientation;
184  };
185 } // namespace armarx
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:919
GfxTL::Orientation
ScalarT Orientation(const VectorXD< 2, ScalarT > &p1, const VectorXD< 2, ScalarT > &p2, const VectorXD< 2, ScalarT > &c)
Definition: Orientation.h:10
SimpleConfigDialog.h
ArmarXGuiPlugin.h
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
QPainterWidget.h
ArmarXComponentWidgetController.h
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
Synchronization.h
armarx::Mutex
boost::mutex Mutex
Definition: Synchronization.h:149
armarx::LaserScannerSelfLocalisationWidgetController::getWidgetName
QString getWidgetName() const override
Returns the Widget name displayed in the ArmarXGui to create an instance of this class.
Definition: LaserScannerSelfLocalisationWidgetController.h:90
armarx::navigation::core::Position
Eigen::Vector3f Position
Definition: basic_types.h:36
armarx::ArmarXComponentWidgetController
Definition: ArmarXComponentWidgetController.h:38
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::LaserScannerSelfLocalisationWidgetController
LaserScannerSelfLocalisationWidgetController brief one line description.
Definition: LaserScannerSelfLocalisationWidgetController.h:58
ImportExportComponent.h