-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdmap_planner.h
More file actions
50 lines (41 loc) · 1.42 KB
/
dmap_planner.h
File metadata and controls
50 lines (41 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once
#include <Eigen/Core>
#include <Eigen/Geometry>
#include "dmap.h"
#include "grid_mapping.h"
#include <list>
struct DMapPlanner {
GridMapping mapping; // to convert from world to grid coordinates
Grid_<float> obstacle_costs; // cost of a cell based on distance
Grid_<float> distances; // useless, kept only for visualization
Grid_<float> policy; // surface pointing to the goal
Grid_<Vector2f> policy_gradients; // surface pointing to the goal
float max_traversal_cost=100;
float robot_radius=0.3;
float max_distance_range=5;
struct DijkstraCell{
DijkstraCell(DijkstraCell* p=0,
float c=std::numeric_limits<float>::max()):
parent(p),
cost(c)
{}
DijkstraCell* parent;
float cost;
};
using DijkstraGrid=Grid_<DijkstraCell>;
DijkstraGrid d_grid;
inline float traversalCost(const Vector2i& from, const Vector2i& to) const {
return sqrt((from-to).squaredNorm()) * obstacle_costs.at(to.x(), to.y());
}
void init(float resolution,
float robot_radius,
float max_range,
const DMap& dmap);
void computePolicy(const Eigen::Vector2f& goal);
float computePath(std::list<Vector2f>& path,
const Eigen::Vector2f& start_pose,
float approach_cost=-1,
size_t max_path_length=10000,
bool use_gradient=true) const;
bool policy_ok=false;
};