se2ez
plan_constraint.cpp
Go to the documentation of this file.
1
/* Author: Zachary Kingston */
2
3
#include <iostream>
4
5
#include <ompl/base/Constraint.h>
6
#include <ompl/base/ConstrainedSpaceInformation.h>
7
#include <ompl/base/spaces/constraint/ProjectedStateSpace.h>
8
9
#include <ompl/geometric/SimpleSetup.h>
10
#include <ompl/geometric/planners/rrt/RRTConnect.h>
11
#include <ompl/geometric/planners/prm/PRM.h>
12
#include <ompl/geometric/planners/est/BiEST.h>
13
14
#include <thread>
15
#include <chrono>
16
17
#include <
se2ez/core.h
>
18
#include <
se2ez/plan.h
>
19
#include <
se2ez/gui.h
>
20
#include <
se2ez/gui/planpanel.h
>
21
22
using namespace
se2ez
;
23
24
int
main
(
int
argc,
char
**argv)
25
{
26
if
(argc < 5)
27
{
28
std::cout
<<
"Usage: ./plan_constraint [filename] [start] [goal] [constraint]"
<<
std::endl
;
29
return
-1;
30
}
31
32
auto
robot =
io::loadRobot
(
std::string
(argv[1]));
33
if
(!robot)
34
return
-1;
35
36
auto
constraints =
plan::loadConstraints
(robot,
std::string
(argv[1]));
37
auto
constraint = constraints.find(
std::string
(argv[4]));
38
if
(constraint == constraints.end())
39
{
40
SE2EZ_ERROR
(
"Constraint %1% does not exist in %2%!"
, argv[4], argv[1]);
41
return
-1;
42
}
43
44
plan::EZPlansConstraint
planner(robot, constraint->second,
plan::PROJECTION
);
45
planner.
initialize
();
46
47
planner.
setPlanner
(
"prm:PRM"
);
48
planner.
setStartGoal
(
std::string
(argv[2]),
std::string
(argv[3]));
49
50
ompl::base::PlannerStatus solved = planner.
setup
->solve(10.0);
51
52
if
(solved)
53
{
54
std::cout
<<
"Found solution!"
<<
std::endl
;
55
auto
&path = planner.
setup
->getSolutionPath();
56
path.interpolate();
57
}
58
else
59
{
60
std::cout
<<
"No solution found"
<<
std::endl
;
61
return
0;
62
}
63
64
QApplication a(argc, argv);
65
gui::MainWindow
gui;
66
67
auto
panel =
new
gui::PlanPanel
(robot,
"Robot1"
);
68
gui.
addPanel
(panel);
69
gui.show();
70
71
panel->setPath(planner.
extractPath
());
72
73
return
a.exec();
74
}
se2ez::plan::EZPlans::setup
ompl::geometric::SimpleSetupPtr setup
Definition:
helper.h:93
se2ez::io::loadRobot
RobotPtr loadRobot(const std::string &filename)
Loads a robot from a YAML file.
Definition:
yaml.cpp:303
se2ez::plan::EZPlans::extractPath
std::vector< StatePtr > extractPath() const
Definition:
helper.cpp:205
se2ez::gui::MainWindow
The main widget that acts a container for other widgets (canvas, panels). It also delegates the drawi...
Definition:
mainwindow.h:34
std::endl
T endl(T... args)
core.h
se2ez::gui::MainWindow::addPanel
void addPanel(Panel *panel)
Adds a panel to the main GUI.
Definition:
mainwindow.cpp:95
std::string
se2ez::plan::PROJECTION
Definition:
helper.h:102
main
int main(int argc, char **argv)
Definition:
plan_constraint.cpp:24
se2ez::gui::PlanPanel
Definition:
planpanel.h:44
se2ez::plan::EZPlans::setPlanner
std::shared_ptr< T > setPlanner(Args &&... args)
Definition:
helper.h:45
plan.h
se2ez::plan::loadConstraints
std::map< std::string, ompl::base::ConstraintPtr > loadConstraints(const RobotPtr &robot, const std::string &filename)
Definition:
yaml.cpp:135
se2ez
Main namespace.
Definition:
collision.h:11
se2ez::plan::EZPlansConstraint::initialize
void initialize() override
Definition:
helper.cpp:240
SE2EZ_ERROR
#define SE2EZ_ERROR(fmt,...)
Definition:
log.h:39
std::cout
gui.h
se2ez::plan::EZPlansConstraint
Definition:
helper.h:111
planpanel.h
se2ez::plan::EZPlans::setStartGoal
bool setStartGoal(const std::string &start, const std::string &goal)
Definition:
helper.cpp:118
script
plan
plan_constraint.cpp
Generated on Tue Mar 10 2020 10:17:50 for se2ez by
1.8.13