removed extra variant of Task::SolutionProcessor

This commit is contained in:
Robert Haschke 2017-11-10 13:47:37 +01:00
parent 9aba70fd59
commit eb9753271a
4 changed files with 13 additions and 26 deletions

View File

@ -49,7 +49,7 @@ public:
void operator()(const SolutionBase &s) { publishSolution(s); }
/// publish all top-level solutions of task
void publishAllSolutions(bool wait = true) const;
void publishAllSolutions(bool wait = true);
/// get solution
bool getSolution(moveit_task_constructor::GetSolution::Request &req,

View File

@ -63,15 +63,7 @@ public:
static void printState(const Task &t);
size_t numSolutions() const override;
/// function type used for processing solutions
/// For each solution, composed from several SubTrajectories,
/// the vector of SubTrajectories as well as the associated costs are provided.
/// Return true, if traversal should continue, otherwise false.
typedef std::function<bool(const ::moveit_task_constructor::Solution& msg,
double accumulated_cost)> SolutionProcessor;
/// process all solutions
void processSolutions(const Task::SolutionProcessor &processor) const;
void processSolutions(const ContainerBase::SolutionProcessor &processor) const override;
/// publish all top-level solutions
void publishAllSolutions(bool wait = true);
@ -85,7 +77,6 @@ protected:
void initScene();
bool canCompute() const override;
bool compute() override;
void processSolutions(const ContainerBase::SolutionProcessor &processor) const override;
void onNewSolution(SolutionBase &s) override;
private:

View File

@ -90,12 +90,19 @@ void Introspection::publishSolution(const SolutionBase &s)
impl->solution_publisher_.publish(msg);
}
void Introspection::publishAllSolutions(bool wait) const
void Introspection::publishAllSolutions(bool wait)
{
Task::SolutionProcessor processor
= [this, wait](const ::moveit_task_constructor::Solution& msg, double cost) {
std::cout << "publishing solution with cost: " << cost << std::endl;
::moveit_task_constructor::Solution msg;
Stage::SolutionProcessor processor = [this, &msg, wait](const SolutionBase& s) {
std::cout << "publishing solution with cost: " << s.cost() << std::endl;
msg.sub_solution.clear();
msg.sub_trajectory.clear();
s.fillMessage(msg, this);
msg.task_id = impl->task_.id();
s.start()->scene()->getPlanningSceneMsg(msg.start_scene);
impl->solution_publisher_.publish(msg);
if (wait) {
std::cout << "Press <Enter> to continue ..." << std::endl;
int ch = getchar();

View File

@ -192,17 +192,6 @@ void Task::processSolutions(const ContainerBase::SolutionProcessor &processor) c
stages()->processSolutions(processor);
}
void Task::processSolutions(const Task::SolutionProcessor& processor) const {
::moveit_task_constructor::Solution msg;
msg.task_id = id();
processSolutions([&msg, &processor](const SolutionBase& s) {
msg.sub_solution.clear();
msg.sub_trajectory.clear();
s.fillMessage(msg);
return processor(msg, s.cost());
});
}
void Task::publishAllSolutions(bool wait)
{
enableIntrospection(true);