-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrid_map.h
More file actions
70 lines (57 loc) · 1.36 KB
/
grid_map.h
File metadata and controls
70 lines (57 loc) · 1.36 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once
#include <iostream>
#include <graphics.h>
#include <ctime>
#include <assert.h>
#include <vector>
#include <unordered_set>
#include "config.h"
using std::cout, std::endl;
using std::vector, std::unordered_set, std::unique_ptr, std::make_unique;
namespace NAVIGATION
{
enum NodeType
{
normal,
start,
end,
obs,
way_pt
};
class Node
{
public:
Node() = default;
Node(const int& r, const int& c, const int& type = NodeType::normal); // row, col, type
void drawNode() const;
bool operator<(const Node& other_node) const { return this->f > other_node.f; } //reload <
public:
int row = 0; //row in map
int col = 0; // col in map
int f = 0; // local total cost
int g = 0; // total cost from start
int h = 0; // total cost till end
int node_type = NodeType::normal;
Node* parent_node = nullptr;
};
class GridMapBase // parent
{
public:
bool GridMapInit(const Node& start, const Node& end);
void printMap(); // console
void drawMap(); // viz
bool outOfMap(const Node& node);
virtual void addObs() = 0;
public:
vector<vector<Node>> grid_map;
Node* start_node = nullptr;
Node* end_node = nullptr;
unordered_set<Node*> obs_nodes; // hash table: fast searsh
};
class GridMap : public GridMapBase
{
public:
GridMap(const Node& start, const Node& end);
void addObs() override;
};
} // end of namespace NAVIGATION