Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support modifying wrappers in user stages #253

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
accept const-refs in liftModifiedSolution
clang-tidy rightfully complained that moving rvalues doesn't make
sense when the underlying method accepts const refs.

The rvalue parameter interface, as it is used with spawn/etc. indicates
that the solution is submitted to the system. But with the shared_ptr interface
we need for `liftModifiedSolution` it does not make any sense, especially because
we can't even move the passed pointer to the internal datastructures but have to copy...
v4hn committed Sep 6, 2021
commit 8ac2968d8c3f4448d31c43aa2af11d5effc9a7d5
6 changes: 3 additions & 3 deletions core/include/moveit/task_constructor/container.h
Original file line number Diff line number Diff line change
@@ -128,13 +128,13 @@ class ParallelContainerBase : public ContainerBase
void liftSolution(const SolutionBase& solution, double cost, std::string comment);

/// lift a modified solution based on the solution of a child stage
void liftModifiedSolution(SolutionBasePtr&& new_solution, const SolutionBase& child_solution);
void liftModifiedSolution(const SolutionBasePtr& new_solution, const SolutionBase& child_solution);
/// lift a modified solution, changing the (single!) new associated start or end InterfaceState
void liftModifiedSolution(SolutionBasePtr&& new_solution, InterfaceState&& new_propagated_state,
void liftModifiedSolution(const SolutionBasePtr& new_solution, InterfaceState&& new_propagated_state,
const SolutionBase& child_solution);
/// lift a modified solution, providing new start and end states
/// The new states will only be used if this's should actually create the corresponding states
void liftModifiedSolution(SolutionBasePtr&& new_solution, InterfaceState&& new_start_state,
void liftModifiedSolution(const SolutionBasePtr& new_solution, InterfaceState&& new_start_state,
InterfaceState&& new_end_state, const SolutionBase& child_solution);
};

15 changes: 7 additions & 8 deletions core/src/container.cpp
Original file line number Diff line number Diff line change
@@ -781,35 +781,34 @@ void ParallelContainerBase::liftSolution(const SolutionBase& solution, double co
solution.start(), solution.end());
}

void ParallelContainerBase::liftModifiedSolution(SolutionBasePtr&& modified_solution, const SolutionBase& child_solution) {
void ParallelContainerBase::liftModifiedSolution(const SolutionBasePtr& modified_solution, const SolutionBase& child_solution) {
// child_solution is correctly prepared by a child of this container
assert(child_solution.creator());
assert(child_solution.creator()->parent() == this);

pimpl()->liftSolution(std::move(modified_solution),
child_solution.start(), child_solution.end());
pimpl()->liftSolution(modified_solution, child_solution.start(), child_solution.end());
}

void ParallelContainerBase::liftModifiedSolution(SolutionBasePtr&& new_solution, InterfaceState&& new_propagated_state, const SolutionBase& child_solution) {
void ParallelContainerBase::liftModifiedSolution(const SolutionBasePtr& new_solution, InterfaceState&& new_propagated_state, const SolutionBase& child_solution) {
assert(child_solution.creator());
assert(child_solution.creator()->parent() == this);

if(pimpl()->requiredInterface() == GENERATE){
// in this case we need a second InterfaceState to move from
InterfaceState new_to{ new_propagated_state };
pimpl()->liftSolution(std::move(new_solution), child_solution.start(), child_solution.end(), &new_propagated_state, &new_to);
pimpl()->liftSolution(new_solution, child_solution.start(), child_solution.end(), &new_propagated_state, &new_to);
}
else {
// pass new_propagated_state as start *and* end. We know at most one will be used.
pimpl()->liftSolution(std::move(new_solution), child_solution.start(), child_solution.end(), &new_propagated_state, &new_propagated_state);
pimpl()->liftSolution(new_solution, child_solution.start(), child_solution.end(), &new_propagated_state, &new_propagated_state);
}
}

void ParallelContainerBase::liftModifiedSolution(SolutionBasePtr&& new_solution, InterfaceState&& new_from, InterfaceState&& new_to, const SolutionBase& child_solution) {
void ParallelContainerBase::liftModifiedSolution(const SolutionBasePtr& new_solution, InterfaceState&& new_from, InterfaceState&& new_to, const SolutionBase& child_solution) {
assert(child_solution.creator());
assert(child_solution.creator()->parent() == this);

pimpl()->liftSolution(std::move(new_solution), child_solution.start(), child_solution.end(), &new_from, &new_to);
pimpl()->liftSolution(new_solution, child_solution.start(), child_solution.end(), &new_from, &new_to);
}