-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
62 lines (44 loc) · 1.09 KB
/
main.cpp
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
//main.cpp
#include <iostream>
#include <opencv2/opencv.hpp>
#include "robot_project.h"
int main(int argc, char* argv[])
{
//MENU
// std::cout << "Please choose an option: " << std::endl;
if (argc != 2)
{
std::cout << "Usage: " << argv[0] << " <image>" << std::endl;
return 0;
}
std::string filename = argv[1];
cv::Mat img = cv::imread(filename);
if (filename.empty())
{
throw std::runtime_error("Could not open image " + filename);
}
RobotProject rp(argc, argv);
if (!rp.preprocessMap(img))
{
std::cerr << "(Critical) Failed to preprocess map" << std::endl;
return false;
}
Path path;
if (!rp.planPath(img, path))
{
std::cerr << "(Critical) Failed to plan path" << std::endl;
return false;
}
int count = 0;
while (count<10)
{
std::vector<double> state;
if (!rp.localize(img, state))
{
std::cerr << "(Warning) Failed localization" << std::endl;
continue;
}
count++;
}
return 0;
}