Commit 5ae11db6 authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

ProblemTarget stores a ProblemWkPtr_t to avoid memory leak.

parent f2b9436c
......@@ -64,7 +64,7 @@ namespace hpp {
}
/// Reference to the planner for access to problem and roadmap
ProblemPtr_t problem_;
ProblemWkPtr_t problem_;
/// Store weak pointer to itself
ProblemTargetWkPtr_t weakPtr_;
......
......@@ -57,15 +57,17 @@ namespace hpp {
PathVectorPtr_t GoalConfigurations::computePath(const RoadmapPtr_t& roadmap) const
{
Astar astar (roadmap, problem_->distance ());
ProblemPtr_t problem (problem_.lock());
assert (problem);
Astar astar (roadmap, problem->distance ());
PathVectorPtr_t sol = PathVector::create (
problem_->robot()->configSize(), problem_->robot()->numberDof());
problem->robot()->configSize(), problem->robot()->numberDof());
astar.solution (sol);
// This happens when q_init == q_goal
if (sol->numberPaths() == 0) {
ConfigurationPtr_t q (roadmap->initNode()->configuration ());
sol->appendPath(
(*problem_->steeringMethod()) (*q, *q)
(*problem->steeringMethod()) (*q, *q)
);
}
return sol;
......
......@@ -54,15 +54,17 @@ namespace hpp {
PathVectorPtr_t TaskTarget::computePath(const RoadmapPtr_t& roadmap) const
{
Astar astar (roadmap, problem_->distance ());
ProblemPtr_t problem (problem_.lock());
assert (problem);
Astar astar (roadmap, problem->distance ());
PathVectorPtr_t sol = PathVector::create (
problem_->robot()->configSize(), problem_->robot()->numberDof());
problem->robot()->configSize(), problem->robot()->numberDof());
astar.solution (sol);
// This happens when q_init already satisfies the task.
if (sol->numberPaths() == 0) {
ConfigurationPtr_t q (roadmap->initNode()->configuration ());
sol->appendPath(
(*problem_->steeringMethod()) (*q, *q)
(*problem->steeringMethod()) (*q, *q)
);
}
return sol;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment