Skip to content
Snippets Groups Projects
Commit dee13b9e authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Joseph Mirabel
Browse files

GraphOptimizer does not optimize short edges.

parent 05679e0f
No related branches found
No related tags found
No related merge requests found
...@@ -30,7 +30,10 @@ namespace hpp { ...@@ -30,7 +30,10 @@ namespace hpp {
toConcat; toConcat;
GraphPathValidationPtr_t gpv = HPP_DYNAMIC_PTR_CAST (GraphPathValidation, GraphPathValidationPtr_t gpv = HPP_DYNAMIC_PTR_CAST (GraphPathValidation,
this->problem().pathValidation ()); this->problem().pathValidation ());
const_cast <core::Problem&>(this->problem ()).pathValidation (gpv->innerValidation()); core::Problem p (problem().robot());
p.distance(problem().distance());
p.pathValidation(gpv->innerValidation());
path->flatten (expanded); path->flatten (expanded);
ConstraintSetPtr_t c; ConstraintSetPtr_t c;
for (std::size_t i_s = 0; i_s < expanded->numberPaths ();) { for (std::size_t i_s = 0; i_s < expanded->numberPaths ();) {
...@@ -41,21 +44,34 @@ namespace hpp { ...@@ -41,21 +44,34 @@ namespace hpp {
graph::EdgePtr_t edge; graph::EdgePtr_t edge;
c = HPP_DYNAMIC_PTR_CAST (ConstraintSet, current->constraints ()); c = HPP_DYNAMIC_PTR_CAST (ConstraintSet, current->constraints ());
if (c) edge = c->edge (); if (c) edge = c->edge ();
bool isShort = edge && edge->isShort();
std::size_t i_e = i_s + 1; std::size_t i_e = i_s + 1;
for (; i_e < expanded->numberPaths (); ++i_e) { for (; i_e < expanded->numberPaths (); ++i_e) {
current = expanded->pathAtRank (i_e); current = expanded->pathAtRank (i_e);
c = HPP_DYNAMIC_PTR_CAST (ConstraintSet, current->constraints ()); c = HPP_DYNAMIC_PTR_CAST (ConstraintSet, current->constraints ());
if (!c && edge) break; if (!c && edge) {
hppDout(info, "No manipulation::ConstraintSet");
break;
}
if (c && edge->node() != c->edge ()->node()) break; if (c && edge->node() != c->edge ()->node()) break;
if (isShort != c->edge()->isShort()) // We do not optimize edges marked as short
break;
toOpt->appendPath (current); toOpt->appendPath (current);
} }
pathOptimizer_ = factory_ (this->problem ()); hppDout(info, "Edge name: " << edge->name());
toConcat = pathOptimizer_->optimize (toOpt); if (isShort)
toConcat = toOpt;
else {
p.constraints(edge->steeringMethod()->constraints());
p.constraints()->configProjector()->rightHandSideFromConfig(toOpt->initial());
p.steeringMethod(edge->steeringMethod());
pathOptimizer_ = factory_ (p);
toConcat = pathOptimizer_->optimize (toOpt);
}
i_s = i_e; i_s = i_e;
opted->concatenate (*toConcat); opted->concatenate (*toConcat);
} }
pathOptimizer_.reset (); pathOptimizer_.reset ();
const_cast <core::Problem&>(this->problem ()).pathValidation (gpv);
return opted; return opted;
} }
} // namespace manipulation } // namespace manipulation
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment