100 group.add_argument(
"--time", type=float, default=5.0, help=
"Planning time allowed.")
178 def __init__(self, spaceType, space, constraint, options):
182 self.
constraint.setTolerance(options.tolerance)
183 self.
constraint.setMaxIterations(options.tries)
189 if spaceType ==
"PJ":
190 ou.OMPL_INFORM(
"Using Projection-Based State Space!")
193 elif spaceType ==
"AT":
194 ou.OMPL_INFORM(
"Using Atlas-Based State Space!")
197 elif spaceType ==
"TB":
198 ou.OMPL_INFORM(
"Using Tangent Bundle-Based State Space!")
203 self.
css.setDelta(options.delta)
204 self.
css.setLambda(options.lambda_)
205 if not spaceType ==
"PJ":
206 self.
css.setExploration(options.exploration)
207 self.
css.setEpsilon(options.epsilon)
208 self.
css.setRho(options.rho)
209 self.
css.setAlpha(options.alpha)
210 self.
css.setMaxChartsPerExtension(options.charts)
212 self.
css.setBiasFunction(
213 ob.AtlasChartBiasFunction(
214 lambda c, atlas=self.
css: atlas.getChartCount()
215 - c.getNeighborCount()
219 if spaceType ==
"AT":
220 self.
css.setSeparated(
not options.no_separate)
224 def setStartAndGoalStates(self, start, goal):
225 sstart = self.
css.allocState()
226 sgoal = self.
css.allocState()
233 self.
css.anchorChart(sstart)
234 self.
css.anchorChart(sgoal)
237 self.
ss.setStartAndGoalStates(sstart, sgoal)
239 def getPlanner(self, plannerName, projectionName=None):
240 planner = eval(
"og.%s(self.csi)" % plannerName)
244 planner.setRange(self.
css.getRho_s())
246 planner.setRange(self.
options.range)
251 planner.setProjectionEvaluator(projectionName)
256 def setPlanner(self, plannerName, projectionName=None):
258 self.
ss.setPlanner(self.
pp)
260 def solveOnce(self, output=False, name="ompl"):
266 path = self.
ss.getSolutionPath()
268 ou.OMPL_WARN(
"Path fails check!")
270 if stat == ob.PlannerStatus.APPROXIMATE_SOLUTION:
271 ou.OMPL_WARN(
"Solution is approximate.")
274 ou.OMPL_INFORM(
"Simplifying solution...")
275 self.
ss.simplifySolution(5.0)
277 simplePath = self.
ss.getSolutionPath()
279 "Simplified Path Length: %.3f -> %.3f"
280 % (path.length(), simplePath.length())
283 if not simplePath.check():
284 ou.OMPL_WARN(
"Simplified path fails check!")
287 ou.OMPL_INFORM(
"Interpolating path...")
291 ou.OMPL_WARN(
"Interpolated simplified path fails check!")
293 ou.OMPL_INFORM(
"Interpolating simplified path...")
294 simplePath.interpolate()
296 if not simplePath.check():
297 ou.OMPL_WARN(
"Interpolated simplified path fails check!")
300 ou.OMPL_INFORM(
"Dumping path to `%s_path.txt`." % name)
301 with open(
"%s_path.txt" % name,
"w")
as pathfile:
302 print(path.printAsMatrix(), file=pathfile)
304 ou.OMPL_INFORM(
"Dumping simplified path to `%s_simplepath.txt`." % name)
305 with open(
"%s_simplepath.txt" % name,
"w")
as simplepathfile:
306 print(simplePath.printAsMatrix(), file=simplepathfile)
308 ou.OMPL_WARN(
"No solution found.")
312 def setupBenchmark(self, planners, problem):
314 print(
"Benchmarking not available, no ompl.tools")
319 self.
bench.addExperimentParameter(
320 "n",
"INTEGER", str(self.
constraint.getAmbientDimension())
322 self.
bench.addExperimentParameter(
323 "k",
"INTEGER", str(self.
constraint.getManifoldDimension())
325 self.
bench.addExperimentParameter(
326 "n - k",
"INTEGER", str(self.
constraint.getCoDimension())
328 self.
bench.addExperimentParameter(
"space",
"INTEGER", self.
spaceType)
334 self.
request.timeBetweenUpdates = 0.1
335 self.
request.saveConsoleOutput =
False
336 for planner
in planners:
339 self.
bench.setPreRunEvent(ot.PreSetupEvent(clearSpaceAndPlanner))
341 def runBenchmark(self):
344 str(datetime.datetime.now())
346 + self.
bench.getExperimentName()
350 self.
bench.saveResultsToFile(filename)
352 def atlasStats(self):
356 ou.OMPL_INFORM(
"Atlas has %d charts" % self.
css.getChartCount())
359 "Atlas is approximately %.3f%% open"
360 % self.
css.estimateFrontierPercent()
363 def dumpGraph(self, name):
364 ou.OMPL_INFORM(
"Dumping planner graph to `%s_graph.graphml`." % name)
366 self.
pp.getPlannerData(data)
368 with open(
"%s_graph.graphml" % name,
"w")
as graphfile:
369 print(data.printGraphML(), file=graphfile)
372 ou.OMPL_INFORM(
"Dumping atlas to `%s_atlas.ply`." % name)
373 with open(
"%s_atlas.ply" % name,
"w")
as atlasfile:
374 print(self.
css.printPLY(), file=atlasfile)