[ROS2] Cancel Goal with a Description in Action

asked 2022-06-03 05:13:14 -0500

ravijoshi gravatar image

updated 2022-06-11 00:57:01 -0500

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?

edit retag flag offensive close merge delete

Comments

Any suggestions, please?

ravijoshi gravatar image ravijoshi  ( 2022-06-05 21:14:25 -0500 )edit

cross-posted: ros2/ros2#1279.

gvdhoorn gravatar image gvdhoorn  ( 2022-06-12 04:34:56 -0500 )edit

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

ravijoshi gravatar image ravijoshi  ( 2022-06-12 04:37:26 -0500 )edit