Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions plansys2_bt_actions/src/plansys2_bt_actions/BTAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ void BTAction::do_work()
{
if (!finished_) {
BT::NodeStatus result;
std::string out_msg;
try {
result = tree_.rootNode()->executeTick();
} catch (BT::LogicError e) {
Expand All @@ -206,16 +207,23 @@ void BTAction::do_work()
finish(false, 0.0, "BTAction behavior tree threw an unknown exception");
}

if (!blackboard_->get("out_msg", out_msg)) {
out_msg = "";
}

switch (result) {
case BT::NodeStatus::SUCCESS:
finish(true, 1.0, "BTAction behavior tree returned SUCCESS");
finish(true, 1.0,
out_msg.empty() ? "BTAction behavior tree returned SUCCESS" : out_msg);
finished_ = true;
break;
case BT::NodeStatus::RUNNING:
send_feedback(0.0, "BTAction behavior tree returned RUNNING");
send_feedback(0.0,
out_msg.empty() ? "BTAction behavior tree returned RUNNING" : out_msg);
break;
case BT::NodeStatus::FAILURE:
finish(false, 1.0, "BTAction behavior tree returned FAILURE");
finish(false, 1.0,
out_msg.empty() ? "BTAction behavior tree returned FAILURE" : out_msg);
finished_ = true;
break;
}
Expand Down
Loading