moveit_task_constructor/include/moveit_task_constructor/subtask.h
v4hn 2dfc2f395e avoid shortened nested namespace definitions
`namespace X::Y { }` is only part of the C++17 standard.
I did not notice before because GCC 6+ do not warn about
this even with `-pedantic -std=c++14`.
2017-09-13 13:16:48 +02:00

84 lines
2.2 KiB
C++

// copyright Michael 'v4hn' Goerner @ 2017
#pragma once
#include <moveit_task_constructor/storage.h>
#include <moveit/macros/class_forward.h>
#include <moveit/planning_scene/planning_scene.h>
#include <vector>
#include <list>
#include <tuple>
namespace planning_scene {
MOVEIT_CLASS_FORWARD(PlanningScene);
}
namespace planning_pipeline {
MOVEIT_CLASS_FORWARD(PlanningPipeline);
}
namespace moveit { namespace task_constructor {
MOVEIT_CLASS_FORWARD(SubTask);
typedef std::weak_ptr<SubTask> SubTaskWeakPtr;
class SubTask {
public:
SubTask(std::string name);
virtual bool canCompute() = 0;
virtual bool compute() = 0;
const std::string& getName();
const std::list<InterfaceState>& getBeginning();
const std::list<InterfaceState>& getEnd();
std::list<SubTrajectory>& getTrajectories();
void setPlanningScene(planning_scene::PlanningSceneConstPtr);
void setPlanningPipeline(planning_pipeline::PlanningPipelinePtr);
void addPredecessor(SubTaskPtr);
void addSuccessor(SubTaskPtr);
protected:
InterfaceState& fetchStateBeginning();
InterfaceState& fetchStateEnding();
std::pair<InterfaceState&, InterfaceState&> fetchStatePair();
bool hasBeginning();
bool hasEnding();
bool hasStatePair();
SubTrajectory& addTrajectory(robot_trajectory::RobotTrajectoryPtr);
void sendForward(SubTrajectory&, planning_scene::PlanningSceneConstPtr);
void sendBackward(SubTrajectory&, planning_scene::PlanningSceneConstPtr);
void sendBothWays(SubTrajectory&, planning_scene::PlanningSceneConstPtr);
InterfaceState* newBeginning(planning_scene::PlanningSceneConstPtr, SubTrajectory*);
InterfaceState* newEnd(planning_scene::PlanningSceneConstPtr, SubTrajectory*);
const std::string name_;
// avoid shared pointers back
SubTaskWeakPtr predecessor_;
SubTaskPtr successor_;
std::list<SubTrajectory> trajectories_;
std::list<InterfaceState> beginnings_;
std::list<InterfaceState> endings_;
planning_scene::PlanningSceneConstPtr scene_;
planning_pipeline::PlanningPipelinePtr planner_;
std::list<InterfaceState>::iterator it_beginnings_;
std::list<InterfaceState>::iterator it_endings_;
std::pair< std::list<InterfaceState>::iterator, std::list<InterfaceState>::iterator > it_pairs_;
};
} }