From 6729fb3ac35f04c96a20a144cb21c2183dfece02 Mon Sep 17 00:00:00 2001 From: Devis Dal Moro Date: Mon, 31 Mar 2025 12:37:11 +0000 Subject: [PATCH 1/5] Set blackboard bug fix Previous SetBlackboard action node did not update the sequence id, the timestamp when called on a pre-existing entry. Moreover, it allowed to bypass type checking. --- .../actions/set_blackboard_node.h | 2 +- tests/gtest_blackboard.cpp | 72 +++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/include/behaviortree_cpp/actions/set_blackboard_node.h b/include/behaviortree_cpp/actions/set_blackboard_node.h index 9882cea6f..6a9b7bbda 100644 --- a/include/behaviortree_cpp/actions/set_blackboard_node.h +++ b/include/behaviortree_cpp/actions/set_blackboard_node.h @@ -78,7 +78,7 @@ class SetBlackboardNode : public SyncActionNode config().blackboard->createEntry(output_key, src_entry->info); dst_entry = config().blackboard->getEntry(output_key); } - dst_entry->value = src_entry->value; + config().blackboard->set(output_key, src_entry->value); } else { diff --git a/tests/gtest_blackboard.cpp b/tests/gtest_blackboard.cpp index fcbc272a3..ad826cb10 100644 --- a/tests/gtest_blackboard.cpp +++ b/tests/gtest_blackboard.cpp @@ -654,3 +654,75 @@ TEST(BlackboardTest, TimestampedInterface) ASSERT_EQ(stamp_opt->seq, 2); ASSERT_GE(stamp_opt->time.count(), nsec_before); } + +TEST(BlackboardTest, SetBlackboard_Upd_Ts_SeqId) +{ + BT::BehaviorTreeFactory factory; + + const std::string xml_text = R"( + + + +