How to cancel ros2 action with ros2 cpp action client
Pleas provide ros2 cpp example client to cancel actions
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
Pleas provide ros2 cpp example client to cancel actions
As you wish https://github.com/ros-planning/navig...
auto future_cancel = action_client_->async_cancel_goal(goal_handle_);
if (callback_group_executor_.spin_until_future_complete(future_cancel, server_timeout_) !=
rclcpp::FutureReturnCode::SUCCESS)
{
RCLCPP_ERROR(
node_->get_logger(),
"Failed to cancel action server for %s", action_name_.c_str());
}
}
I think there is something weird around. According with your code we need the goal_handle_ to cancel the action. Ok, sounds good. But it turns out that you get that goal_handle_ value only after the future of the response of the original request is resolved.
I even wonder if you can cancel some specific action goal using the rclcpp_action API nowadays (Sept 2022).
The problem is that the "async_cancel_goal" requires a goal handle, but the "send_goal" function only provides a "future goal handle". You will get the required "goal handle" only after the response from the server is received. Too late to cancel.
see: https://github.com/ros2/rclcpp/blob/3...
I would say that is still an open issue in the rclcpp repo: https://github.com/ros2/rclcpp/issues...
By the moment, cancelling everything is an alternative:
client_ptr->async_cancel_all_goals();
Asked: 2022-03-09 10:15:58 -0500
Seen: 931 times
Last updated: Sep 07 '22
parameter_bridge with collection of topic in command line on ROS2 FOXY
[ROS2 Humble] Segmentation Fault for assigning Header/Frame ID to shared pointer
Slam_toolbox message filter dropping message
ROS in arm/v7, Docker, and Limited Storage Robot
subscription callback types ROS1 vs. ROS2
Sourcing setup.bash in ROS2 foxy
Should there be a DefaultQoS or default constructor for QoS?
colcon build in package source folders, how to avoid falling in this development mistake?