├── contributors.txt
├── behavior_tree_core
├── contributors.txt
├── action
│ └── BT.action
├── package.xml
├── src
│ ├── exceptions.cpp
│ ├── leaf_node.cpp
│ ├── condition_node.cpp
│ ├── action_node.cpp
│ ├── tick_engine.cpp
│ ├── gtest
│ │ ├── external_ros_nodes_test.cpp
│ │ └── gtest_tree.cpp
│ ├── conditions
│ │ ├── ros_condition.cpp
│ │ └── condition_test_node.cpp
│ ├── behavior_tree.cpp
│ ├── tree.cpp
│ ├── actions
│ │ ├── action_test_node.cpp
│ │ └── ros_action.cpp
│ ├── tree_node.cpp
│ ├── decorators
│ │ └── negation_node.cpp
│ ├── decorator_node.cpp
│ ├── control_node.cpp
│ ├── sequence_node.cpp
│ ├── fallback_node.cpp
│ ├── parallel_node.cpp
│ ├── fallback_node_with_memory.cpp
│ ├── sequence_node_with_memory.cpp
│ ├── dot_bt.cpp
│ └── draw.cpp
├── include
│ ├── leaf_node.h
│ ├── tick_engine.h
│ ├── exceptions.h
│ ├── sequence_node.h
│ ├── decorators
│ │ └── negation_node.h
│ ├── fallback_node.h
│ ├── decorator_node.h
│ ├── conditions
│ │ ├── condition_test_node.h
│ │ └── ros_condition.h
│ ├── actions
│ │ ├── action_test_node.h
│ │ └── ros_action.h
│ ├── fallback_node_with_memory.h
│ ├── parallel_node.h
│ ├── sequence_node_with_memory.h
│ ├── condition_node.h
│ ├── action_node.h
│ ├── behavior_tree.h
│ ├── draw.h
│ ├── control_node.h
│ ├── tree_node.h
│ └── dot_bt.h
├── templates
│ ├── condition_node_template.cpp
│ └── action_node_template.cpp
└── CMakeLists.txt
├── behavior_tree_leaves
├── contributors.txt
├── launch
│ └── test_behavior_tree.launch
├── example_nodes
│ ├── python
│ │ ├── class_example.py
│ │ ├── bt_action.py
│ │ ├── condition_example.py
│ │ └── action_example.py
│ └── cpp
│ │ ├── class_example.cpp
│ │ ├── bt_action.h
│ │ ├── condition_example.cpp
│ │ └── action_example.cpp
├── package.xml
├── src
│ ├── action_client.cpp
│ └── condition_client.cpp
└── CMakeLists.txt
├── BTUserManual.pdf
├── behavior_tree
├── CMakeLists.txt
└── package.xml
├── LICENSE
└── README.md
/contributors.txt:
--------------------------------------------------------------------------------
1 | Michele Colledanchise
2 |
--------------------------------------------------------------------------------
/behavior_tree_core/contributors.txt:
--------------------------------------------------------------------------------
1 | Michele Colledanchise
2 |
--------------------------------------------------------------------------------
/behavior_tree_leaves/contributors.txt:
--------------------------------------------------------------------------------
1 | Michele Colledanchise
2 |
--------------------------------------------------------------------------------
/BTUserManual.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miccol/ROS-Behavior-Tree/HEAD/BTUserManual.pdf
--------------------------------------------------------------------------------
/behavior_tree/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8.3)
2 | project(behavior_tree)
3 | find_package(catkin REQUIRED)
4 | catkin_metapackage()
5 |
--------------------------------------------------------------------------------
/behavior_tree_core/action/BT.action:
--------------------------------------------------------------------------------
1 | #goal definition
2 | int32 parameter #no goal needed for BT tick. But It could be useful to have a parameter for action (e.g.goto x,y)
3 | ---
4 | #result definition RUNNING = 0, SUCCESS = 1, FAILURE = 2
5 | int32 status
6 | ---
7 | #feedback
8 | int32 status
9 |
--------------------------------------------------------------------------------
/behavior_tree_leaves/launch/test_behavior_tree.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/behavior_tree/package.xml:
--------------------------------------------------------------------------------
1 |
2 | behavior_tree
3 | 1.0.0
4 | A ROS behavior tree library. The leaf nodes (user defined) can be either in C++ or python
5 |
6 | Michele Colledanchise
7 | MIT
8 | Michele Colledanchise
9 | Rocco Santomo
10 | Petter Ögren
11 |
12 | catkin
13 | behavior_tree_core
14 | behavior_tree_leaves
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/behavior_tree_leaves/example_nodes/python/class_example.py:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env python
2 | # Author: Anas Abou Allaban
3 |
4 | import rospy
5 | from bt_action import BTAction
6 |
7 |
8 | class Start(BTAction):
9 |
10 | def __init__(self):
11 | self.condition = true
12 | # Behavior tree action server
13 | super(Start, self).__init__('Start')
14 |
15 | def execute_cb(self, goal):
16 | while not rospy.is_shutdown():
17 | if self._as.is_preempt_requested():
18 | rospy.loginfo("{} halted".format(self._action_name))
19 | self._as.set_preempted()
20 | self.set_status(False)
21 | break
22 | if condition:
23 | self.set_status(True)
24 | else:
25 | self.set_status(False)
26 |
--------------------------------------------------------------------------------
/behavior_tree_leaves/example_nodes/cpp/class_example.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Example for abstract class implementation
3 | */
4 |
5 | #include
6 | #include
7 |
8 |
9 | class StartCondition: public BTAction
10 | {
11 | public:
12 | bool start_condition = false;
13 | ros::NodeHandle nh_;
14 |
15 | StartCondition(ros::NodeHandle* n) :
16 | BTAction("StartCondition"),
17 | nh_(*n)
18 | {
19 | nh_.param("/start_condition", start_condition, false);
20 | }
21 |
22 | void execute_callback(const behavior_tree_core::BTGoalConstPtr &goal)
23 | {
24 | set_status(SUCCESS);
25 | // if (start_condition)
26 | // set_status(SUCCESS);
27 | // else
28 | // set_status(FAILURE);
29 | }
30 | };
31 |
32 | int main(int argc, char** argv)
33 | {
34 | ros::init(argc, argv, "start_conditions");
35 | ros::NodeHandle nh;
36 | StartCondition sc(&nh);
37 | ros::spin();
38 | return 0;
39 | }
40 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 - 2018 Michele Colledanchise
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/behavior_tree_core/package.xml:
--------------------------------------------------------------------------------
1 |
2 | behavior_tree_core
3 | 0.0.0
4 |
5 | This package provides a behavior trees framework in ROS.
6 |
7 | Michele Colledanchise
8 | MIT
9 | Michele Colledanchise
10 |
11 | catkin
12 | message_generation
13 | roscpp
14 | roslib
15 | rospy
16 | std_msgs
17 | message_generation
18 | actionlib
19 | actionlib_msgs
20 | glut
21 | libxmu-dev
22 | libxi-dev
23 | actionlib
24 | actionlib_msgs
25 | message_runtime
26 | roscpp
27 | roslib
28 | rospy
29 | std_msgs
30 |
31 |
32 |
--------------------------------------------------------------------------------
/behavior_tree_leaves/example_nodes/python/bt_action.py:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env python
2 | # Author: Anas Abou Allaban
3 |
4 | import rospy
5 | import actionlib
6 | import behavior_tree_core.msg
7 | from abc import ABCMeta, abstractmethod
8 |
9 |
10 | class BTAction:
11 | __metaclass__ = ABCMeta
12 | _feedback = behavior_tree_core.msg.BTFeedback()
13 | _result = behavior_tree_core.msg.BTResult()
14 |
15 | def __init__(self, name):
16 | # Behavior tree action server
17 | self._action_name = name
18 | self._as = actionlib.SimpleActionServer(self._action_name, behavior_tree_core.msg.BTAction,
19 | execute_cb=self.execute_cb, auto_start=False)
20 | self._as.start()
21 | rospy.loginfo("{} Server Started".format(self._action_name))
22 |
23 | @abstractmethod
24 | def execute_cb(self, goal):
25 | raise NotImplementedError()
26 |
27 | def set_status(self, status):
28 | if status:
29 | self._feedback.status = 1
30 | self._result.status = self._feedback.status
31 | rospy.loginfo('Action %s: Succeeded' % self._action_name)
32 | self._as.set_succeeded(self._result)
33 | else:
34 | self._feedback.status = 2
35 | self._result.status = self._feedback.status
36 | rospy.loginfo('Action %s: Failed' % self._action_name)
37 | self._as.set_succeeded(self._result)
38 |
--------------------------------------------------------------------------------
/behavior_tree_core/src/exceptions.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5 | * 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:
6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | *
8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 | * 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,
10 | * 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.
11 | */
12 |
13 | #include
14 | #include
15 |
16 | BT::BehaviorTreeException::BehaviorTreeException(const std::string Message)
17 | {
18 | this->Message = std::string("BehaviorTreeException: " + Message).c_str();
19 | }
20 |
21 | const char* BT::BehaviorTreeException::what()
22 | {
23 | return Message;
24 | }
25 |
--------------------------------------------------------------------------------
/behavior_tree_core/src/leaf_node.cpp:
--------------------------------------------------------------------------------
1 |
2 | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
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 | #include
15 | #include
16 |
17 | BT::LeafNode::LeafNode(std::string name) : TreeNode(name) {}
18 |
19 | BT::LeafNode::~LeafNode() {}
20 |
21 |
22 | void BT::LeafNode::ResetColorState()
23 | {
24 | color_status_ = BT::IDLE;
25 | }
26 |
27 | int BT::LeafNode::Depth()
28 | {
29 | return 0;
30 | }
31 |
--------------------------------------------------------------------------------
/behavior_tree_core/include/leaf_node.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5 | * 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:
6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | *
8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 | * 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,
10 | * 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.
11 | */
12 |
13 | #ifndef LEAF_NODE_H
14 | #define LEAF_NODE_H
15 |
16 | #include
17 | #include
18 | #include
19 | namespace BT
20 | {
21 | class LeafNode : public TreeNode
22 | {
23 | protected:
24 | public:
25 | explicit LeafNode(std::string name);
26 | ~LeafNode();
27 | void ResetColorState();
28 | int Depth();
29 | };
30 | } // namespace BT
31 |
32 | #endif // LEAF_NODE_H
33 |
--------------------------------------------------------------------------------
/behavior_tree_core/src/condition_node.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5 | * 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:
6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | *
8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 | * 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,
10 | * 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.
11 | */
12 |
13 | #include
14 | #include
15 |
16 | BT::ConditionNode::ConditionNode(std::string name) : LeafNode::LeafNode(name)
17 | {
18 | type_ = BT::CONDITION_NODE;
19 | }
20 |
21 | BT::ConditionNode::~ConditionNode() {}
22 |
23 | void BT::ConditionNode::Halt() {}
24 |
25 | int BT::ConditionNode::DrawType()
26 | {
27 | // Lock acquistion
28 |
29 | return BT::CONDITION;
30 | }
31 |
--------------------------------------------------------------------------------
/behavior_tree_core/include/tick_engine.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5 | * 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:
6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | *
8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 | * 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,
10 | * 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.
11 | */
12 |
13 | #ifndef TICK_ENGINE_H
14 | #define TICK_ENGINE_H
15 |
16 | #include
17 |
18 | class TickEngine
19 | {
20 | private:
21 | int value_;
22 | std::mutex mutex_;
23 | std::condition_variable condition_variable_;
24 | public:
25 | explicit TickEngine(int initial_value);
26 | ~TickEngine();
27 | void Wait();
28 | void Tick();
29 | };
30 |
31 | #endif // TICK_ENGINE_H
32 |
--------------------------------------------------------------------------------
/behavior_tree_leaves/example_nodes/python/condition_example.py:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env python
2 |
3 |
4 | import rospy
5 |
6 | import actionlib
7 |
8 | import behavior_tree_core.msg
9 |
10 |
11 |
12 |
13 | class BTAction(object):
14 | # create messages that are used to publish feedback/result
15 | _feedback = behavior_tree_core.msg.BTFeedback()
16 | _result = behavior_tree_core.msg.BTResult()
17 |
18 | def __init__(self, name):
19 | self._action_name = name
20 | self._as = actionlib.SimpleActionServer(self._action_name, behavior_tree_core.msg.BTAction, execute_cb=self.execute_cb, auto_start = False)
21 | self._as.start()
22 |
23 | def execute_cb(self, goal):
24 |
25 | # publish info to the console for the user
26 | rospy.loginfo('Checking Condition')
27 |
28 | self.set_status('FAILURE')
29 |
30 |
31 |
32 | def set_status(self,status):
33 | if status == 'SUCCESS':
34 | self._feedback.status = 1
35 | self._result.status = self._feedback.status
36 | rospy.loginfo('Action %s: Succeeded' % self._action_name)
37 | self._as.set_succeeded(self._result)
38 | elif status == 'FAILURE':
39 | self._feedback.status = 2
40 | self._result.status = self._feedback.status
41 | rospy.loginfo('Action %s: Failed' % self._action_name)
42 | self._as.set_succeeded(self._result)
43 | else:
44 | rospy.logerr('Action %s: has a wrong return status' % self._action_name)
45 |
46 |
47 |
48 | if __name__ == '__main__':
49 | rospy.init_node('condition')
50 | BTAction(rospy.get_name())
51 | rospy.spin()
52 |
--------------------------------------------------------------------------------
/behavior_tree_core/include/exceptions.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5 | * 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:
6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | *
8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 | * 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,
10 | * 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.
11 | */
12 |
13 |
14 | #ifndef EXCEPTIONS_H
15 | #define EXCEPTIONS_H
16 |
17 | #include
18 | #include
19 |
20 | namespace BT
21 | {
22 | /// Exception class
23 | class BehaviorTreeException : public std::exception
24 | {
25 | private:
26 | const char* Message;
27 | public:
28 | explicit BehaviorTreeException(const std::string Message);
29 | const char* what();
30 | };
31 | } // namespace BT
32 |
33 | #endif // EXCEPTIONS_H
34 |
--------------------------------------------------------------------------------
/behavior_tree_core/include/sequence_node.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5 | * 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:
6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | *
8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 | * 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,
10 | * 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.
11 | */
12 |
13 |
14 | #ifndef SEQUENCE_NODE_H
15 | #define SEQUENCE_NODE_H
16 |
17 | #include
18 | #include
19 |
20 |
21 | namespace BT
22 | {
23 | class SequenceNode : public ControlNode
24 | {
25 | public:
26 | // Constructor
27 | explicit SequenceNode(std::string name);
28 | ~SequenceNode();
29 | int DrawType();
30 | BT::ReturnStatus Tick();
31 | };
32 | } // namespace BT
33 |
34 | #endif // SEQUENCE_NODE_H
35 |
--------------------------------------------------------------------------------
/behavior_tree_core/src/action_node.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5 | * 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:
6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | *
8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 | * 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,
10 | * 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.
11 | */
12 |
13 | #include
14 | #include
15 |
16 |
17 | BT::ActionNode::ActionNode(std::string name) : LeafNode::LeafNode(name)
18 | {
19 | type_ = BT::ACTION_NODE;
20 | }
21 |
22 | BT::ActionNode::~ActionNode() {}
23 |
24 |
25 | BT::ReturnStatus BT::ActionNode::Tick()
26 | {
27 | return BT::EXIT; // not used in action node.
28 | }
29 |
30 |
31 | int BT::ActionNode::DrawType()
32 | {
33 | // Lock acquistion
34 |
35 | return BT::ACTION;
36 | }
37 |
--------------------------------------------------------------------------------
/behavior_tree_core/include/decorators/negation_node.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5 | * 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:
6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | *
8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 | * 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,
10 | * 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.
11 | */
12 |
13 | #ifndef NEGATION_NODE_H
14 | #define NEGATION_NODE_H
15 |
16 | #include
17 | #include
18 |
19 | namespace BT
20 | {
21 | class NegationNode : public DecoratorNode
22 | {
23 | public:
24 | // Constructor
25 | explicit NegationNode(std::string name);
26 | ~NegationNode();
27 | BT::ReturnStatus Tick();
28 | BT::ReturnStatus convert(BT::ReturnStatus input);
29 | };
30 | } // namespace BT
31 |
32 | #endif // NEGATION_NODE_H
33 |
--------------------------------------------------------------------------------
/behavior_tree_core/include/fallback_node.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5 | * 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:
6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | *
8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 | * 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,
10 | * 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.
11 | */
12 |
13 | #ifndef FALLBACK_NODE_H
14 | #define FALLBACK_NODE_H
15 |
16 | #include
17 | #include
18 |
19 | namespace BT
20 | {
21 | class FallbackNode : public ControlNode
22 | {
23 | public:
24 | // Constructor
25 | explicit FallbackNode(std::string name);
26 | ~FallbackNode();
27 | int DrawType();
28 | BT::ReturnStatus Tick(); // The method that is going to be executed what the node is ticked
29 | };
30 | } // namespace BT
31 |
32 | #endif // FALLBACK_NODE_H
33 |
--------------------------------------------------------------------------------
/behavior_tree_core/include/decorator_node.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5 | * 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:
6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | *
8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 | * 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,
10 | * 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.
11 | */
12 |
13 | #ifndef DECORATOR_NODE_H
14 | #define DECORATOR_NODE_H
15 |
16 | #include
17 | #include
18 |
19 | namespace BT
20 | {
21 | class DecoratorNode : public ControlNode
22 | {
23 | public:
24 | // Constructor
25 | explicit DecoratorNode(std::string name);
26 | ~DecoratorNode();
27 | void AddChild(TreeNode* child);
28 | int DrawType();
29 | BT::ReturnStatus Tick(); // The method that is going to be executed what the node is ticked
30 | };
31 | } // namespace BT
32 |
33 | #endif // DECORATOR_NODE_H
34 |
--------------------------------------------------------------------------------
/behavior_tree_core/templates/condition_node_template.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright (C) (YEAR) YOUR NAME- All Rights Reserved
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5 | * 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:
6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | *
8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 | * 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,
10 | * 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.
11 | */
12 |
13 |
14 | #include
15 | #include
16 |
17 | BT::CLASSNAME::CONSTRUCTOR(std::string name) : ConditionNode::ConditionNode(name)
18 | {
19 | }
20 |
21 | BT::CLASSNAME::~CONSTRUCTOR() {}
22 |
23 | BT::ReturnStatus BT::CLASSNAME::Tick()
24 | {
25 | // Condition checking and state update
26 |
27 | if (/*CONDITION TO CHECK*/)
28 | {
29 | set_status(BT::SUCCESS);
30 | return BT::SUCCESS;
31 | }
32 | else
33 | {
34 | set_status(BT::FAILURE);
35 | return BT::FAILURE;
36 | }
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/behavior_tree_core/include/conditions/condition_test_node.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5 | * 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:
6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | *
8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 | * 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,
10 | * 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.
11 | */
12 |
13 |
14 | #ifndef CONDITIONS_CONDITION_TEST_NODE_H
15 | #define CONDITIONS_CONDITION_TEST_NODE_H
16 |
17 | #include
18 | #include
19 |
20 | namespace BT
21 | {
22 | class ConditionTestNode : public ConditionNode
23 | {
24 | public:
25 | // Constructor
26 | explicit ConditionTestNode(std::string Name);
27 | ~ConditionTestNode();
28 | void set_boolean_value(bool boolean_value);
29 |
30 | BT::ReturnStatus Tick();
31 | private:
32 | bool boolean_value_;
33 | };
34 | } // namespace BT
35 |
36 | #endif // CONDITIONS_CONDITION_TEST_NODE_H
37 |
--------------------------------------------------------------------------------
/behavior_tree_core/include/actions/action_test_node.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5 | * 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:
6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | *
8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 | * 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,
10 | * 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.
11 | */
12 |
13 |
14 | #ifndef ACTIONS_ACTION_TEST_NODE_H
15 | #define ACTIONS_ACTION_TEST_NODE_H
16 |
17 | #include
18 | #include
19 | namespace BT
20 | {
21 | class ActionTestNode : public ActionNode
22 | {
23 | public:
24 | // Constructor
25 | explicit ActionTestNode(std::string Name);
26 | ~ActionTestNode();
27 |
28 | void WaitForTick();
29 | void set_time(int time);
30 |
31 | void Halt();
32 | void set_boolean_value(bool boolean_value);
33 | private:
34 | int time_;
35 | bool boolean_value_;
36 | };
37 | } // namespace BT
38 |
39 | #endif // ACTIONS_ACTION_TEST_NODE_H
40 |
--------------------------------------------------------------------------------
/behavior_tree_core/include/fallback_node_with_memory.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5 | * 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:
6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | *
8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 | * 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,
10 | * 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.
11 | */
12 |
13 | #ifndef FALLBACK_NODE_WITH_MEMORY_H
14 | #define FALLBACK_NODE_WITH_MEMORY_H
15 |
16 | #include
17 | #include
18 |
19 | namespace BT
20 | {
21 | class FallbackNodeWithMemory : public ControlNode
22 | {
23 | public:
24 | // Constructor
25 | explicit FallbackNodeWithMemory(std::string name);
26 | FallbackNodeWithMemory(std::string name, int reset_policy);
27 | ~FallbackNodeWithMemory();
28 | int DrawType();
29 | BT::ReturnStatus Tick();
30 | void Halt();
31 | private:
32 | unsigned int current_child_idx_;
33 | unsigned int reset_policy_;
34 | };
35 | } // namespace BT
36 |
37 |
38 | #endif // FALLBACK_NODE_WITH_MEMORY_H
39 |
--------------------------------------------------------------------------------
/behavior_tree_core/include/parallel_node.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5 | * 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:
6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | *
8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 | * 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,
10 | * 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.
11 | */
12 |
13 |
14 | #ifndef PARALLEL_NODE_H
15 | #define PARALLEL_NODE_H
16 |
17 | #include
18 | #include
19 |
20 | namespace BT
21 | {
22 | class ParallelNode : public ControlNode
23 | {
24 | public:
25 | // Constructor
26 | explicit ParallelNode(std::string name, int threshold_M);
27 | ~ParallelNode();
28 | int DrawType();
29 | BT::ReturnStatus Tick();
30 | void Halt();
31 |
32 | unsigned int get_threshold_M();
33 | void set_threshold_M(unsigned int threshold_M);
34 |
35 | private:
36 | unsigned int threshold_M_;
37 | unsigned int success_childred_num_;
38 | unsigned int failure_childred_num_;
39 | };
40 | } // namespace BT
41 | #endif // PARALLEL_NODE_H
42 |
--------------------------------------------------------------------------------
/behavior_tree_core/include/sequence_node_with_memory.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5 | * 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:
6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | *
8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 | * 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,
10 | * 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.
11 | */
12 |
13 |
14 | #ifndef SEQUENCE_NODE_WITH_MEMORY_H
15 | #define SEQUENCE_NODE_WITH_MEMORY_H
16 |
17 |
18 | #include
19 | #include
20 |
21 | namespace BT
22 | {
23 | class SequenceNodeWithMemory : public ControlNode
24 | {
25 | public:
26 | // Constructor
27 | explicit SequenceNodeWithMemory(std::string name);
28 | SequenceNodeWithMemory(std::string name, int reset_policy);
29 | ~SequenceNodeWithMemory();
30 | int DrawType();
31 | // The method that is going to be executed by the thread
32 | BT::ReturnStatus Tick();
33 | void Halt();
34 | private:
35 | unsigned int current_child_idx_;
36 | unsigned int reset_policy_;
37 | };
38 | } // namespace BT
39 |
40 | #endif // SEQUENCE_NODE_WITH_MEMORY_H
41 |
--------------------------------------------------------------------------------
/behavior_tree_core/include/condition_node.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5 | * 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:
6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | *
8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 | * 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,
10 | * 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.
11 | */
12 |
13 |
14 | #ifndef CONDITION_NODE_H
15 | #define CONDITION_NODE_H
16 |
17 | #include
18 | #include
19 |
20 | namespace BT
21 | {
22 | class ConditionNode : public LeafNode
23 | {
24 | public:
25 | // Constructor
26 | explicit ConditionNode(std::string name);
27 | ~ConditionNode();
28 |
29 | // The method that is going to be executed by the thread
30 | virtual BT::ReturnStatus Tick() = 0;
31 |
32 | // The method used to interrupt the execution of the node
33 | void Halt();
34 |
35 | // Methods used to access the node state without the
36 | // conditional waiting (only mutual access)
37 | bool WriteState(ReturnStatus new_state);
38 | int DrawType();
39 | };
40 | } // namespace BT
41 |
42 | #endif // CONDITION_NODE_H
43 |
--------------------------------------------------------------------------------
/behavior_tree_core/include/action_node.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5 | * 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:
6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | *
8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 | * 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,
10 | * 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.
11 | */
12 |
13 | #ifndef ACTION_NODE_H
14 | #define ACTION_NODE_H
15 |
16 | #include
17 | #include
18 | namespace BT
19 | {
20 |
21 | class ActionNode : public LeafNode
22 | {
23 | public:
24 | // Constructor
25 | explicit ActionNode(std::string name);
26 | ~ActionNode();
27 |
28 | // The method that is going to be executed by the thread
29 | virtual void WaitForTick() = 0;
30 | BT::ReturnStatus Tick();
31 |
32 | // The method used to interrupt the execution of the node
33 | virtual void Halt() = 0;
34 |
35 | // Methods used to access the node state without the
36 | // conditional waiting (only mutual access)
37 | bool WriteState(ReturnStatus new_state);
38 | int DrawType();
39 | };
40 | } // namespace BT
41 |
42 | #endif // ACTION_NODE_H
43 |
--------------------------------------------------------------------------------
/behavior_tree_core/include/conditions/ros_condition.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5 | * 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:
6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | *
8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 | * 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,
10 | * 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.
11 | */
12 |
13 |
14 | #ifndef CONDITIONS_ROS_CONDITION_H
15 | #define CONDITIONS_ROS_CONDITION_H
16 |
17 | #include
18 | #include
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | namespace BT
25 | {
26 | class ROSCondition : public ConditionNode
27 | {
28 | protected:
29 | actionlib::SimpleActionClient action_client_;
30 | behavior_tree_core::BTResult node_result;
31 | behavior_tree_core::BTGoal goal;
32 | public:
33 | // Constructor
34 | explicit ROSCondition(std::string Name);
35 | ~ROSCondition();
36 |
37 | ReturnStatus Tick();
38 | };
39 | } // namespace BT
40 |
41 | #endif // CONDITIONS_ROS_CONDITION_H
42 |
--------------------------------------------------------------------------------
/behavior_tree_core/src/tick_engine.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5 | * 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:
6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | *
8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 | * 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,
10 | * 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.
11 | */
12 |
13 | #include
14 |
15 | TickEngine::TickEngine(int initial_value)
16 | {
17 | value_ = initial_value;
18 | }
19 |
20 | TickEngine::~TickEngine() {}
21 |
22 | void TickEngine::Wait()
23 | {
24 | // Lock acquire (need a unique lock for the condition variable usage)
25 | std::unique_lock UniqueLock(mutex_);
26 |
27 | // If the state is 0 then we have to wait for a signal
28 | if (value_ == 0)
29 | condition_variable_.wait(UniqueLock);
30 |
31 | // Once here we decrement the state
32 | value_--;
33 | }
34 |
35 | void TickEngine::Tick()
36 | {
37 | // Lock acquire
38 |
39 | std::lock_guard LockGuard(mutex_);
40 |
41 | // State increment
42 | value_++;
43 |
44 | // Notification
45 | condition_variable_.notify_all();
46 | }
47 |
--------------------------------------------------------------------------------
/behavior_tree_core/include/behavior_tree.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2015-2017 Michele Colledanchise - All Rights Reserved
2 | *
3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5 | * 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:
6 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | *
8 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 | * 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,
10 | * 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.
11 | */
12 |
13 | #ifndef BEHAVIOR_TREE_H
14 | #define BEHAVIOR_TREE_H
15 |
16 |
17 |
18 |
19 |
20 | #include
21 |
22 | #include
23 | #include
24 | #include
25 |
26 | #include
27 | #include
28 |
29 | #include
30 | #include
31 |
32 |
33 | #include
34 | #include
35 | #include
36 | #include
37 |
38 |
39 | #include
40 |
41 | #include
42 | #include