test_node.h
Go to the documentation of this file.
1 /* Copyright (C) 2022 Davide Faconti - All Rights Reserved
2  *
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
6 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
10 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
11 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 */
13 
14 #pragma once
15 
19 
20 namespace BT
21 {
22 
24 {
27 
29  std::string success_script;
30 
32  std::string failure_script;
33 
35  std::string post_script;
36 
38  std::chrono::milliseconds async_delay = std::chrono::milliseconds(0);
39 
42  std::function<NodeStatus(void)> complete_func = [this]() { return return_status; };
43 };
44 
65 {
66 public:
67  TestNode(const std::string& name, const NodeConfig& config, TestNodeConfig test_config);
68 
70  {
71  return {};
72  }
73 
74 protected:
75  virtual NodeStatus onStart() override;
76 
77  virtual NodeStatus onRunning() override;
78 
79  virtual void onHalted() override;
80 
82 
88  std::atomic_bool _completed = false;
89 };
90 
91 } // namespace BT
BT
Definition: ex01_wrap_legacy.cpp:29
BT::TestNodeConfig::failure_script
std::string failure_script
script to execute when complete_func() returns FAILURE
Definition: test_node.h:32
BT::TestNodeConfig::async_delay
std::chrono::milliseconds async_delay
if async_delay > 0, this action become asynchronous and wait this amount of time
Definition: test_node.h:38
BT::TimerQueue
Definition: timer_queue.h:72
BT::TreeNode::config
const NodeConfig & config() const
Definition: tree_node.cpp:345
BT::TestNode::providedPorts
static PortsList providedPorts()
Definition: test_node.h:69
BT::TestNode::onHalted
virtual void onHalted() override
Definition: test_node.cpp:62
BT::ScriptFunction
std::function< Any(Ast::Environment &env)> ScriptFunction
Definition: script_parser.hpp:43
BT::TestNode::_timer
TimerQueue _timer
Definition: test_node.h:87
timer_queue.h
BT::TestNode::_success_executor
ScriptFunction _success_executor
Definition: test_node.h:84
BT::PortsList
std::unordered_map< std::string, PortInfo > PortsList
Definition: basic_types.h:585
BT::TestNodeConfig
Definition: test_node.h:23
action_node.h
BT::TestNodeConfig::return_status
NodeStatus return_status
status to return when the action is completed.
Definition: test_node.h:26
BT::TreeNode::name
const std::string & name() const
Name of the instance, not the type.
Definition: tree_node.cpp:296
BT::NodeStatus::SUCCESS
@ SUCCESS
BT::TestNodeConfig::success_script
std::string success_script
script to execute when complete_func() returns SUCCESS
Definition: test_node.h:29
BT::TestNode::_test_config
TestNodeConfig _test_config
Definition: test_node.h:83
BT::TestNode
The TestNode is a Node that can be configure to:
Definition: test_node.h:64
BT::TestNodeConfig::complete_func
std::function< NodeStatus(void)> complete_func
Definition: test_node.h:42
BT::TestNode::_post_executor
ScriptFunction _post_executor
Definition: test_node.h:86
BT::TestNodeConfig::post_script
std::string post_script
script to execute when actions is completed
Definition: test_node.h:35
BT::TestNode::_failure_executor
ScriptFunction _failure_executor
Definition: test_node.h:85
BT::TestNode::_completed
std::atomic_bool _completed
Definition: test_node.h:88
BT::TestNode::onRunning
virtual NodeStatus onRunning() override
method invoked when the action is already in the RUNNING state.
Definition: test_node.cpp:53
BT::NodeConfig
Definition: tree_node.h:73
BT::TestNode::onCompleted
NodeStatus onCompleted()
Definition: test_node.cpp:67
BT::NodeStatus
NodeStatus
Definition: basic_types.h:33
script_parser.hpp
BT::TestNode::TestNode
TestNode(const std::string &name, const NodeConfig &config, TestNodeConfig test_config)
Definition: test_node.cpp:3
BT::StatefulActionNode
The StatefulActionNode is the preferred way to implement asynchronous Actions. It is actually easier ...
Definition: action_node.h:159
BT::TestNode::onStart
virtual NodeStatus onStart() override
Definition: test_node.cpp:30


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Jun 28 2024 02:20:08