-
Notifications
You must be signed in to change notification settings - Fork 1
/
dstar_env.h
55 lines (38 loc) · 907 Bytes
/
dstar_env.h
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
#pragma once
#ifndef DSTAR_ENV_H
#define DSTAR_ENV
#include <iostream>
#include <vector>
#include <cmath>
#include <unordered_map>
using namespace std;
struct hash_pair {
template <class T1, class T2>
size_t operator()(
const pair<T1, T2>& x)
const {
return x.first ^ x.second;
}
};
struct grid {
public:
grid(string id_) :id(id_), g(FLT_MAX), rhs(FLT_MAX), status(0) {};
string id;
unordered_map<pair<int,int>, float, hash_pair> preds;
unordered_map<pair<int,int>, float, hash_pair> succs;
float g;
float rhs;
float status;
};
class Environment {
protected:
int x_dim;
int y_dim;
vector<vector<grid>> cells;
float linearCost = 1.0;
float diagonalCost = sqrt(2.0);
Environment(int x_dim_, int y_dim_) :x_dim(x_dim_), y_dim(y_dim_) { generateCells(); };
private:
void generateCells();
};
#endif // !DSTAR_ENV_H