[ROS2] Cancel Goal with a Description in Action
I am writing an action server in ROS2. However, I could not find a way to provide a message to the client upon canceling a goal.
Please see the following code snippet:
if (goal->order > 9000) {
return rclcpp_action::GoalResponse::REJECT;
}
It would be best if a reason could be sent along with a message, say the following:
if (goal->order > 9000) {
return rclcpp_action::GoalResponse::REJECT ("Order, i.e., " << goal->order << " is more than allowed value");
}
Consider a situation wherein the goal has multiple parameters to check, as shown below:
if (goal->param_a < 0) {
return rclcpp_action::GoalResponse::REJECT;
}
if (goal->param_b == true) {
return rclcpp_action::GoalResponse::REJECT;
}
if (goal->param_c.size() > 10) {
return rclcpp_action::GoalResponse::REJECT;
}
In the above case, it would be better for the client to know why the goal was rejected. Therefore, my question is how to cancel a goal with a description in ROS2?
Any suggestions, please?
cross-posted: ros2/ros2#1279.
@gvdhoorn: Thanks for pointing out. Hope someone can advise on it.