se2ez
plan.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()
14 {
16  std::make_shared<Geometry>(Geometry::BOX, Eigen::Vector2d{0.2, 0.2}, Eigen::Vector3d{0, 0, 0}) //
17  };
18 
20  std::make_shared<Geometry>(Geometry::BOX, Eigen::Vector2d{0.2, 0.2}, Eigen::Vector3d{0, 0, 0}), //
21  };
22 
24  std::make_shared<Geometry>(Geometry::BOX, Eigen::Vector2d{0.5, 1.5}, Eigen::Vector3d{0, 0.5, 0}), //
25  };
26 
27  auto f_1 = std::make_shared<Frame>("l1", // name
28  Eigen::Vector3d{0, 0, 0}, // tip offset
29  Joint::FLYING, // type
30  Eigen::Vector2d{-2, -2}, // lower limits
31  Eigen::Vector2d{2, 2}, // upper limits
32  geo1); // geometry
33 
34  auto f_2 = std::make_shared<Frame>("l2", // name
35  Eigen::Vector3d{0, 0, 0}, // tip offset
36  Joint::FLYING, // type
37  Eigen::Vector2d{-2, -2}, // lower limits
38  Eigen::Vector2d{2, 2}, // upper limits
39  geo2); // geometry
40 
41  auto f_b = std::make_shared<Frame>("box", // name
42  Eigen::Vector3d{0, 0, 0}, // tip offset
43  geo3); // geometry
44 
45  auto robot = std::make_shared<Robot>();
46  robot->attachFrame(f_1);
47  robot->attachFrame(f_2);
48  robot->attachFrame(f_b);
49  robot->compileTree();
50 
51  plan::EZPlans planner(robot);
52  planner.initialize();
53  planner.setPlanner<ompl::geometric::RRTConnect>();
54  planner.setStartGoal(math::toVector({-1.5, 0, 0, 1.5, 0, 0}), math::toVector({1.5, 0, 0, -1.5, 0, 0}));
55 
56  ompl::base::PlannerStatus solved = planner.setup->solve(1.0);
57 
58  if (solved)
59  {
60  std::cout << "Found solution:" << std::endl;
61  planner.setup->getSolutionPath().print(std::cout);
62 
63  std::cout << "Simplified solution:" << std::endl;
64  planner.setup->simplifySolution();
65  planner.setup->getSolutionPath().print(std::cout);
66  }
67  else
68  std::cout << "No solution found" << std::endl;
69 }
ompl::geometric::SimpleSetupPtr setup
Definition: helper.h:93
A rectangular prism.
Definition: geometry.h:33
T endl(T... args)
virtual void initialize()
Definition: helper.cpp:52
Floating joint, free movement in SE(2). Continuous rotation, uses SE(2) metric.
Definition: joint.h:42
std::shared_ptr< T > setPlanner(Args &&... args)
Definition: helper.h:45
Eigen::VectorXd toVector(double x)
Converts a single double value into a 1 x 1 matrix.
Definition: math.cpp:134
Main namespace.
Definition: collision.h:11
int main()
Definition: plan.cpp:13
bool setStartGoal(const std::string &start, const std::string &goal)
Definition: helper.cpp:118