MIRA
PositionTask.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_POSITIONTASK_H_
48 #define _MIRA_POSITIONTASK_H_
49 
50 #include <geometry/Point.h>
51 
52 #include <navigation/Task.h>
53 
54 namespace mira { namespace navigation {
55 
57 
67 class PositionTask : public SubTask
68 {
69  MIRA_OBJECT(PositionTask);
70 public:
71 
72  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
73 
76  position(Point2f(0.0, 0.0)),
77  minTolerance(0.0f),
78  maxTolerance(0.0f),
79  frameID("/GlobalFrame")
80  {}
81 
89  PositionTask(const Point2f& pos, float maxT,
90  const std::string& f = "/GlobalFrame") :
91  position(pos),
92  minTolerance(maxT),
93  maxTolerance(maxT),
94  frameID(f)
95  {}
96 
104  PositionTask(const Point2f& pos, float minT, float maxT,
105  const std::string& f = "/GlobalFrame") :
106  position(pos),
107  minTolerance(minT<maxT?minT:maxT),
108  maxTolerance(maxT>minT?maxT:minT),
109  frameID(f)
110  {}
111 
113  template<typename Reflector>
114  void reflect(Reflector& r)
115  {
117  r.property("Position", position,
118  "The request position.");
119  r.property("MinTolerance", minTolerance,
120  "The minimum tolerance/lower limit for path planner hysteresis.");
121  r.property("MaxTolerance", maxTolerance,
122  "The maximum tolerance/upper limit for path planner hysteresis.");
123  r.property("FrameID", frameID,
124  "The frame the position is related to.", "/GlobalFrame");
125  }
126 
128  bool reached(const Point2f& pos) const
129  {
130  return hypotf(position.x()-pos.x(),
131  position.y()-pos.y()) <= maxTolerance;
132  }
133 
134 public:
137 
140 
143 
145  std::string frameID;
146 };
147 
149 
150 }}
151 
152 #endif
PositionTask(const Point2f &pos, float minT, float maxT, const std::string &f="/GlobalFrame")
Creates a task with given position and tolerances.
Definition: PositionTask.h:104
EIGEN_MAKE_ALIGNED_OPERATOR_NEW PositionTask()
Creates a task with both tolerances 0.
Definition: PositionTask.h:75
Point2f position
The request position.
Definition: PositionTask.h:136
float maxTolerance
The maximum tolerance/upper limit for path planner hysteresis.
Definition: PositionTask.h:142
PositionTask(const Point2f &pos, float maxT, const std::string &f="/GlobalFrame")
Creates a task with given position and one tolerance that is used for both min and max tolerance...
Definition: PositionTask.h:89
#define MIRA_REFLECT_BASE(reflector, BaseClass)
bool reached(const Point2f &pos) const
Calculates if the task is reached for the current position pos.
Definition: PositionTask.h:128
Task for driving to a given position providing two limits for a hysteresis that can be applied when c...
Definition: PositionTask.h:67
std::string frameID
The frame the position is related to.
Definition: PositionTask.h:145
void reflect(Reflector &r)
The reflect method.
Definition: PositionTask.h:114
Interface for sub tasks to be added to a navigation task.
Definition: Task.h:63
Base classes and interfaces for navigation tasks.
float minTolerance
The minimum tolerance/lower limit for path planner hysteresis.
Definition: PositionTask.h:139