Decision Module
1.0
ICRA2020 AI Challenge Northwestern Polytechnical University Aoxiang Team Strategy Code
|
Go to the documentation of this file.
18 #ifndef ROBORTS_DECISION_BEHAVIOR_NODE_H
19 #define ROBORTS_DECISION_BEHAVIOR_NODE_H
25 #include "../blackboard/blackboard_raw.h"
27 #include "../strategy/strategy_execute.h"
53 class BehaviorNode :
public std::enable_shared_from_this<BehaviorNode>{
56 typedef std::shared_ptr<BehaviorNode>
Ptr;
214 child_node_ptr->SetParent(shared_from_this());
215 child_node_ptr->SetLevel(
level_+1);
221 virtual void AddChildren(std::initializer_list<BehaviorNode::Ptr> child_node_ptr_list){
222 for (
auto child_node_ptr = child_node_ptr_list.begin(); child_node_ptr!=child_node_ptr_list.end(); child_node_ptr++) {
224 (*child_node_ptr)->SetParent(shared_from_this());
225 (*child_node_ptr)->SetLevel(
level_+1);
295 virtual void AddChildren(std::initializer_list<std::shared_ptr<AbstractCommonStrategy>> child_node_ptr_list);
305 ROS_INFO(
"%s %s",
name_.c_str(), __FUNCTION__);
310 std::shared_ptr<AbstractCommonStrategy>
GetAction();
340 unsigned int threshold):
359 ROS_INFO(
"initialize start");
360 ROS_INFO(
"%s %s",
name_.c_str(), __FUNCTION__);
400 ROS_INFO(
"%s %s IDLE!",
name_.c_str(), __FUNCTION__);
403 ROS_INFO(
"%s %s SUCCESS!",
name_.c_str(), __FUNCTION__);
406 ROS_INFO(
"%s %s FAILURE!",
name_.c_str(), __FUNCTION__);
409 ROS_INFO(
"%s %s ERROR!",
name_.c_str(), __FUNCTION__);
432 #endif //ROBORTS_DECISION_BEHAVIOR_NODE_H
@ PRECONDITION
Precondition Node.
Behavior tree parallel node inherited from CompositeNode.
Definition: behavior_node.h:346
Behavior tree base node.
Definition: behavior_node.h:68
virtual BehaviorState Update()
Tick the node and update the state of the behavior node.
Definition: behavior_node.h:381
virtual ~CompositeNode()=default
@ FAILURE
Failure state as result.
virtual BehaviorNode::Ptr GetChild()
Get the child behavior node that it is turn to tick.
Definition: behavior_node.h:247
void SetLevel(unsigned int level)
Set the level of the behavior node.
Definition: behavior_node.h:172
std::string GetName()
Get the name of the behavior node.
Definition: behavior_node.h:137
virtual BehaviorState Update()
Tick the node and update the state of the behavior node.
Definition: behavior_node.cpp:51
unsigned int success_count_
the current number of child nodes with success behavior state
Definition: behavior_node.h:436
std::shared_ptr< Blackboard > Ptr
Definition: blackboard.h:37
unsigned int threshold_
the number of child nodes with success behavior state to determine success of the parallel node
Definition: behavior_node.h:440
unsigned int failure_count_
the current number of child nodes with failure behavior state
Definition: behavior_node.h:438
std::shared_ptr< BehaviorNode > Ptr
Definition: behavior_node.h:71
SelectorNode(std::string name, const Blackboard::Ptr &blackboard_ptr)
Constructor of SelectorNode.
Definition: behavior_node.h:303
std::vector< BehaviorNode::Ptr > & GetChildren()
Get the list of child behavior nodes.
Definition: behavior_node.h:254
virtual void OnInitialize()=0
Initialize something before starting to tick the node.
BehaviorState GetBehaviorState()
Get the state of the behavior node.
Definition: behavior_node.h:130
void SetParent(BehaviorNode::Ptr parent_node_ptr)
Set the parent of the behavior node.
Definition: behavior_node.h:144
@ IDLE
Idle state, state as default or after cancellation.
unsigned int level_
Level of the tree.
Definition: behavior_node.h:203
virtual BehaviorState Update()=0
Tick the node and update the state of the behavior node.
BehaviorState Run()
Run the behavior node.
Definition: behavior_node.h:95
Blackboard::Ptr blackboard_ptr_
Blackboard.
Definition: behavior_node.h:199
virtual BehaviorNode::Ptr GetChild()
Get the child node of the behavior node.
Definition: behavior_node.h:158
CompositeNode(std::string name, BehaviorType behavior_type, const Blackboard::Ptr &blackboard_ptr)
Constructor of CompositeNode.
Definition: behavior_node.h:217
BehaviorNode::Ptr GetParent()
Get the parent node of the behavior node.
Definition: behavior_node.h:151
virtual void OnTerminate(BehaviorState state)=0
Recover or reset something After getting the result.
void SetChildrenIndex(unsigned int children_node_index)
Set the index of the child node to tick.
Definition: behavior_node.cpp:93
virtual void OnInitialize()=0
Initialize something before starting to tick the node.
@ RUNNING
Running state in process.
void ExitThisAction()
Definition: behavior_node.cpp:14
unsigned int children_node_index_
the index of child nodes
Definition: behavior_node.h:290
virtual void OnTerminate(BehaviorState state)=0
Recover or reset something After getting the result.
std::vector< BehaviorNode::Ptr > children_node_ptr_
the list of child nodes
Definition: behavior_node.h:288
BehaviorType GetBehaviorType()
Get the type of the behavior node.
Definition: behavior_node.h:123
@ PARALLEL
Parallel Composite Node.
Definition: behavior_test_node.h:14
Behavior tree composite node inherited from BehaviorNode.
Definition: behavior_node.h:209
std::vector< bool > children_node_done_
a list of result checker flags for each child node
Definition: behavior_node.h:434
ParallelNode(std::string name, const Blackboard::Ptr &blackboard_ptr, unsigned int threshold)
Constructor of ParallelNode.
Definition: behavior_node.h:354
@ SELECTOR
Selector Composite Node.
std::shared_ptr< AbstractCommonStrategy > ptr_selector_node_
Definition: behavior_node.h:335
virtual void OnInitialize()
Initialize something before starting to tick the node.
Definition: behavior_node.h:369
virtual void OnTerminate(BehaviorState state)
Recover or reset something After getting the result.
Definition: behavior_node.h:412
unsigned int GetChildrenIndex()
Get the index of the child behavior node that it is turn to tick.
Definition: behavior_node.h:261
std::vector< std::shared_ptr< AbstractCommonStrategy > > children_node_ptr_vector_
Definition: behavior_node.h:336
BehaviorType
Type of behavior tree node.
Definition: behavior_node.h:48
@ SUCCESS
Success state as result.
std::shared_ptr< AbstractCommonStrategy > GetAction()
Definition: behavior_node.cpp:19
BehaviorState
Behavior state.
Definition: behavior_state.h:11
unsigned int GetChildrenNum()
Get the number of child behavior nodes.
Definition: behavior_node.h:268
virtual void AddChildren(const BehaviorNode::Ptr &child_node_ptr)
Add child behavior node to the composite node.
Definition: behavior_node.h:227
virtual BehaviorState Update()=0
Tick the node and update the state of the behavior node.
unsigned int GetLevel()
Get the level of the behavior node.
Definition: behavior_node.h:165
BehaviorNode()
Definition: behavior_node.h:72
void OnTerminate(BehaviorState state)
Recover or reset something After getting the result.
Definition: behavior_node.cpp:69
virtual void Reset()
Reset the behavior node.
Definition: behavior_node.h:113
BehaviorState behavior_state_
State.
Definition: behavior_node.h:195
BehaviorNode::Ptr parent_node_ptr_
Parent Node Pointer.
Definition: behavior_node.h:201
bool HasActionOnGoing()
Definition: behavior_node.cpp:10
virtual ~ParallelNode()=default
virtual void AddChildren(std::initializer_list< std::shared_ptr< AbstractCommonStrategy >> child_node_ptr_list)
Definition: behavior_node.cpp:42
virtual void OnInitialize()
Initialize something before starting to tick the node.
Definition: behavior_node.h:318
std::shared_ptr< AbstractCommonStrategy > ChooseActionToExecute()
Definition: behavior_node.cpp:33
virtual ~SelectorNode()=default
std::string name_
Node name.
Definition: behavior_node.h:192
virtual ~BehaviorNode()=default
Behavior tree selector node inherited from CompositeNode.
Definition: behavior_node.h:296
@ SEQUENCE
Sequence Composite Node.
BehaviorType behavior_type_
Type.
Definition: behavior_node.h:197