se2ez
plan_yaml.cpp
Go to the documentation of this file.
1 /* Author: Zachary Kingston */
2 
3 #include <iostream>
4 
5 #include <ompl/geometric/SimpleSetup.h>
6 #include <ompl/geometric/planners/rrt/RRTConnect.h>
7 
8 #include <se2ez/core.h>
9 #include <se2ez/plan.h>
10 
11 using namespace se2ez;
12 
13 int main(int argc, char **argv)
14 {
15  if (argc < 2)
16  {
17  std::cout << "Please give filename to load!" << std::endl;
18  return -1;
19  }
20 
21  auto robot = io::loadRobot(std::string(argv[1]));
22  if (!robot)
23  return -1;
24 
25  plan::EZPlans planner(robot);
26  planner.initialize();
27  planner.setPlanner("rrt:RRTConnect");
28  planner.setStartGoal("start", "goal");
29 
30  ompl::base::PlannerStatus solved = planner.setup->solve(1.0);
31 
32  if (solved)
33  {
34  std::cout << "Found solution:" << std::endl;
35  planner.setup->getSolutionPath().print(std::cout);
36 
37  std::cout << "Simplified solution:" << std::endl;
38  planner.setup->simplifySolution();
39  planner.setup->getSolutionPath().interpolate();
40  planner.setup->getSolutionPath().print(std::cout);
41  }
42  else
43  std::cout << "No solution found" << std::endl;
44 }
ompl::geometric::SimpleSetupPtr setup
Definition: helper.h:93
RobotPtr loadRobot(const std::string &filename)
Loads a robot from a YAML file.
Definition: yaml.cpp:303
T endl(T... args)
virtual void initialize()
Definition: helper.cpp:52
std::shared_ptr< T > setPlanner(Args &&... args)
Definition: helper.h:45
int main(int argc, char **argv)
Definition: plan_yaml.cpp:13
Main namespace.
Definition: collision.h:11
bool setStartGoal(const std::string &start, const std::string &goal)
Definition: helper.cpp:118