-
Notifications
You must be signed in to change notification settings - Fork 0
/
PathFinder.cpp
50 lines (39 loc) · 1.21 KB
/
PathFinder.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
#include <rrt/2dplane/2dplane.hpp>
#include <rrt/2dplane/GridStateSpace.hpp>
#include <rrt/BiRRT.hpp>
using namespace std;
using namespace Eigen;
namespace RRT {
Vector2d start = {1, 1}, goal = {30, 30};
BiRRT<Vector2d> biRRT(make_shared<GridStateSpace>(50, 50, 50, 50), hash,
dimensions);
biRRT.setStartState(start);
biRRT.setGoalState(goal);
biRRT.setStepSize(1);
biRRT.setMaxIterations(10000);
bool success = biRRT.run();
ASSERT_TRUE(success);
vector<Vector2d> path = biRRT.getPath();
// path should contain at least two points (start and end)
ASSERT_GE(path.size(), 2);
// The given start and goal points should be the first and last points of
// the path, respectively.
EXPECT_EQ(start, path.front());
EXPECT_EQ(goal, path.back());
/*
TEST(BiRRT, multipleRuns) {
Vector2d start = {1, 1}, goal = {30, 30};
BiRRT<Vector2d> biRRT(make_shared<GridStateSpace>(50, 50, 50, 50), hash,
dimensions);
biRRT.setStartState(start);
biRRT.setGoalState(goal);
biRRT.setStepSize(1);
biRRT.setMaxIterations(10000);
for (int i = 0; i < 50; i++) {
bool success = biRRT.run();
ASSERT_TRUE(success);
biRRT.reset();
}
}
*/
} // namespace RRT