MIRA
PoseTool.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 by
3  * MetraLabs GmbH (MLAB), GERMANY
4  * and
5  * Neuroinformatics and Cognitive Robotics Labs (NICR) at TU Ilmenau, GERMANY
6  * All rights reserved.
7  *
8  * Contact: info@mira-project.org
9  *
10  * Commercial Usage:
11  * Licensees holding valid commercial licenses may use this file in
12  * accordance with the commercial license agreement provided with the
13  * software or, alternatively, in accordance with the terms contained in
14  * a written agreement between you and MLAB or NICR.
15  *
16  * GNU General Public License Usage:
17  * Alternatively, this file may be used under the terms of the GNU
18  * General Public License version 3.0 as published by the Free Software
19  * Foundation and appearing in the file LICENSE.GPL3 included in the
20  * packaging of this file. Please review the following information to
21  * ensure the GNU General Public License version 3.0 requirements will be
22  * met: http://www.gnu.org/copyleft/gpl.html.
23  * Alternatively you may (at your option) use any later version of the GNU
24  * General Public License if such license has been publicly approved by
25  * MLAB and NICR (or its successors, if any).
26  *
27  * IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
28  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
29  * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
30  * "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
33  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
34  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
35  * ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
36  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
37  */
38 
47 #ifndef _MIRA_POSETOOL_H_
48 #define _MIRA_POSETOOL_H_
49 
50 #ifndef Q_MOC_RUN
51 #include <OGRE/OgreRenderWindow.h>
52 #include <OGRE/OgreSceneManager.h>
53 #endif
54 
55 #include <transform/Pose.h>
56 
60 
61 namespace mira {
62 
64 
70 {
71  enum SelectionMode
72  {
73  Position,
74  PositionVariance,
75  Orientation,
76  OrientationVariance,
77  };
78 
79  enum InputMode
80  {
81  PoseInput,
82  PositionInput,
83  OrientationInput
84  };
85 
86 public:
87  struct InputModePosition {};
89 
90 public:
93 
100  PoseTool(float minPositionVariance = 0.1f,
101  float minOrientationVariance = 0.25f);
102 
112  float minPositionVariance = 0.1f,
113  float minOrientationVariance = 0.25f);
114 
127  float minOrientationVariance = 0.25f,
128  float minPositionVariance = 0.1f);
130 
131  template <typename Reflector>
132  void reflect(Reflector& r)
133  {
135  // TODO: remove these conditions if InputMode is made mutable at runtime
136  if ((mInputMode == PoseInput) || (mInputMode == PositionInput)) {
137  r.property("MinPositionVariance", mMinPositionVariance,
138  "The smallest allowed position variance.", 0.1f,
139  PropertyHints::minimum(0.001f));
140  }
141  if ((mInputMode == PoseInput) || (mInputMode == OrientationInput)) {
142  r.property("MinOrientationVariance", mMinOrientationVariance,
143  "The smallest allowed orientation variance.", 0.25f,
144  PropertyHints::minimum(0.001f));
145  }
146  }
147 
148 public:
151  virtual void onMousePressed(QMouseEvent* e);
152 
153  virtual void onMouseReleased(QMouseEvent* e);
154 
155  virtual void onMouseMoved(QMouseEvent* e);
156 
158 
159 protected:
162 
163  virtual void setupScene(IVisualization3DSite* site);
164 
166 
167 protected:
170 
183  virtual void onNewPose(const PoseCov2& pose) {}
184 
195  virtual void onNewPosition(const Point2f& position,
196  float xRange, float yRange) {}
197 
207  virtual void onNewOrientation(const Anglef& orientation,
208  float range) {}
210 
211 private:
212 
213  std::pair<std::string, Ogre::Vector3> getIntersection(float x, float y,
214  const std::string& mask="");
215 
216  void showCovariances(const PoseCov2::CovMatrixType& cov);
217 
218 private:
219 
220  boost::shared_ptr<AxesObject> mAxesObject;
221  boost::shared_ptr<AxesCovObject> mAxesCovObject;
222  boost::shared_ptr<CovObject> mCovObject;
223  SelectionMode mSelectionMode;
224  std::string mSelectedObject;
225  Ogre::Vector3 mLastPos;
226  QPoint mLastGlobalPos;
227  bool mIsValid;
228 
229  const InputMode mInputMode; // for now this is fixed, set at construction
230  float mMinPositionVariance;
231  float mMinOrientationVariance;
232 
233  PoseCov2 mPose;
234 };
235 
237 
238 }
239 
240 #endif
virtual void onNewOrientation(const Anglef &orientation, float range)
A new orientation was selected by the user.
Definition: PoseTool.h:207
The interface of a Visualization3DSite.
Definition: Visualization3D.h:84
Definition: SceneQueryTool.h:60
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
#define MIRA_REFLECT_BASE(reflector, BaseClass)
Macro that can be used to reflect the base class easily.
Definition: ReflectorInterface.h:912
Definition: PoseTool.h:88
Base class for 3D tools querying scene.
Definition: PoseTool.h:87
Visualization of covariances.
void reflect(Reflector &r)
Definition: PoseTool.h:132
#define MIRA_GUI_VISUALIZATION_EXPORT
Definition: GuiVisualizationExports.h:61
PropertyHint minimum(const T &min)
Sets the attribute "minimum" to the specified value.
Definition: PropertyHint.h:243
Tool base class for selecting a PoseCov2 pose in the xy-plane of a 3D scene (in a Visualization3DView...
Definition: PoseTool.h:69
virtual void onNewPosition(const Point2f &position, float xRange, float yRange)
A new position was selected by the user.
Definition: PoseTool.h:195
Visualization of covariance for axes.
Typedefs for different Pose datatypes that are internally RigidTransforms.
virtual void onNewPose(const PoseCov2 &pose)
A new pose was selected by the user.
Definition: PoseTool.h:183
Unsigned angle that is represented using radians.
Definition: Angle.h:717