Skip to content

Commit 9c41757

Browse files
committed
file moved and renamed
1 parent 2e6bcd8 commit 9c41757

24 files changed

+269
-53
lines changed

CMakeLists.txt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,27 @@ set(BT_Source
4343
src/action_node.cpp
4444
src/basic_types.cpp
4545
src/decorator_node.cpp
46-
src/decorator_negation_node.cpp
47-
src/decorator_repeat_node.cpp
48-
src/decorator_retry_node.cpp
4946
src/condition_node.cpp
5047
src/control_node.cpp
5148
src/exceptions.cpp
5249
src/leaf_node.cpp
5350
src/tick_engine.cpp
54-
src/parallel_node.cpp
55-
src/fallback_node.cpp
56-
src/sequence_node.cpp
57-
src/fallback_node_with_memory.cpp
58-
src/sequence_node_with_memory.cpp
59-
src/tree_node.cpp
51+
src/tree_node.cpp
6052
src/bt_factory.cpp
6153
src/behavior_tree.cpp
62-
6354
src/xml_parsing.cpp
6455

56+
src/decorators/negation_node.cpp
57+
src/decorators/repeat_node.cpp
58+
src/decorators/retry_node.cpp
59+
60+
src/controls/parallel_node.cpp
61+
src/controls/fallback_node.cpp
62+
src/controls/sequence_node.cpp
63+
src/controls/fallback_node_with_memory.cpp
64+
src/controls/sequence_node_with_memory.cpp
65+
66+
6567
src/loggers/bt_cout_logger.cpp
6668
src/loggers/bt_file_logger.cpp
6769
src/loggers/bt_minitrace_logger.cpp

gtest/gtest_factory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ TEST(BehaviorTreeFactory, VerifyLargeTree)
128128
ASSERT_EQ(sequence_closed->child(2)->name(), "PassThroughDoor");
129129
ASSERT_EQ(sequence_closed->child(3)->name(), "CloseDoor");
130130

131-
auto decorator = dynamic_cast<const BT::DecoratorNegationNode*>(sequence_closed->child(0));
131+
auto decorator = dynamic_cast<const BT::NegationNode*>(sequence_closed->child(0));
132132
ASSERT_TRUE(decorator != nullptr);
133133

134134
ASSERT_EQ(decorator->child()->name(), "IsDoorOpen");
@@ -178,7 +178,7 @@ TEST(BehaviorTreeFactory, Subtree)
178178
ASSERT_EQ(sequence->child(2)->name(), "PassThroughDoor");
179179
ASSERT_EQ(sequence->child(3)->name(), "CloseDoor");
180180

181-
auto decorator = dynamic_cast<const BT::DecoratorNegationNode*>(sequence->child(0));
181+
auto decorator = dynamic_cast<const BT::NegationNode*>(sequence->child(0));
182182
ASSERT_TRUE(decorator != nullptr);
183183

184184
ASSERT_EQ(decorator->child()->name(), "IsDoorLocked");

include/behavior_tree_core/behavior_tree.h

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,24 @@
1414
#ifndef BEHAVIOR_TREE_H
1515
#define BEHAVIOR_TREE_H
1616

17-
#include "behavior_tree_core/parallel_node.h"
18-
#include "behavior_tree_core/fallback_node.h"
19-
#include "behavior_tree_core/sequence_node.h"
17+
#include "behavior_tree_core/controls/parallel_node.h"
18+
#include "behavior_tree_core/controls/fallback_node.h"
19+
#include "behavior_tree_core/controls/sequence_node.h"
2020

21-
#include "behavior_tree_core/sequence_node_with_memory.h"
22-
#include "behavior_tree_core/fallback_node_with_memory.h"
21+
#include "behavior_tree_core/controls/sequence_node_with_memory.h"
22+
#include "behavior_tree_core/controls/fallback_node_with_memory.h"
2323

2424
#include "behavior_tree_core/action_node.h"
2525
#include "behavior_tree_core/condition_node.h"
2626

27-
#include "behavior_tree_core/decorator_negation_node.h"
28-
#include "behavior_tree_core/decorator_retry_node.h"
29-
#include "behavior_tree_core/decorator_repeat_node.h"
30-
#include "behavior_tree_core/decorator_subtree_node.h"
27+
#include "behavior_tree_core/decorators/negation_node.h"
28+
#include "behavior_tree_core/decorators/retry_node.h"
29+
#include "behavior_tree_core/decorators/repeat_node.h"
30+
#include "behavior_tree_core/decorators/subtree_node.h"
31+
32+
#include "behavior_tree_core/decorators/always_success_node.h"
33+
#include "behavior_tree_core/decorators/always_failure_node.h"
34+
#include "behavior_tree_core/decorators/blackboard_precondition_node.h"
3135

3236
namespace BT
3337
{
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/* Copyright (C) 2018 Davide Faconti - 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_ALWAYS_FAILURE_NODE_H
14+
#define DECORATOR_ALWAYS_FAILURE_NODE_H
15+
16+
#include "behavior_tree_core/decorator_node.h"
17+
18+
namespace BT
19+
{
20+
class AlwaysFailureNode : public DecoratorNode
21+
{
22+
public:
23+
AlwaysFailureNode(const std::string& name);
24+
25+
virtual ~AlwaysFailureNode() override = default;
26+
27+
private:
28+
virtual BT::NodeStatus tick() override;
29+
};
30+
31+
//------------ implementation ----------------------------
32+
33+
inline AlwaysFailureNode::AlwaysFailureNode(const std::string& name) :
34+
DecoratorNode(name, NodeParameters())
35+
{
36+
}
37+
38+
inline NodeStatus AlwaysFailureNode::tick()
39+
{
40+
setStatus(NodeStatus::RUNNING);
41+
42+
const NodeStatus child_state = child_node_->executeTick();
43+
44+
switch (child_state)
45+
{
46+
case NodeStatus::FAILURE:
47+
case NodeStatus::SUCCESS:
48+
{
49+
child_node_->setStatus(NodeStatus::IDLE);
50+
return NodeStatus::FAILURE;
51+
}
52+
break;
53+
54+
case NodeStatus::RUNNING:
55+
{
56+
return NodeStatus::RUNNING;
57+
}
58+
break;
59+
60+
default:
61+
{
62+
// TODO throw?
63+
}
64+
}
65+
return status();
66+
}
67+
68+
}
69+
70+
#endif
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/* Copyright (C) 2018 Davide Faconti - 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_ALWAYS_SUCCESS_NODE_H
14+
#define DECORATOR_ALWAYS_SUCCESS_NODE_H
15+
16+
#include "behavior_tree_core/decorator_node.h"
17+
18+
namespace BT
19+
{
20+
class AlwaysSuccessNode : public DecoratorNode
21+
{
22+
public:
23+
AlwaysSuccessNode(const std::string& name);
24+
25+
virtual ~AlwaysSuccessNode() override = default;
26+
27+
private:
28+
virtual BT::NodeStatus tick() override;
29+
};
30+
31+
//------------ implementation ----------------------------
32+
33+
inline AlwaysSuccessNode::AlwaysSuccessNode(const std::string& name) :
34+
DecoratorNode(name, NodeParameters())
35+
{
36+
}
37+
38+
inline NodeStatus AlwaysSuccessNode::tick()
39+
{
40+
setStatus(NodeStatus::RUNNING);
41+
42+
const NodeStatus child_state = child_node_->executeTick();
43+
44+
switch (child_state)
45+
{
46+
case NodeStatus::FAILURE:
47+
case NodeStatus::SUCCESS:
48+
{
49+
child_node_->setStatus(NodeStatus::IDLE);
50+
return NodeStatus::SUCCESS;
51+
}
52+
break;
53+
54+
case NodeStatus::RUNNING:
55+
{
56+
return NodeStatus::RUNNING;
57+
}
58+
break;
59+
60+
default:
61+
{
62+
// TODO throw?
63+
}
64+
}
65+
return status();
66+
}
67+
68+
}
69+
70+
#endif

0 commit comments

Comments
 (0)