Returns CancelResponse::REJECT while goal handle failed to transit to CANCELING state (#1641) (#1659)

Signed-off-by: Kaven Yau <kavenyau@foxmail.com>
This commit is contained in:
Kaven Yau 2021-05-20 06:22:41 +08:00 committed by GitHub
parent d12ed36e89
commit 122355704b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -365,7 +365,14 @@ protected:
if (goal_handle) { if (goal_handle) {
resp = handle_cancel_(goal_handle); resp = handle_cancel_(goal_handle);
if (CancelResponse::ACCEPT == resp) { if (CancelResponse::ACCEPT == resp) {
try {
goal_handle->_cancel_goal(); goal_handle->_cancel_goal();
} catch (const rclcpp::exceptions::RCLError & ex) {
RCLCPP_DEBUG(
rclcpp::get_logger("rclcpp_action"),
"Failed to cancel goal in call_handle_cancel_callback: %s", ex.what());
return CancelResponse::REJECT;
}
} }
} }
return resp; return resp;