BehaviorTree / BehaviorTree.ROS2

BehaviorTree.CPP utilities to work with ROS2
Apache License 2.0
144 stars 59 forks source link

add payloads to Action #66

Closed facontidavide closed 4 months ago

facontidavide commented 4 months ago

The main goal of this PR is to support users that want to send and receive more comple payloads, when executing a Tree (arguments and return values).

A single string is used for both, since the majority of the users can use JSON to store any argitrary set of arguments.

The return value of onTreeExecutionCompleted has been changed to support a return value.

Also, about this code :

  // return success or aborted for the action result
  if(status == BT::NodeStatus::SUCCESS)
  {
    RCLCPP_INFO(kLogger, "BT finished with status: %s", BT::toStr(status).c_str());
    goal_handle->succeed(action_result);
  }
  else
  {
    action_result->error_message = std::string("Behavior Tree failed during execution "
                                               "with status: ") +
                                   BT::toStr(status);
    RCLCPP_ERROR(kLogger, action_result->error_message.c_str());
    goal_handle->abort(action_result);
  }

I don't think that a FAILURe shoult trigger a goal_handle->abort since, from a technical point of view, the tree has been executed.

facontidavide commented 4 months ago

@MarqRazz check my latest changes