40 from ompl
import base
as ob
41 from ompl
import geometric
as og
45 from os.path
import abspath, dirname, join
47 sys.path.insert(0, join(dirname(dirname(abspath(__file__))),
"py-bindings"))
48 from ompl
import base
as ob
49 from ompl
import geometric
as og
54 def __init__(self, si):
55 super(RandomWalkPlanner, self).__init__(si,
"RandomWalkPlanner")
57 self.sampler_ = si.allocStateSampler()
60 pdef = self.getProblemDefinition()
62 si = self.getSpaceInformation()
63 pi = self.getPlannerInputStates()
66 self.states_.append(st)
72 rstate = si.allocState()
74 self.sampler_.sampleUniform(rstate)
76 if si.checkMotion(self.states_[-1], rstate):
77 self.states_.append(rstate)
78 sat = goal.isSatisfied(rstate)
79 dist = goal.distanceGoal(rstate)
82 solution = len(self.states_)
86 approxsol = len(self.states_)
94 for s
in self.states_[:solution]:
96 pdef.addSolutionPath(path)
101 super(RandomWalkPlanner, self).clear()
106 def isStateValid(state):
110 return x*x + y*y + z*z > .8
119 space.setBounds(bounds)
131 ss.setStartAndGoalStates(start, goal, .05)
134 ss.setPlanner(planner)
136 result = ss.solve(10.0)
138 if result.getStatus() == ob.PlannerStatus.APPROXIMATE_SOLUTION:
139 print(
"Solution is approximate")
141 ss.simplifySolution()
143 print(ss.getSolutionPath())
146 if __name__ ==
"__main__":