From 396a4f157d75e42a3fd6de5f681315342695a844 Mon Sep 17 00:00:00 2001 From: Kotakku Date: Thu, 15 Feb 2024 13:31:59 +0900 Subject: [PATCH] =?UTF-8?q?control=E3=81=A8decorator=E3=81=AE=E3=82=A8?= =?UTF-8?q?=E3=82=A4=E3=83=AA=E3=82=A2=E3=82=B9=E9=96=A2=E6=95=B0=E5=90=8D?= =?UTF-8?q?=E3=82=92=E7=9F=AD=E7=B8=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../micro_behaviortree_cpp.hpp | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/include/micro_behaviortree_cpp/micro_behaviortree_cpp.hpp b/include/micro_behaviortree_cpp/micro_behaviortree_cpp.hpp index 65daf61..ed446b3 100644 --- a/include/micro_behaviortree_cpp/micro_behaviortree_cpp.hpp +++ b/include/micro_behaviortree_cpp/micro_behaviortree_cpp.hpp @@ -146,7 +146,7 @@ class Builder return *this; } - Builder& control_end() + Builder& end() { bool is_control_child = (!builder_parent_.empty() && builder_parent_.back().control_node != nullptr); assert(is_control_child); @@ -164,26 +164,26 @@ class Builder {"value", value}}); } - Builder& control_fallback() { return control({}); } - Builder& control_if_then_else() { return control({}); } - Builder& control_parallel(int failure_threshold, int success_threshold) + Builder& fallback() { return control({}); } + Builder& if_then_else() { return control({}); } + Builder& parallel(int failure_threshold, int success_threshold) { return control({ {"failure_threshold", toStr(failure_threshold)}, {"success_threshold", toStr(success_threshold)}}); } - Builder& control_reactive_fallback() { return control({}); } - Builder& control_reactive_sequence() { return control({}); } - Builder& control_sequence() { return control({}); } - Builder& control_sequence_star() { return control({}); } - Builder& control_switch2(const std::string& variable, const std::string& value_1, const std::string& value_2) + Builder& reactive_fallback() { return control({}); } + Builder& reactive_sequence() { return control({}); } + Builder& sequence() { return control({}); } + Builder& sequence_star() { return control({}); } + Builder& switch2(const std::string& variable, const std::string& value_1, const std::string& value_2) { return control>({ {"variable", variable}, {"value_1", value_1}, {"value_2", value_2}}); } - Builder& control_switch3(const std::string& variable, const std::string& value_1, const std::string& value_2, const std::string& value_3) + Builder& switch3(const std::string& variable, const std::string& value_1, const std::string& value_2, const std::string& value_3) { return control>({ {"variable", variable}, @@ -191,7 +191,7 @@ class Builder {"value_2", value_2}, {"value_3", value_3}}); } - Builder& control_switch4(const std::string& variable, const std::string& value_1, const std::string& value_2, const std::string& value_3, const std::string& value_4) + Builder& switch4(const std::string& variable, const std::string& value_1, const std::string& value_2, const std::string& value_3, const std::string& value_4) { return control>({ {"variable", variable}, @@ -200,7 +200,7 @@ class Builder {"value_3", value_3}, {"value_4", value_4}}); } - Builder& control_switch5(const std::string& variable, const std::string& value_1, const std::string& value_2, const std::string& value_3, const std::string& value_4, const std::string& value_5) + Builder& switch5(const std::string& variable, const std::string& value_1, const std::string& value_2, const std::string& value_3, const std::string& value_4, const std::string& value_5) { return control>({ {"variable", variable}, @@ -210,7 +210,7 @@ class Builder {"value_4", value_4}, {"value_5", value_5}}); } - Builder& control_switch6(const std::string& variable, const std::string& value_1, const std::string& value_2, const std::string& value_3, const std::string& value_4, const std::string& value_5, const std::string& value_6) + Builder& switch6(const std::string& variable, const std::string& value_1, const std::string& value_2, const std::string& value_3, const std::string& value_4, const std::string& value_5, const std::string& value_6) { return control>({ {"variable", variable}, @@ -221,42 +221,42 @@ class Builder {"value_5", value_5}, {"value_6", value_6}}); } - Builder& control_while_do_else() { return control({}); } + Builder& while_do_else() { return control({}); } - Builder& decorator_blackboard_check_bool(bool value_A, bool value_B, NodeStatus return_on_mismatch) + Builder& blackboard_check_bool(bool value_A, bool value_B, NodeStatus return_on_mismatch) { return decorator>({ {"value_A", toStr(value_A)}, {"value_B", toStr(value_B)}, {"return_on_mismatch", toStr(return_on_mismatch)}}); } - Builder& decorator_blackboard_check_int(int value_A, int value_B, NodeStatus return_on_mismatch) + Builder& blackboard_check_int(int value_A, int value_B, NodeStatus return_on_mismatch) { return decorator>({ {"value_A", toStr(value_A)}, {"value_B", toStr(value_B)}, {"return_on_mismatch", toStr(return_on_mismatch)}}); } - Builder& decorator_blackboard_check_double(double value_A, double value_B, NodeStatus return_on_mismatch) + Builder& blackboard_check_double(double value_A, double value_B, NodeStatus return_on_mismatch) { return decorator>({ {"value_A", toStr(value_A)}, {"value_B", toStr(value_B)}, {"return_on_mismatch", toStr(return_on_mismatch)}}); } - Builder& decorator_blackboard_check_string(const std::string &value_A, const std::string &value_B, NodeStatus return_on_mismatch) + Builder& blackboard_check_string(const std::string &value_A, const std::string &value_B, NodeStatus return_on_mismatch) { return decorator>({ {"value_A", value_A}, {"value_B", value_B}, {"return_on_mismatch", toStr(return_on_mismatch)}}); } - Builder& decorator_force_failure() { return decorator({}); } - Builder& decorator_force_success() { return decorator({}); } - Builder& decorator_inverter() { return decorator({}); } - Builder& decorator_keep_running_until_failure() { return decorator({}); } - Builder& decorator_repeat(int num_cycles) { return decorator({{"num_cycles", toStr(num_cycles)}}); } - Builder& decorator_retry_until_successful(int num_attempts) { return decorator({{"num_attempts", toStr(num_attempts)}}); } + Builder& force_failure() { return decorator({}); } + Builder& force_success() { return decorator({}); } + Builder& inverter() { return decorator({}); } + Builder& keep_running_until_failure() { return decorator({}); } + Builder& repeat(int num_cycles) { return decorator({{"num_cycles", toStr(num_cycles)}}); } + Builder& retry_until_successful(int num_attempts) { return decorator({{"num_attempts", toStr(num_attempts)}}); } Tree::SharedPtr build() {