From: Helio P. F. <xpe...@gm...> - 2020-03-11 14:32:08
|
Hi Hadar, How can I get the path with more states along the path in addition to the > start and goal? There are a couple ways to accomplish that, but to decide which one to use we first need to ask, why is it a problem that the planner is only returning the start and end states? If the solution is valid in the context of the navigation task (there are no obstacles obstructing the way, etc) and you just need it to contain intermediary states down to a given resolution (say, one state every 0.01 m), you can use the ompl::geometric::PathGeometric::interpolate <http://ompl.kavrakilab.org/classompl_1_1geometric_1_1PathGeometric.html#a29c50018bc71d4d25b0f8e4d3e97aecd> function to add intermediary states to the computed path. Optionally you can also use ompl::geometric::PathSimplifier::smoothBSpline <http://ompl.kavrakilab.org/classompl_1_1geometric_1_1PathSimplifier.html#aa4ecd0970d2061c457f57b7665fd6f6b> before it to ensure transitions between paths are smoother. For example: // space is assumed to be an instance of ompl::base::RealVectorStateSpace created previously. ompl::geometric::SimpleSetup solver(space); // Setup solver - set planner, validity checker, start and goal states etc. // Compute path from start state to goal. solver.solve(timeout); // Smooth and interpolate path. auto &path = solver.getSolutionPath(); solver.getPathSimplifier()->smoothBSpline(path); path.interpolate(path.length() / resolution); If however the problem is that the path is not actually valid, e.g. it leads through an obstacle, then you need to use a finer resolution for the validity checker. That can be done by setting the length of the longest valid path edge as a fraction of the maximum extent of the state space: ompl::geometric::SimpleSetup solver(space); // Set path edge resolution. auto state_space = solver.getStateSpace(); double fraction = edge_length / state_space->getMaximumExtent(); state_space->setLongestValidSegmentFraction(fraction); // Finish setting up solver... solver.solve(timeout); You may actually want to combine the two approaches for performance reasons, i.e. set the longest valid segment to a size just short enough to ensure path validity, then use interpolation for further refinement. -- Best regards, Helio Perroni Filho E-mail: ma...@xp... Web: http://xperroni.me <http://machineawakening.blogspot.com/> On Wed, Mar 11, 2020 at 9:49 AM hadar sinvani <had...@gm...> wrote: > Hello again, > > I'm trying to use PRM/PRMstar planner in a RealVectorStateSpace. > In both cases, I'm only getting the start and goal states with no > additional states along the path. > If it matters, my "bool isStateValid(const ob::State *state)" function > always returns true. > How can I get the path with more states along the path in addition to the > start and goal? > > Best, Hadar. > > > _______________________________________________ > ompl-users mailing list > omp...@li... > https://lists.sourceforge.net/lists/listinfo/ompl-users > |