From 86ac6d8cc1eda87771ca2bf575e8055607c295a1 Mon Sep 17 00:00:00 2001 From: Alopez <alopez@iri.upc.edu> Date: Tue, 6 Apr 2021 14:31:12 +0200 Subject: [PATCH] Added async_is_tree_start and async_is_tree_stop --- include/iri_bt_basic_nodes.h | 2 ++ src/iri_bt_basic_nodes.cpp | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/iri_bt_basic_nodes.h b/include/iri_bt_basic_nodes.h index c7b0e57..d26eaaa 100644 --- a/include/iri_bt_basic_nodes.h +++ b/include/iri_bt_basic_nodes.h @@ -39,7 +39,9 @@ class IriBTBasicNodes BT::NodeStatus NOP(void); // functions to check whether start or restart have been demanded by the user BT::NodeStatus is_not_start_tree(void); + BT::NodeStatus async_is_start_tree(void); BT::NodeStatus is_not_stop_tree(void); + BT::NodeStatus async_is_stop_tree(void); // functions set start or restart variables BT::NodeStatus set_start_tree(void); diff --git a/src/iri_bt_basic_nodes.cpp b/src/iri_bt_basic_nodes.cpp index dbf6640..e0efa60 100644 --- a/src/iri_bt_basic_nodes.cpp +++ b/src/iri_bt_basic_nodes.cpp @@ -12,7 +12,9 @@ void IriBTBasicNodes::init(IriBehaviorTreeFactory &factory) factory.registerIriAsyncAction("NOP", std::bind(&IriBTBasicNodes::NOP, this)); factory.registerSimpleCondition("is_not_start_tree", std::bind(&IriBTBasicNodes::is_not_start_tree, this)); + factory.registerIriAsyncAction("async_is_start_tree", std::bind(&IriBTBasicNodes::async_is_start_tree, this)); factory.registerSimpleCondition("is_not_stop_tree", std::bind(&IriBTBasicNodes::is_not_stop_tree, this)); + factory.registerIriAsyncAction("async_is_stop_tree", std::bind(&IriBTBasicNodes::async_is_stop_tree, this)); factory.registerSimpleAction("set_start_tree", std::bind(&IriBTBasicNodes::set_start_tree, this)); factory.registerSimpleAction("set_stop_tree", std::bind(&IriBTBasicNodes::set_stop_tree, this)); @@ -33,6 +35,14 @@ BT::NodeStatus IriBTBasicNodes::is_not_start_tree(void) return BT::NodeStatus::SUCCESS; } +BT::NodeStatus IriBTBasicNodes::async_is_start_tree(void) +{ + if(this->tree_start) + return BT::NodeStatus::SUCCESS; + else + return BT::NodeStatus::RUNNING; +} + BT::NodeStatus IriBTBasicNodes::is_not_stop_tree(void) { if(this->tree_stop) @@ -41,6 +51,14 @@ BT::NodeStatus IriBTBasicNodes::is_not_stop_tree(void) return BT::NodeStatus::SUCCESS; } +BT::NodeStatus IriBTBasicNodes::async_is_stop_tree(void) +{ + if(this->tree_stop) + return BT::NodeStatus::SUCCESS; + else + return BT::NodeStatus::RUNNING; +} + BT::NodeStatus IriBTBasicNodes::set_start_tree(void) { this->tree_start=true; -- GitLab