37 #include "ompl/base/DiscreteMotionValidator.h"
38 #include "ompl/util/Exception.h"
41 void ompl::base::DiscreteMotionValidator::defaultSettings()
44 if (stateSpace_ ==
nullptr)
45 throw Exception(
"No state space for motion validator");
49 std::pair<State *, double> &lastValid)
const
54 int nd = stateSpace_->validSegmentCount(s1, s2);
59 State *test = si_->allocState();
61 for (
int j = 1; j < nd; ++j)
63 stateSpace_->interpolate(s1, s2, (
double)j / (
double)nd, test);
64 if (!si_->isValid(test))
66 lastValid.second = (double)(j - 1) / (double)nd;
67 if (lastValid.first !=
nullptr)
68 stateSpace_->interpolate(s1, s2, lastValid.second, lastValid.first);
77 if (!si_->isValid(s2))
79 lastValid.second = (double)(nd - 1) / (double)nd;
80 if (lastValid.first !=
nullptr)
81 stateSpace_->interpolate(s1, s2, lastValid.second, lastValid.first);
96 if (!si_->isValid(s2))
103 int nd = stateSpace_->validSegmentCount(s1, s2);
106 std::queue<std::pair<int, int>> pos;
109 pos.emplace(1, nd - 1);
112 State *test = si_->allocState();
117 std::pair<int, int> x = pos.front();
119 int mid = (x.first + x.second) / 2;
120 stateSpace_->interpolate(s1, s2, (
double)mid / (double)nd, test);
122 if (!si_->isValid(test))
131 pos.emplace(x.first, mid - 1);
133 pos.emplace(mid + 1, x.second);
136 si_->freeState(test);