Commits

Ioan Sucan committed c59c0e4

add cast to bool operator for PlannerTerminationCondition

  • Participants
  • Parent commits c0c0999

Comments (0)

Files changed (21)

File py-bindings/PRM.SingleThreadSolve.cpp

     sln.reset();
 
     double roadmap_build_time = 0.05;
-    while (ptc() == false && !addedSolution_)
+    while (ptc == false && !addedSolution_)
     {
         // Check for any new goal states
         if (goal->maxSampleCount() > goalM_.size())

File src/ompl/base/PlannerTerminationCondition.h

                 return terminate_ || eval();
             }
 
+            /** \brief Cast as true if the planner should stop its computation */
+            operator bool() const
+            {
+                return terminate_ || eval();
+            }
+          
             /** \brief Notify that the condition for termination should become true, regardless of what eval() returns.
                 This function may be called while the condition is being evaluated by other threads. */
             void terminate(void) const;

File src/ompl/base/src/Planner.cpp

                         OMPL_DEBUG("Discarded goal state %s", ss.str().c_str());
                     }
                 }
-                while (!ptc() && sampledGoalsCount_ < goal->maxSampleCount() && goal->canSample());
+                while (!ptc && sampledGoalsCount_ < goal->maxSampleCount() && goal->canSample());
             }
-            if (goal->couldSample() && !ptc())
+            if (goal->couldSample() && !ptc)
             {
                 if (first)
                 {
                     OMPL_DEBUG("Waiting for goal region samples ...");
                 }
                 boost::this_thread::sleep(time::seconds(0.01));
-                attempt = !ptc();
+                attempt = !ptc;
             }
         }
     }

File src/ompl/contrib/rrt_star/src/BallTreeRRTstar.cpp

 
     std::pair<base::State*,double> lastValid(tstate, 0.0);
 
