From a21321f75ed0bdd53e3e1550de9a112b8077f281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergi=20Hern=C3=A0ndez=20Juan?= <shernand@iri.upc.edu> Date: Tue, 10 Oct 2017 14:21:57 +0000 Subject: [PATCH] Changes to avoid checking the action state when the action is not active. --- include/iri_ros_tools/module_action.h | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/include/iri_ros_tools/module_action.h b/include/iri_ros_tools/module_action.h index 565a4ed..64b7829 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()) -- GitLab