From 0f9ebb2d75ef91e9b06792ad12322561ecac0bb5 Mon Sep 17 00:00:00 2001 From: Gregory LeMasurier Date: Thu, 18 Apr 2024 15:10:14 -0400 Subject: [PATCH] Add interaction node --- include/behaviortree_cpp/action_node.h | 2 +- include/behaviortree_cpp/basic_types.h | 1 + include/behaviortree_cpp/interaction_node.h | 25 +++++++++++++++++++++ src/interaction_node.cpp | 8 +++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 include/behaviortree_cpp/interaction_node.h create mode 100644 src/interaction_node.cpp diff --git a/include/behaviortree_cpp/action_node.h b/include/behaviortree_cpp/action_node.h index 3f9b64bf4..aeaede736 100644 --- a/include/behaviortree_cpp/action_node.h +++ b/include/behaviortree_cpp/action_node.h @@ -38,7 +38,7 @@ class ActionNodeBase : public LeafNode ActionNodeBase(const std::string& name, const NodeConfig& config); ~ActionNodeBase() override = default; - virtual NodeType type() const override final + virtual NodeType type() const override { return NodeType::ACTION; } diff --git a/include/behaviortree_cpp/basic_types.h b/include/behaviortree_cpp/basic_types.h index a51a1164c..cd191630d 100644 --- a/include/behaviortree_cpp/basic_types.h +++ b/include/behaviortree_cpp/basic_types.h @@ -21,6 +21,7 @@ enum class NodeType { UNDEFINED = 0, ACTION, + INTERACTION, CONDITION, ASSUMPTIONCHECKER, CONTROL, diff --git a/include/behaviortree_cpp/interaction_node.h b/include/behaviortree_cpp/interaction_node.h new file mode 100644 index 000000000..b00d2edcf --- /dev/null +++ b/include/behaviortree_cpp/interaction_node.h @@ -0,0 +1,25 @@ +#ifndef INTERACTIONNODE_H +#define INTERACTIONNODE_H + +#include "leaf_node.h" +#include "behaviortree_cpp/action_node.h" + +namespace BT +{ +class InteractionNode : public SyncActionNode +{ +public: + InteractionNode(const std::string& name, const NodeConfig& config); + ~InteractionNode() override = default; + + /// throws if the derived class return RUNNING. + virtual NodeStatus executeTick() override; + + virtual NodeType type() const override final + { + return NodeType::INTERACTION; + } +}; +} // namespace BT + +#endif diff --git a/src/interaction_node.cpp b/src/interaction_node.cpp new file mode 100644 index 000000000..b45de333b --- /dev/null +++ b/src/interaction_node.cpp @@ -0,0 +1,8 @@ +#include "behaviortree_cpp/interaction_node.h" + +namespace BT +{ +InteractionNode::InteractionNode(const std::string& name, const NodeConfig& config) + : SyncActionNode(name, config) +{} +} \ No newline at end of file