MIRA
CostMap.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 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  * Redistribution and modification of this code is strictly prohibited.
9  *
10  * IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
11  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
12  * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
13  * "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14  *
15  * "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
16  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
18  * ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
19  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
20  */
21 
30 #ifndef _MIRA_COSTMAP_H_
31 #define _MIRA_COSTMAP_H_
32 
33 #include <maps/GridMap.h>
34 
35 namespace mira { namespace maps {
36 
38 
39 class CostMap : public GridMap<double>
40 {
41 public:
43 
44  CostMap() {}
45 
46  CostMap(const Base& map, const std::string& iFrameID) : Base(map), frameID(iFrameID) {}
47 
48  CostMap(const Size2i& size, float cellSize,
49  const Point2i& offset = Point2i(0, 0),
50  const std::string& iFrameID = "") : Base(size, cellSize, offset), frameID(iFrameID) {}
51 
53  {
54  Base::operator=(c);
55  return *this;
56  }
57 
58  CostMap clone() const {
59  return CostMap(Base::clone(), frameID);
60  }
61 
66  Point2f getGradient(const Point2i& mapPos) const {
67  Point2f value = Point2f(0.0, 0.0);
68  if(mapPos.x() <= 0 || (int)mapPos.x() >= width()-1 ||
69  mapPos.y() <= 0 || (int)mapPos.y() >= height()-1 )
70  return value;
71 
72  value = Point2f((operator()(mapPos.x()-1,mapPos.y()) - operator()(mapPos.x()+1,mapPos.y()))/2.0,
73  (operator()(mapPos.x(),mapPos.y()-1) - operator()(mapPos.x(),mapPos.y()+1))/2.0);
74  return value;
75  }
76 
77 public:
78  std::string frameID;
79 };
80 
82 typedef std::list<Rect2i> DirtyRegions;
83 typedef std::list<Rect2f> DirtyRegionsWorld;
84 
86 
88 
89 }}
90 
91 #endif
std::list< Rect2f > DirtyRegionsWorld
Definition: CostMap.h:83
GridMap clone() const
Definition: GridMap.h:148
Img< double, 1 > operator()(const cv::Rect &roi)
Definition: CostMap.h:39
Point2f getGradient(const Point2i &mapPos) const
Returns the gradient per cell.
Definition: CostMap.h:66
Size2i size() const
Definition: GridMap.h:67
Description.
Point< int, 2 > Point2i
std::string frameID
Definition: CostMap.h:78
CostMap(const Size2i &size, float cellSize, const Point2i &offset=Point2i(0, 0), const std::string &iFrameID="")
Definition: CostMap.h:48
Base::Pixel CellType
Definition: GridMap.h:79
std::list< Rect2i > DirtyRegions
Dirty regions stored as vector of rects.
Definition: CostMap.h:82
CostMap(const Base &map, const std::string &iFrameID)
Definition: CostMap.h:46
CostMap()
Definition: CostMap.h:44
CostMap & operator=(const CellType &c)
Definition: CostMap.h:52
Point< float, 2 > Point2f
CostMap clone() const
Definition: CostMap.h:58
GridMap & operator=(const CellType &c)
Definition: GridMap.h:143
DirtyRegions mergeRegions(DirtyRegions regions)
GridMap< double > Base
Definition: CostMap.h:42