Fawkes API  Fawkes Development Version
astar_search.h
1 
2 /***************************************************************************
3  * astar_search.h - A colli-specific A* search implementation
4  *
5  * Created: Fri Oct 18 15:16:23 2013
6  * Copyright 2002 Stefan Jacobs
7  * 2013 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_ASTAR_SEARCH_H_
24 #define _PLUGINS_COLLI_SEARCH_ASTAR_SEARCH_H_
25 
26 #include "abstract_search.h"
27 
28 #include <memory>
29 #include <vector>
30 
31 namespace fawkes {
32 
33 class LaserOccupancyGrid;
34 class AStarColli;
35 class Logger;
36 class Configuration;
37 
38 typedef struct point_struct point_t;
39 
40 /** This is the plan class.
41  * Here the plan from A* is managed and cut into small pieces.
42  * Also usable methods for managing the plan are implemented here.
43  */
44 class Search : public AbstractSearch
45 {
46 public:
47  Search(LaserOccupancyGrid *occ_grid, Logger *logger, Configuration *config);
48  virtual ~Search();
49 
50  ///\brief update complete plan things
51  void update(int robo_x, int robo_y, int target_x, int target_y);
52 
53  ///\brief returns, if the update was successful or not.
54  bool updated_successful();
55 
56  ///\brief Get the current plan
57  std::vector<point_t> *get_plan();
58 
59  ///\brief Get the robot's position in the grid, used for the plan
61 
62 private:
63  /** Returns the current, modified waypoint to drive to. */
64  point_t calculate_local_target();
65 
66  /** Adjust the waypoint if it is not the final point. */
67  point_t adjust_waypoint(const point_t &local_target);
68 
69  /** Returns the current trajectory point to drive to. */
70  point_t calculate_local_trajec_point();
71 
72  /** Method for checking if an obstacle is between two points. */
73  bool is_obstacle_between(const point_t &a, const point_t &b, const int maxcount);
74 
75  std::unique_ptr<AStarColli> astar_; /**< the A* search algorithm */
76  std::vector<point_t> plan_; /**< the local representation of the plan */
77 
78  point_t robo_position_, target_position_;
79  bool updated_successful_;
80  int
81  cfg_search_line_allowed_cost_max_; /**< the config value for the max allowed costs on the line search on the a-star result */
82 
83  fawkes::Logger *logger_;
84 };
85 
86 } // namespace fawkes
87 
88 #endif
fawkes::point_struct
Point with cartesian coordinates as signed integers.
Definition: types.h:41
fawkes::point_t
struct fawkes::point_struct point_t
Point with cartesian coordinates as signed integers.
Definition: astar.h:45
fawkes::Logger
Definition: logger.h:41
fawkes
fawkes::Search::get_plan
std::vector< point_t > * get_plan()
Get the current plan.
Definition: astar_search.cpp:122
fawkes::Search::Search
Search(LaserOccupancyGrid *occ_grid, Logger *logger, Configuration *config)
Constructor.
Definition: astar_search.cpp:51
fawkes::Search::~Search
virtual ~Search()
Destructor.
Definition: astar_search.cpp:62
fawkes::Search::get_robot_position
point_t get_robot_position()
Get the robot's position in the grid, used for the plan.
Definition: astar_search.cpp:131
fawkes::Search::updated_successful
bool updated_successful()
returns, if the update was successful or not.
Definition: astar_search.cpp:113
fawkes::Search::update
void update(int robo_x, int robo_y, int target_x, int target_y)
update complete plan things
Definition: astar_search.cpp:74