Fawkes API  Fawkes Development Version
abstract_search.h
1 
2 /***************************************************************************
3  * abstract_search.h - An abstract class for a search in an occupancy grid
4  *
5  * Created: Fri Oct 18 15:16:23 2013
6  * Copyright 2002 Stefan Jacobs
7  * 2013-2014 Bahram Maleki-Fard
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef _PLUGINS_COLLI_SEARCH_ABSTRACTSEARCH_H_
24 #define _PLUGINS_COLLI_SEARCH_ABSTRACTSEARCH_H_
25 
26 #include "../common/types.h"
27 #include "og_laser.h"
28 
29 #include <logging/logger.h>
30 #include <utils/math/types.h>
31 
32 namespace fawkes {
33 
34 /** @class AbstractSearch <plugins/colli/search/abstract_search.h>
35  * This is the abstract search interpretation class for an arbitrary
36  * search algorithm to find its way through
37  * an Occupancy grid from a robopos to a targetpos.
38  */
39 
40 class AbstractSearch
41 {
42 public:
43  AbstractSearch(LaserOccupancyGrid *occ_grid, Logger *logger);
44  virtual ~AbstractSearch();
45 
46  /** update complete plan things
47  * precondition: the occupancy grid has to be updated previously!
48  * @param robo_x Robot x position in grid
49  * @param robo_y Robot y position in grid
50  * @param target_x Target x position in grid
51  * @param target_y Target y position in grid
52  */
53  virtual void update(int robo_x, int robo_y, int target_x, int target_y) = 0;
54 
55  /** Checks if the update was successful.
56  * @return true if "update(...)" was successful, fals otherwise.
57  */
58  virtual bool updated_successful() = 0;
59 
60  /** return pointer to the local target. do not modify afterwards
61  * precondition: update has to be called before this is ok here
62  */
63  const point_t &get_local_target();
64 
65  /** return pointer to the local trajectory point. do not modify afterwards
66  * precondition: update has to be called before this is ok here
67  */
68  const point_t &get_local_trajec();
69 
70 protected:
71  LaserOccupancyGrid *occ_grid_; /**< The occupancy grid */
72 
73  point_t local_target_; /**< the calculated target where to drive to */
74  point_t local_trajec_; /**< the calculated trajectory where to drive to */
75 
76  colli_cell_cost_t cell_costs_; /**< The costs for cells in occupancy grid */
77 };
78 
79 /** Constructor.
80  * @param occ_grid The laser occupancy-grid
81  * @param logger The fawkes logger
82  */
84 {
85  logger->log_debug("AbstractSearch", "(Constructor): Entering");
86  occ_grid_ = occ_grid;
88  logger->log_debug("AbstractSearch", "(Constructor): Exiting");
89 }
90 
91 /** Destructor. */
93 {
94 }
95 
96 /** Get the local target in the grid.
97  * @return The local target in grid as a point_t struct
98  */
99 inline const point_t &
101 {
102  return local_target_;
103 }
104 
105 /** Get the local trajectory in the grid.
106  * @return The local trajectory in grid as a point_t struct
107  */
108 inline const point_t &
110 {
111  return local_trajec_;
112 }
113 
114 } // namespace fawkes
115 
116 #endif
fawkes::AbstractSearch::~AbstractSearch
virtual ~AbstractSearch()
Destructor.
Definition: abstract_search.h:96
fawkes::point_struct
Point with cartesian coordinates as signed integers.
Definition: types.h:40
fawkes::AbstractSearch::get_local_target
const point_t & get_local_target()
return pointer to the local target.
Definition: abstract_search.h:104
fawkes::AbstractSearch::local_target_
point_t local_target_
the calculated target where to drive to
Definition: abstract_search.h:77
fawkes::AbstractSearch::local_trajec_
point_t local_trajec_
the calculated trajectory where to drive to
Definition: abstract_search.h:78
fawkes::AbstractSearch::get_local_trajec
const point_t & get_local_trajec()
return pointer to the local trajectory point.
Definition: abstract_search.h:113
fawkes::MultiLogger::log_debug
virtual void log_debug(const char *component, const char *format,...)
Definition: multi.cpp:178
fawkes::AbstractSearch::cell_costs_
colli_cell_cost_t cell_costs_
The costs for cells in occupancy grid.
Definition: abstract_search.h:80
fawkes::Logger
Definition: logger.h:40
fawkes
fawkes::AbstractSearch::update
virtual void update(int robo_x, int robo_y, int target_x, int target_y)=0
update complete plan things precondition: the occupancy grid has to be updated previously!
fawkes::AbstractSearch::updated_successful
virtual bool updated_successful()=0
Checks if the update was successful.
fawkes::LaserOccupancyGrid::get_cell_costs
colli_cell_cost_t get_cell_costs() const
Get cell costs.
Definition: og_laser.cpp:477
fawkes::AbstractSearch::occ_grid_
LaserOccupancyGrid * occ_grid_
The occupancy grid.
Definition: abstract_search.h:75
fawkes::colli_cell_cost_t
Costs of occupancy-grid cells.
Definition: types.h:54
fawkes::AbstractSearch::AbstractSearch
AbstractSearch(LaserOccupancyGrid *occ_grid, Logger *logger)
Constructor.
Definition: abstract_search.h:87
fawkes::LaserOccupancyGrid
Definition: og_laser.h:51