44 #include "boost/program_options.hpp"
45 #include "../PlanarManipulator/PolyWorld.h"
46 #include "../PlanarManipulator/PlanarManipulatorPolyWorld.h"
47 #include "../PlanarManipulator/PlanarManipulator.h"
48 #include "../PlanarManipulator/PlanarManipulatorStateSpace.h"
49 #include "../PlanarManipulator/PlanarManipulatorStateValidityChecker.h"
50 #include "../PlanarManipulator/PlanarManipulatorIKGoal.h"
51 #include "MultiLevelPlanarManipulatorCommon.h"
53 #include <ompl/geometric/planners/rrt/RRTConnect.h>
54 #include <ompl/geometric/planners/rrt/RRT.h>
55 #include <ompl/base/spaces/SE2StateSpace.h>
56 #include <ompl/base/spaces/RealVectorStateSpace.h>
57 #include <ompl/multilevel/planners/qrrt/QRRT.h>
58 #include <ompl/multilevel/planners/qmp/QMP.h>
60 #include <ompl/multilevel/datastructures/Projection.h>
61 #include <ompl/multilevel/datastructures/projections/SE2_R2.h>
77 : Projection(bundle, base), manip_(manip)
82 void project(
const State *xBundle,
State *xBase)
const
84 std::vector<double> reals;
85 getBundle()->copyToReals(reals, xBundle);
87 Eigen::Affine2d eeFrame;
88 manip_->FK(reals, eeFrame);
90 double x = eeFrame.translation()(0);
91 double y = eeFrame.translation()(1);
92 double yaw = acos(eeFrame.matrix()(0, 0));
97 getBundle()->printState(xBundle);
98 getBase()->printState(xBase);
101 void lift(
const State *xBase,
State *xBundle)
const
103 std::vector<double> reals;
104 getBase()->copyToReals(reals, xBase);
107 Eigen::Affine2d eeFrame;
108 eeFrame.translation()(0) = reals.at(0);
109 eeFrame.translation()(1) = reals.at(1);
110 eeFrame.rotate(reals.at(2));
112 std::vector<double> solution;
113 manip_->FABRIK(solution, eeFrame);
116 for (uint k = 0; k < solution.size(); k++)
118 angles[k] = solution.at(k);
128 Eigen::Affine2d baseFrame;
129 Eigen::Affine2d goalFrame;
132 PolyWorld world = createCorridorProblem(numLinks, baseFrame, goalFrame);
139 bounds.setLow(-M_PI);
140 bounds.setHigh(M_PI);
142 manipulator.setBounds(bounds.low, bounds.high);
145 si->setStateValidityChecker(std::make_shared<PlanarManipulatorCollisionChecker>(si, manipulator, &world));
146 si->setStateValidityCheckingResolution(0.001);
153 boundsWorkspace.setLow(-2);
154 boundsWorkspace.setHigh(+2);
158 siSE2->setStateValidityChecker(std::make_shared<SE2CollisionChecker>(siSE2, &world));
159 siSE2->setStateValidityCheckingResolution(0.001);
178 ompl::multilevel::ProjectionPtr projAB = std::make_shared<ProjectionJointSpaceToSE2>(space, spaceSE2, &manipulator);
187 std::vector<SpaceInformationPtr> siVec;
188 std::vector<ompl::multilevel::ProjectionPtr> projVec;
192 siVec.push_back(siSE2);
193 projVec.push_back(projAB);
196 auto planner = std::make_shared<ompl::multilevel::QRRT>(siVec, projVec);
204 for (
int i = 0; i < numLinks; ++i)
206 start_angles[i] = 1e-1*(pow(-1,i)) + i*1e-3;
216 std::vector<double> goalJoints;
217 manipulator.IK(goalJoints, goalFrame);
220 goal_angles[0] = 0.346324;
221 goal_angles[1] = 0.0828153;
222 goal_angles[2] = 2.96842;
223 goal_angles[3] = -2.17559;
224 goal_angles[4] = -0.718962;
225 goal_angles[5] = 0.16532;
226 goal_angles[6] = -0.228314;
227 goal_angles[7] = 0.172762;
230 pdef->addStartState(start);
231 pdef->setGoalState(goal, 1e-3);
233 si->freeState(start);
239 planner->setProblemDefinition(pdef);
247 PathPtr path = pdef->getSolutionPath();
252 WriteVisualization(manipulator, &world, pgeo);