42 #include "container.h"
44 #include <moveit/task_constructor/introspection.h>
45 #include <moveit_task_constructor_msgs/Solution.h>
47 #include <moveit/macros/class_forward.h>
49 #include <moveit_msgs/MoveItErrorCodes.h>
50 #include <moveit/utils/moveit_error_code.h>
54 MOVEIT_CLASS_FORWARD(RobotModel);
55 MOVEIT_CLASS_FORWARD(RobotState);
60 namespace task_constructor {
62 MOVEIT_CLASS_FORWARD(Stage);
63 MOVEIT_CLASS_FORWARD(ContainerBase);
64 MOVEIT_CLASS_FORWARD(Task);
77 using WrapperBase::operator[];
79 Task(
const std::string& ns =
"",
bool introspection =
true,
80 ContainerBase::pointer&& container = std::make_unique<SerialContainer>(
"task pipeline"));
85 const std::string& name()
const {
return stages()->name(); }
86 void setName(
const std::string& name) {
stages()->setName(name); }
88 Stage* findChild(
const std::string& name)
const {
return stages()->findChild(name); }
89 Stage* operator[](
int index)
const {
return stages()->operator[](index); }
91 const moveit::core::RobotModelConstPtr& getRobotModel()
const;
93 void setRobotModel(
const moveit::core::RobotModelConstPtr& robot_model);
95 void loadRobotModel(
const std::string& robot_description =
"robot_description");
97 void add(Stage::pointer&& stage);
98 void insert(Stage::pointer&& stage,
int before = -1)
override;
105 using TaskCallback = std::function<void(
const Task& t)>;
106 using TaskCallbackList = std::list<TaskCallback>;
115 using WrapperBase::SolutionCallback;
120 using WrapperBase::pruning;
129 moveit::core::MoveItErrorCode
plan(
size_t max_solutions = 0);
132 void resetPreemptRequest();
137 void printState(std::ostream& os = std::cout)
const;
142 size_t numSolutions()
const {
return solutions().size(); }
144 const std::list<SolutionBaseConstPtr>& failures()
const {
return stages()->failures(); }
157 void setProperty(
const std::string& name,
const boost::any& value);
162 bool canCompute()
const override;
163 void compute()
override;
170 inline std::ostream& operator<<(std::ostream& os,
const Task& task) {
Definition: container.h:49
void init(const moveit::core::RobotModelConstPtr &robot_model) override
void setPruning(bool pruning)
Explicitly enable/disable pruning.
Definition: container.h:55
Definition: introspection.h:66
Definition: properties.h:257
abstract base class for solutions (primitive and sequences)
Definition: storage.h:269
void setTimeout(double timeout)
Definition: stage.h:194
void removeSolutionCallback(SolutionCallbackList::const_iterator which)
remove function callback
Definition: stage.cpp:408
SolutionCallbackList::const_iterator addSolutionCallback(SolutionCallback &&cb)
add function to be called for every newly found solution or failure
Definition: stage.cpp:403
void setCostTerm(const CostTermConstPtr &term)
Definition: stage.cpp:412
double timeout() const
timeout of stage per computation
Definition: stage.h:196
void explainFailure(std::ostream &os=std::cout) const override
print an explanation for a planning failure to os
Definition: task.cpp:336
void enableIntrospection(bool enable=true)
enable introspection publishing for use with rviz
Definition: task.cpp:159
ContainerBase * stages()
access stage tree
Definition: task.cpp:309
void preempt()
interrupt current planning
Definition: task.cpp:274
void insert(Stage::pointer &&stage, int before=-1) override
insertion is only allowed if children() is empty
Definition: task.cpp:150
void loadRobotModel(const std::string &robot_description="robot_description")
load robot model from given parameter
Definition: task.cpp:138
TaskCallbackList::const_iterator addTaskCallback(TaskCallback &&cb)
add function to be called after each top-level iteration
Definition: task.cpp:182
void eraseTaskCallback(TaskCallbackList::const_iterator which)
remove function callback
Definition: task.cpp:188
PropertyMap & properties()
properties access
Definition: task.cpp:317
void printState(std::ostream &os=std::cout) const
print current task state (number of found solutions and propagated states) to std::cout
Definition: task.cpp:332
void setRobotModel(const moveit::core::RobotModelConstPtr &robot_model)
setting the robot model also resets the task
Definition: task.cpp:127
moveit::core::MoveItErrorCode plan(size_t max_solutions=0)
reset, init scene (if not yet done), and init all stages, then start planning
Definition: task.cpp:243
moveit::core::MoveItErrorCode execute(const SolutionBase &s)
execute solution, return the result
Definition: task.cpp:282
void publishAllSolutions(bool wait=true)
publish all top-level solutions
Definition: task.cpp:297
void reset() final
reset all stages
Definition: task.cpp:192
void init()
initialize all stages with given scene
Definition: task.cpp:201
void onNewSolution(const SolutionBase &s) override
called by a (direct) child when a new solution becomes available
Definition: task.cpp:302
void setProperty(const std::string &name, const char *value)
overload: const char* values are stored as std::string
Definition: task.h:159
Definition: container.h:214
ordered<ValueType> provides an adapter for a std::list to allow sorting.
Definition: cost_queue.h:30