@@ -213,11 +213,12 @@ void Task::init() {
213
213
// task expects its wrapped child to push to both ends, this triggers interface resolution
214
214
stages ()->pimpl ()->resolveInterface (InterfaceFlags ({ GENERATE }));
215
215
216
- // provide introspection instance to all stages
216
+ // provide introspection instance and prempted requested to all stages
217
217
auto * introspection = impl->introspection_ .get ();
218
218
impl->traverseStages (
219
- [introspection](Stage& stage, int /* depth*/ ) {
219
+ [introspection, impl ](Stage& stage, int /* depth*/ ) {
220
220
stage.pimpl ()->setIntrospection (introspection);
221
+ stage.pimpl ()->setPreemptedCheck (&impl->preempt_requested_ );
221
222
return true ;
222
223
},
223
224
1 , UINT_MAX);
@@ -232,7 +233,11 @@ bool Task::canCompute() const {
232
233
}
233
234
234
235
void Task::compute () {
235
- stages ()->pimpl ()->runCompute ();
236
+ try {
237
+ stages ()->pimpl ()->runCompute ();
238
+ } catch (const PreemptStageException& e) {
239
+ // do nothing, needed for early stop
240
+ }
236
241
}
237
242
238
243
moveit::core::MoveItErrorCode Task::plan (size_t max_solutions) {
@@ -274,6 +279,10 @@ void Task::resetPreemptRequest() {
274
279
pimpl ()->preempt_requested_ = false ;
275
280
}
276
281
282
+ bool Task::isPreempted () {
283
+ return pimpl ()->preempt_requested_ ;
284
+ }
285
+
277
286
moveit::core::MoveItErrorCode Task::execute (const SolutionBase& s) {
278
287
actionlib::SimpleActionClient<moveit_task_constructor_msgs::ExecuteTaskSolutionAction> ac (" execute_task_solution" );
279
288
if (!ac.waitForServer (ros::Duration (0.5 ))) {
0 commit comments