-    while (ptc() == false)
+    while (ptc == false)
     {
         bool rejected = false;
 

File src/ompl/contrib/rrt_star/src/RRTstar.cpp

     unsigned int         rewireTest = 0;
     double               stateSpaceDimensionConstant = 1.0 / (double)si_->getStateSpace()->getDimension();
 
-    while (ptc() == false)
+    while (ptc == false)
     {
         // sample random state (with goal biasing)
         if (goal_s && rng_.uniform01() < goalBias_ && goal_s->canSample())

File src/ompl/control/planners/est/src/EST.cpp

     Motion   *rmotion = new Motion(siC_);
     bool       solved = false;
 
-    while (!ptc())
+    while (!ptc)
     {
         // Select a state to expand the tree from
         Motion *existing = selectMotion();

File src/ompl/control/planners/kpiece/src/KPIECE1.cpp

     // samples that were found to be the best, so far
     CloseSamples closeSamples(nCloseSamples_);
 
-    while (ptc() == false)
+    while (ptc == false)
     {
         tree_.iteration++;
 

File src/ompl/control/planners/rrt/src/RRT.cpp

     Control       *rctrl = rmotion->control;
     base::State  *xstate = si_->allocState();
 
-    while (ptc() == false)
+    while (ptc == false)
     {
         /* sample random state (with goal biasing) */
         if (goal_s && rng_.uniform01() < goalBias_ && goal_s->canSample())

File src/ompl/control/planners/syclop/src/Syclop.cpp

     base::Goal* goal = pdef_->getGoal().get();
     double goalDist = std::numeric_limits<double>::infinity();
     bool solved = false;
-    while (!ptc() && !solved)
+    while (!ptc && !solved)
     {
         const int chosenStartRegion = startRegions_.sampleUniform();
         int chosenGoalRegion = -1;
 
         leadComputeFn(chosenStartRegion, chosenGoalRegion, lead_);
         computeAvailableRegions();
-        for (int i = 0; i < numRegionExpansions_ && !solved && !ptc(); ++i)
+        for (int i = 0; i < numRegionExpansions_ && !solved && !ptc; ++i)
         {
             const int region = selectRegion();
             bool improved = false;
-            for (int j = 0; j < numTreeSelections_ && !solved && !ptc(); ++j)
+            for (int j = 0; j < numTreeSelections_ && !solved && !ptc; ++j)
             {
                 newMotions.clear();
                 selectAndExtend(graph_[boost::vertex(region,graph_)], newMotions);
-                for (std::vector<Motion*>::const_iterator m = newMotions.begin(); m != newMotions.end() && !ptc(); ++m)
+                for (std::vector<Motion*>::const_iterator m = newMotions.begin(); m != newMotions.end() && !ptc; ++m)
                 {
                     Motion* motion = *m;
                     double distance;

File src/ompl/geometric/planners/est/src/EST.cpp

     double  approxdif = std::numeric_limits<double>::infinity();
     base::State *xstate = si_->allocState();
 
-    while (ptc() == false)
+    while (ptc == false)
     {
         /* Decide on a state to expand from */
         Motion *existing = selectMotion();

File src/ompl/geometric/planners/kpiece/src/BKPIECE1.cpp

     bool      startTree = true;
     bool         solved = false;
 
-    while (ptc() == false)
+    while (ptc == false)
     {
         Discretization<Motion> &disc      = startTree ? dStart_ : dGoal_;
         startTree = !startTree;

File src/ompl/geometric/planners/kpiece/src/KPIECE1.cpp

     double  approxdif   = std::numeric_limits<double>::infinity();
     base::State *xstate = si_->allocState();
 
-    while (ptc() == false)
+    while (ptc == false)
     {
         disc_.countIteration();
 

File src/ompl/geometric/planners/kpiece/src/LBKPIECE1.cpp

     bool      startTree = true;
     bool         solved = false;
 
-    while (ptc() == false)
+    while (ptc == false)
     {
         Discretization<Motion> &disc      = startTree ? dStart_ : dGoal_;
         startTree = !startTree;

File src/ompl/geometric/planners/prm/src/PRM.cpp

     if (pdf.empty())
         return;
 
-    while (ptc() == false)
+    while (ptc == false)
     {
         Vertex v = pdf.sample(rng_.uniform01());
         unsigned int s = si_->randomBounceMotion(simpleSampler_, stateProperty_[v], workStates.size(), workStates, false);
 void ompl::geometric::PRM::growRoadmap(const base::PlannerTerminationCondition &ptc,
                                        base::State *workState)
 {
-    while (ptc() == false)
+    while (ptc == false)
     {
         // search for a valid state
         bool found = false;
-        while (!found && ptc() == false)
+        while (!found && ptc == false)
         {
             unsigned int attempts = 0;
             do
                                              base::PathPtr &solution)
 {
     base::GoalSampleableRegion *goal = dynamic_cast<base::GoalSampleableRegion*>(pdef_->getGoal().get());
-    while (!ptc() && !addedSolution_)
+    while (!ptc && !addedSolution_)
     {
         // Check for any new goal states
         if (goal->maxSampleCount() > goalM_.size())

File src/ompl/geometric/planners/rrt/src/LazyRRT.cpp

 
     bool solutionFound = false;
 
-    while (ptc() == false && !solutionFound)
+    while (ptc == false && !solutionFound)
     {
         /* sample random state (with goal biasing) */
         if (goal_s && rng_.uniform01() < goalBias_ && goal_s->canSample())

File src/ompl/geometric/planners/rrt/src/RRT.cpp

     base::State *rstate = rmotion->state;
     base::State *xstate = si_->allocState();
 
-    while (ptc() == false)
+    while (ptc == false)
     {
 
         /* sample random state (with goal biasing) */

File src/ompl/geometric/planners/rrt/src/RRTConnect.cpp

     bool startTree      = true;
     bool solved         = false;
 
-    while (ptc() == false)
+    while (ptc == false)
     {
         TreeData &tree      = startTree ? tStart_ : tGoal_;
         tgi.start = startTree;

File src/ompl/geometric/planners/rrt/src/pRRT.cpp

     base::State *rstate = rmotion->state;
     base::State *xstate = si_->allocState();
 
-    while (sol->solution == NULL && ptc() == false)
+    while (sol->solution == NULL && ptc == false)
     {
         /* sample random state (with goal biasing) */
         if (goal_s && rng.uniform01() < goalBias_ && goal_s->canSample())

File src/ompl/geometric/planners/sbl/src/SBL.cpp

     bool      startTree = true;
     bool         solved = false;
 
-    while (ptc() == false)
+    while (ptc == false)
     {
         TreeData &tree      = startTree ? tStart_ : tGoal_;
         startTree = !startTree;

File src/ompl/geometric/planners/sbl/src/pSBL.cpp

     base::State *xstate = si_->allocState();
     bool      startTree = rng.uniformBool();
 
-    while (!sol->found && ptc() == false)
+    while (!sol->found && ptc == false)
     {
         bool retry = true;
-        while (retry && !sol->found && ptc() == false)
+        while (retry && !sol->found && ptc == false)
         {
             removeList_.lock.lock();
             if (!removeList_.motions.empty())
             removeList_.lock.unlock();
         }
 
-        if (sol->found || ptc())
+        if (sol->found || ptc)
             break;
 
         loopLockCounter_.lock();

File src/ompl/geometric/src/PathSimplifier.cpp

 
     // try a randomized step of connecting vertices
     bool tryMore = false;
-    if (ptc() == false)
+    if (ptc == false)
         tryMore = reduceVertices(path);
 
     // try to collapse close-by vertices
-    if (ptc() == false)
+    if (ptc == false)
         collapseCloseVertices(path);
 
     // try to reduce verices some more, if there is any point in doing so
     int times = 0;
-    while (tryMore && ptc() == false && ++times <= 5)
+    while (tryMore && ptc == false && ++times <= 5)
         tryMore = reduceVertices(path);
 
     // run a more complex short-cut algorithm : allow splitting path segments
-    if (ptc() == false)
+    if (ptc == false)
         tryMore = shortcutPath(path);
     else
         tryMore = false;
 
     // run the short-cut algorithm some more, if it makes a difference
     times = 0;
-    while (tryMore && ptc() == false && ++times <= 5)
+    while (tryMore && ptc == false && ++times <= 5)
         tryMore = shortcutPath(path);
 
     // smooth the path
-    if (ptc() == false)
+    if (ptc == false)
         smoothBSpline(path, 3, path.length()/100.0);
 
     // we always run this