-
Notifications
You must be signed in to change notification settings - Fork 11
/
DWA.h
61 lines (60 loc) · 1.31 KB
/
DWA.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
56
57
58
59
60
61
#include <vector>
#include <queue>
#include <thread>
class DWA{
typedef std::vector<std::vector<int>> cluster_vector;
typedef std::vector<std::vector<std::pair<float, float>>> VMap;
public:
DWA(){
errno_t err;
err = fopen_s(&fptr, "Log.txt", "w");
if (err != 0){
printf("open file failure...\n");
}
head_direction = 90;
targetMask();
}
~DWA(){
fclose(fptr);
}
void twoThread();
volatile bool flag = false;
volatile int head_direction ;
private:
struct arima_laserscan
{
std::vector<float> ranges;
std::vector<float> angles;
};
struct slope_range
{
float r_right;
float r_left;
float r;
float y;
};
void targetMask(){
for (int i = 0; i < 101; i++){
if (i < 50)
mask.push_back((float)i / 50.0F);
else if (i == 50)
mask.push_back(1);
else
mask.push_back((float)(100 - i) / 50.0F);
}
}
void robotHead(int);
void motorThread(int);
void laserThread(int);
int cal_DWA(arima_laserscan);
cluster_vector cluster(arima_laserscan&);
std::queue<arima_laserscan> global_laserscan;
std::vector<float> mask;
int count_frame = 0;
int count_obs, count_backup;
int pre_v = 50;
volatile float robot_head = 90.0F;
float time_lapsed = 0;
bool Lock = false, trap = false, Lclose = false, Rclose = false;
FILE* fptr;
};