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