-
Notifications
You must be signed in to change notification settings - Fork 48
/
mainShowcase.cpp
executable file
·62 lines (39 loc) · 1.62 KB
/
mainShowcase.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
#define DEBUG // TODO activate DEBUG in PlannerSettings.h
#include "base/PlannerSettings.h"
#include "steer_functions/POSQ/POSQSteering.h"
#include "metrics/PathLengthMetric.h"
#include "planners/OMPLPlanner.hpp"
#include "planners/ThetaStar.h"
#include "gui/PathEvaluation.h"
#include "PostSmoothing.h"
namespace og = ompl::geometric;
int main(int argc, char **argv)
{
PlannerSettings::initializeSteering();
QtVisualizer::initialize();
std::vector<Rectangle> obstacles;
obstacles.emplace_back(Rectangle(10, 0, 15, 15));
obstacles.emplace_back(Rectangle(26, 10, 31, 25));
PlannerSettings::environment = Environment::createFromObstacles(obstacles, 40, 25);
PlannerSettings::environment->setStart(Tpoint(5, 3));
PlannerSettings::environment->setGoal(Tpoint(36, 22));
QtVisualizer::visualize(*PlannerSettings::environment, 0);
auto *planner = new ThetaStar;
if (!planner->run())
return EXIT_FAILURE;
std::vector<Tpoint> path = planner->solutionPath();
std::vector<GNode> trajectory = planner->solutionTrajectory();
PlannerUtils::updateAngles(trajectory);
path = PlannerUtils::toSteeredTrajectoryPoints(trajectory);
QtVisualizer::drawPath(path, Qt::black, 2);
QtVisualizer::drawNodes(trajectory, false, Qt::black);
std::vector<GNode> smoothed(trajectory);
PostSmoothing::smooth(smoothed, path);
auto smoothedTrajPoints = PlannerUtils::toSteeredTrajectoryPoints(smoothed);
QColor c(Qt::magenta);
c.setAlpha(150);
QPen oPen(c, 3.);
QtVisualizer::drawPath(smoothedTrajPoints, oPen);
QtVisualizer::show();
return QtVisualizer::exec();
}