Hybrid A* Planner
 All Classes Namespaces Files Functions Variables Friends Pages
collisiondetection.h
1 #ifndef COLLISIONDETECTION_H
2 #define COLLISIONDETECTION_H
3 
4 #include <nav_msgs/OccupancyGrid.h>
5 
6 #include "constants.h"
7 #include "lookup.h"
8 #include "node2d.h"
9 #include "node3d.h"
10 
11 namespace HybridAStar {
12 namespace {
13 void getConfiguration(const Node2D* node, float& x, float& y, float& t) {
14  x = node->getX();
15  y = node->getY();
16  // avoid 2D collision checking
17  t = 99;
18 }
19 
20 void getConfiguration(const Node3D* node, float& x, float& y, float& t) {
21  x = node->getX();
22  y = node->getY();
23  t = node->getT();
24 }
25 }
32  public:
35 
36 
41  template<typename T> bool isTraversable(const T* node) {
42  /* Depending on the used collision checking mechanism this needs to be adjusted
43  standard: collision checking using the spatial occupancy enumeration
44  other: collision checking using the 2d costmap and the navigation stack
45  */
46  float cost = 0;
47  float x;
48  float y;
49  float t;
50  // assign values to the configuration
51  getConfiguration(node, x, y, t);
52 
53  // short 2D collision test
54  if (t == 99) {
55  return !grid->data[node->getIdx()];
56  }
57 
58  if (true) {
59  cost = configurationTest(x, y, t) ? 0 : 1;
60  } else {
61  cost = configurationCost(x, y, t);
62  }
63 
64  return cost <= 0;
65  }
66 
74  float configurationCost(float x, float y, float t) {return 0;}
75 
83  bool configurationTest(float x, float y, float t);
84 
88  void updateGrid(nav_msgs::OccupancyGrid::Ptr map) {grid = map;}
89 
90  private:
92  nav_msgs::OccupancyGrid::Ptr grid;
94  Constants::config collisionLookup[Constants::headings * Constants::positions];
95 };
96 }
97 #endif // COLLISIONDETECTION_H
bool isTraversable(const T *node)
evaluates whether the configuration is safe
Definition: collisiondetection.h:41
This is a collection of constants that are used throughout the project.
The CollisionDetection class determines whether a given configuration q of the robot will result in a...
Definition: collisiondetection.h:31
void updateGrid(nav_msgs::OccupancyGrid::Ptr map)
updates the grid with the world map
Definition: collisiondetection.h:88
float configurationCost(float x, float y, float t)
Calculates the cost of the robot taking a specific configuration q int the World W.
Definition: collisiondetection.h:74
bool configurationTest(float x, float y, float t)
Tests whether the configuration q of the robot is in C_free.
Definition: collisiondetection.cpp:31
CollisionDetection()
Constructor.
Definition: collisiondetection.cpp:5
A structure capturing the lookup for each theta configuration.
Definition: constants.h:132
Constants::config collisionLookup[Constants::headings *Constants::positions]
The collision lookup table.
Definition: collisiondetection.h:94
nav_msgs::OccupancyGrid::Ptr grid
The occupancy grid.
Definition: collisiondetection.h:92