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

pathPlanner::EndEffectorTrajectory generates InterpolatedPath.

parent 815964c6
No related branches found
No related tags found
No related merge requests found
...@@ -148,11 +148,19 @@ namespace hpp { ...@@ -148,11 +148,19 @@ namespace hpp {
bool success = false; bool success = false;
bool resetRightHandSide = true; bool resetRightHandSide = true;
std::size_t i; std::size_t i;
Configuration_t q1;
vector_t times (nDiscreteSteps_+1);
matrix_t steps (problem().robot()->configSize(), nDiscreteSteps_+1);
times[0] = timeRange.first;
for (int j = 1; j < nDiscreteSteps_; ++j)
times[j] = timeRange.first + j * (timeRange.second - timeRange.first) / nDiscreteSteps_;
times[nDiscreteSteps_] = timeRange.second;
for (i = 0; i < qs.size(); ++i) for (i = 0; i < qs.size(); ++i)
{ {
if (resetRightHandSide) { if (resetRightHandSide) {
constraints->rightHandSideAt (timeRange.first); constraints->rightHandSideAt (times[0]);
resetRightHandSide = false; resetRightHandSide = false;
} }
Configuration_t& q (qs[i]); Configuration_t& q (qs[i]);
...@@ -160,13 +168,13 @@ namespace hpp { ...@@ -160,13 +168,13 @@ namespace hpp {
if (!cfgValidation->validate (q, cfgReport)) continue; if (!cfgValidation->validate (q, cfgReport)) continue;
resetRightHandSide = true; resetRightHandSide = true;
q1 = q; steps.col(0) = q;
success = true; success = true;
for (int j = 1; j <= nDiscreteSteps_; ++j) { for (int j = 1; j <= nDiscreteSteps_; ++j) {
value_type t = timeRange.first + j * (timeRange.second - timeRange.first) / nDiscreteSteps_; constraints->rightHandSideAt (times[j]);
constraints->rightHandSideAt (t);
hppDout (info, "RHS: " << setpyformat << constraints->rightHandSide().transpose()); hppDout (info, "RHS: " << setpyformat << constraints->rightHandSide().transpose());
if (!constraints->apply (q)) { steps.col(j) = steps.col(j-1);
if (!constraints->apply (steps.col(j))) {
hppDout (info, "Failed to generate destination config.\n" << setpyformat hppDout (info, "Failed to generate destination config.\n" << setpyformat
<< *constraints << *constraints
<< "\nq=" << one_line (q)); << "\nq=" << one_line (q));
...@@ -177,16 +185,16 @@ namespace hpp { ...@@ -177,16 +185,16 @@ namespace hpp {
if (!success) continue; if (!success) continue;
success = false; success = false;
if (!cfgValidation->validate (q, cfgReport)) { if (!cfgValidation->validate (steps.col(nDiscreteSteps_), cfgReport)) {
hppDout (info, "Destination config is in collision."); hppDout (info, "Destination config is in collision.");
continue; continue;
} }
core::PathPtr_t path = (*sm) (q1, q); core::PathPtr_t path = sm->projectedPath(times, steps);
if (!path) { if (!path) {
hppDout (info, "Steering method failed.\n" << setpyformat hppDout (info, "Steering method failed.\n" << setpyformat
<< one_line(q1) << '\n' << "times: " << one_line(times) << '\n'
<< one_line(q ) << '\n' << "configs:\n" << condensed(steps.transpose()) << '\n'
); );
continue; continue;
} }
...@@ -197,9 +205,10 @@ namespace hpp { ...@@ -197,9 +205,10 @@ namespace hpp {
continue; continue;
} }
roadmap()->initNode (boost::make_shared<Configuration_t>(q1)); roadmap()->initNode (boost::make_shared<Configuration_t>(steps.col(0)));
core::NodePtr_t init = roadmap()-> initNode (); core::NodePtr_t init = roadmap()-> initNode ();
core::NodePtr_t goal = roadmap()->addGoalNode (boost::make_shared<Configuration_t>(q )); core::NodePtr_t goal = roadmap()->addGoalNode (
boost::make_shared<Configuration_t>(steps.col(nDiscreteSteps_)));
roadmap()->addEdge (init, goal, path); roadmap()->addEdge (init, goal, path);
success = true; success = true;
if (feasibilityOnly_) break; if (feasibilityOnly_) break;
......
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