File tree Expand file tree Collapse file tree 4 files changed +18
-5
lines changed
include/moveit/task_constructor Expand file tree Collapse file tree 4 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,8 @@ class ContainerBase : public Stage
6262 // / traverse all children of this container recursively
6363 bool traverseRecursively (const StageCallback& processor) const ;
6464
65+ void add (Stage::pointer&& stage);
66+
6567 virtual bool insert (Stage::pointer&& stage, int before = -1 );
6668 virtual bool remove (int pos);
6769 virtual bool remove (Stage* child);
Original file line number Diff line number Diff line change @@ -92,8 +92,8 @@ class Task : protected WrapperBase
9292 // / load robot model from given parameter
9393 void loadRobotModel (const std::string& robot_description = " robot_description" );
9494
95- // TODO: use Stage::insert as well?
9695 void add (Stage::pointer&& stage);
96+ bool insert (Stage::pointer&& stage, int before = -1 );
9797 void clear () final ;
9898
9999 // / enable introspection publishing for use with rviz
Original file line number Diff line number Diff line change @@ -194,7 +194,18 @@ bool ContainerBase::traverseRecursively(const ContainerBase::StageCallback& proc
194194 return pimpl ()->traverseStages (processor, 1 , UINT_MAX);
195195}
196196
197+ void ContainerBase::add (Stage::pointer&& stage) {
198+ if (!insert (std::move (stage))) {
199+ throw std::runtime_error (name () + " : Could not insert stage" );
200+ }
201+ }
202+
197203bool ContainerBase::insert (Stage::pointer&& stage, int before) {
204+ if (!stage) {
205+ ROS_ERROR_STREAM (name () << " : reveived invalid stage pointer" );
206+ return false ;
207+ }
208+
198209 StagePrivate* impl = stage->pimpl ();
199210 if (!impl->setParent (this ))
200211 return false ;
Original file line number Diff line number Diff line change @@ -194,11 +194,11 @@ void Task::loadRobotModel(const std::string& robot_description) {
194194}
195195
196196void Task::add (Stage::pointer&& stage) {
197- if (! stage)
198- throw std::runtime_error ( " stage insertion failed: invalid stage pointer " );
197+ stages ()-> add ( std::move ( stage));
198+ }
199199
200- if (! stages ()-> insert (std::move ( stage)))
201- throw std::runtime_error ( std::string ( " insertion failed for stage: " ) + stage-> name () );
200+ bool Task:: insert (Stage::pointer&& stage, int before) {
201+ return stages ()-> insert ( std::move ( stage), before );
202202}
203203
204204void Task::clear () {
You can’t perform that action at this time.
0 commit comments