diff --git a/include/iri_ros_tools/module_action.h b/include/iri_ros_tools/module_action.h index 565a4ed4a04977cd24d8f4e99dabdf15c69ed327..64b78296d084e0d1abdc029daab5cf5b7d786288 100644 --- a/include/iri_ros_tools/module_action.h +++ b/include/iri_ros_tools/module_action.h @@ -665,10 +665,13 @@ template<class action_ros> void CModuleAction<action_ros>::cancel(void) { actionlib::SimpleClientGoalState action_state(actionlib::SimpleClientGoalState::PENDING); - - action_state=action_client->getState(); - if(action_state==actionlib::SimpleClientGoalState::ACTIVE) - this->action_client->cancelGoal(); + + if(this->status==ACTION_RUNNING) + { + action_state=action_client->getState(); + if(action_state==actionlib::SimpleClientGoalState::ACTIVE) + this->action_client->cancelGoal(); + } } template<class action_ros> @@ -676,9 +679,14 @@ bool CModuleAction<action_ros>::is_finished(void) { actionlib::SimpleClientGoalState action_state(actionlib::SimpleClientGoalState::PENDING); - action_state=action_client->getState(); - if(action_state==actionlib::SimpleClientGoalState::ACTIVE) - return false; + if(this->status==ACTION_RUNNING) + { + action_state=action_client->getState(); + if(action_state==actionlib::SimpleClientGoalState::ACTIVE) + return false; + else + return true; + } else return true; } @@ -688,9 +696,9 @@ action_status CModuleAction<action_ros>::get_state(void) { actionlib::SimpleClientGoalState action_state(actionlib::SimpleClientGoalState::PENDING); - action_state=action_client->getState(); if(this->status==ACTION_RUNNING) { + action_state=action_client->getState(); if(this->use_timeout && this->is_timeout_active()) this->status=ACTION_TIMEOUT; if(this->is_watchdog_active())