-
Notifications
You must be signed in to change notification settings - Fork 5
/
TestProbHRM3D.cpp
67 lines (55 loc) · 2.31 KB
/
TestProbHRM3D.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
63
64
65
66
67
/** \author Sipu Ruan */
#include "hrm/config.h"
#include "hrm/planners/ProbHRM3D.h"
#include "hrm/test/util/GTestUtils.h"
#include "hrm/test/util/ParsePlanningSettings.h"
TEST(TestHRMPlanning3D, ProbHRM) {
// Setup environment config
hrm::parsePlanningConfig("superquadrics", "sparse", "snake", "3D");
const int NUM_SURF_PARAM = 10;
const double MAX_PLAN_TIME = 300.0;
hrm::PlannerSetting3D env3D(NUM_SURF_PARAM);
env3D.loadEnvironment(CONFIG_PATH "/");
// Setup URDF file for the robot
std::string urdfFile;
if (env3D.getEndPoints().at(0).size() == 10) {
urdfFile = RESOURCES_PATH "/3D/urdf/snake.urdf";
} else if (env3D.getEndPoints().at(0).size() == 16) {
urdfFile = RESOURCES_PATH "/3D/urdf/tree.urdf";
} else {
std::cout << "No URDF file specified, will treat robot as a rigid body."
<< std::endl;
}
// Setup robot
const auto robot =
hrm::loadRobotMultiBody3D(CONFIG_PATH "/", "0", NUM_SURF_PARAM);
// Planning requests
hrm::PlanningRequest req;
req.isRobotRigid = false;
req.start = env3D.getEndPoints().at(0);
req.goal = env3D.getEndPoints().at(1);
hrm::defineParameters(robot, env3D, req.parameters);
// Main Algorithm
std::cout << "Prob-HRM for 3D articulated-body planning" << std::endl;
std::cout << "----------" << std::endl;
std::cout << "Input number of sweep lines {X,Y}: {"
<< req.parameters.numLineX << ',' << req.parameters.numLineY
<< '}' << std::endl;
std::cout << "----------" << std::endl;
std::cout << "Start planning..." << std::endl;
hrm::planners::ProbHRM3D probHRM(robot, urdfFile, env3D.getArena(),
env3D.getObstacle(), req);
probHRM.plan(MAX_PLAN_TIME);
hrm::PlanningResult res = probHRM.getPlanningResult();
const auto param = probHRM.getPlannerParameters();
// Planning results: Time and Path Cost
std::cout << "----------" << std::endl;
std::cout << "Number of C-slices: " << param.numSlice << std::endl;
std::cout << "Final number of sweep lines {X,Y}: {" << param.numLineX << ','
<< param.numLineY << '}' << std::endl;
hrm::evaluateResult(res);
}
int main(int ac, char* av[]) {
testing::InitGoogleTest(&ac, av);
return RUN_ALL_TESTS();
}