Robotics StackExchange | Archived questions

[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?

Asked by ravijoshi on 2022-06-03 05:13:14 UTC

Comments

Any suggestions, please?

Asked by ravijoshi on 2022-06-05 21:14:25 UTC

cross-posted: ros2/ros2#1279.

Asked by gvdhoorn on 2022-06-12 04:34:56 UTC

@gvdhoorn: Thanks for pointing out. Hope someone can advise on it.

Asked by ravijoshi on 2022-06-12 04:37:26 UTC

Answers