Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bd27aa6

Browse files
author
Davide Faconti
committed
new nodes renamed
1 parent a0f733c commit bd27aa6

File tree

12 files changed

+65
-33
lines changed

12 files changed

+65
-33
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ list(APPEND BT_SOURCE
121121

122122
src/controls/fallback_node.cpp
123123
src/controls/parallel_node.cpp
124-
src/controls/parallel_first_node.cpp
125-
src/controls/parallel_all_node.cpp
124+
src/controls/reactive_sequence.cpp
125+
src/controls/reactive_fallback.cpp
126126
src/controls/sequence_node.cpp
127127
src/controls/sequence_star_node.cpp
128128

examples/t04_reactive_sequence.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ static const char* xml_text_reactive = R"(
3636
<root main_tree_to_execute = "MainTree" >
3737
3838
<BehaviorTree ID="MainTree">
39-
<ParallelAll name="root">
39+
<ReactiveSequence name="root">
4040
<BatteryOK/>
4141
<Sequence>
4242
<SaySomething message="mission started..." />
4343
<MoveBase goal="1;2;3"/>
4444
<SaySomething message="mission completed!" />
4545
</Sequence>
46-
</ParallelAll>
46+
</ReactiveSequence>
4747
</BehaviorTree>
4848
4949
</root>

gtest/gtest_fallback.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct SimpleFallbackTest : testing::Test
4040

4141
struct ParallelOneTest : testing::Test
4242
{
43-
BT::ParallelFirstNode root;
43+
BT::ReactiveFallback root;
4444
BT::ConditionTestNode condition_1;
4545
BT::ConditionTestNode condition_2;
4646
BT::AsyncActionTest action_1;

gtest/gtest_parallel.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ TEST_F(SimpleParallelTest, Threshold_1)
149149
ASSERT_EQ(NodeStatus::IDLE, action_2.status());
150150
ASSERT_EQ(NodeStatus::SUCCESS, state);
151151
}
152+
152153
TEST_F(ComplexParallelTest, ConditionsTrue)
153154
{
154155
BT::NodeStatus state = root.executeTick();

gtest/gtest_sequence.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct SimpleSequenceTest : testing::Test
4040

4141
struct ComplexSequenceTest : testing::Test
4242
{
43-
BT::ParallelAllNode root;
43+
BT::ReactiveSequence root;
4444
BT::AsyncActionTest action_1;
4545
BT::ConditionTestNode condition_1;
4646
BT::ConditionTestNode condition_2;

gtest/navigation_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ static const char* xml_text = R"(
1111
<BehaviorTree ID="BehaviorTree">
1212
<Fallback name="root">
1313
14-
<ParallelAll name="navigation_subtree">
14+
<ReactiveSequence name="navigation_subtree">
1515
<Inverter>
1616
<Condition ID="IsStuck"/>
1717
</Inverter>
1818
<SequenceStar name="navigate">
1919
<Action ID="ComputePathToPose"/>
2020
<Action ID="FollowPath"/>
2121
</SequenceStar>
22-
</ParallelAll>
22+
</ReactiveSequence>
2323
2424
<SequenceStar name="stuck_recovery">
2525
<Condition ID="IsStuck"/>

include/behaviortree_cpp/behavior_tree.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#define BEHAVIOR_TREE_H
1616

1717
#include "behaviortree_cpp/controls/parallel_node.h"
18-
#include "behaviortree_cpp/controls/parallel_first_node.h"
19-
#include "behaviortree_cpp/controls/parallel_all_node.h"
18+
#include "behaviortree_cpp/controls/reactive_sequence.h"
19+
#include "behaviortree_cpp/controls/reactive_fallback.h"
2020
#include "behaviortree_cpp/controls/fallback_node.h"
2121
#include "behaviortree_cpp/controls/sequence_node.h"
2222
#include "behaviortree_cpp/controls/sequence_star_node.h"

include/behaviortree_cpp/controls/parallel_first_node.h renamed to include/behaviortree_cpp/controls/reactive_fallback.h

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,41 @@
1010
* 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.
1111
*/
1212

13-
#ifndef PARALLEL_FIRST_NODE_H
14-
#define PARALLEL_FIRST_NODE_H
13+
#ifndef REACTIVE_FALLBACK_NODE_H
14+
#define REACTIVE_FALLBACK_NODE_H
1515

1616
#include "behaviortree_cpp/control_node.h"
1717

1818
namespace BT
1919
{
2020

21-
class ParallelFirstNode : public ControlNode
21+
/**
22+
* @brief The ReactiveFallback is similar to a ParallelNode.
23+
* All the children are ticked from first to last:
24+
*
25+
* - If a child returns RUNNING, continue to the next sibling.
26+
* - If a child returns FAILURE, continue to the next sibling.
27+
* - If a child returns SUCCESS, stop and return SUCCESS.
28+
*
29+
* If all the children fail, than this node returns FAILURE.
30+
*
31+
* IMPORTANT: to work properly, this node should not have more than a single
32+
* asynchronous child.
33+
*
34+
*/
35+
class ReactiveFallback : public ControlNode
2236
{
2337
public:
2438

25-
ParallelFirstNode(const std::string& name):
39+
ReactiveFallback(const std::string& name):
2640
ControlNode(name, {}){}
2741

28-
~ParallelFirstNode() = default;
42+
~ReactiveFallback() = default;
2943

3044
private:
3145

3246
virtual BT::NodeStatus tick() override;
3347
};
3448

3549
}
36-
#endif // PARALLEL_FIRST_NODE_H
50+
#endif // REACTIVE_FALLBACK_NODE_H

include/behaviortree_cpp/controls/parallel_all_node.h renamed to include/behaviortree_cpp/controls/reactive_sequence.h

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,40 @@
1010
* 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.
1111
*/
1212

13-
#ifndef PARALLEL_ALL_NODE_H
14-
#define PARALLEL_ALL_NODE_H
13+
#ifndef REACTIVE_SEQUENCE_NODE_H
14+
#define REACTIVE_SEQUENCE_NODE_H
1515

1616
#include "behaviortree_cpp/control_node.h"
1717

1818
namespace BT
1919
{
20-
21-
class ParallelAllNode : public ControlNode
20+
/**
21+
* @brief The ReactiveSequence is similar to a ParallelNode.
22+
* All the children are ticked from first to last:
23+
*
24+
* - If a child returns RUNNING, tick the next sibling.
25+
* - If a child returns SUCCESS, tick the next sibling.
26+
* - If a child returns FAILURE, stop and return FAILURE.
27+
*
28+
* If all the children return SUCCESS, this node returns SUCCESS.
29+
*
30+
* IMPORTANT: to work properly, this node should not have more than a single
31+
* asynchronous child.
32+
*
33+
*/
34+
class ReactiveSequence : public ControlNode
2235
{
2336
public:
2437

25-
ParallelAllNode(const std::string& name):
38+
ReactiveSequence(const std::string& name):
2639
ControlNode(name, {}) {}
2740

28-
~ParallelAllNode() = default;
41+
~ReactiveSequence() = default;
2942

3043
private:
3144

3245
virtual BT::NodeStatus tick() override;
3346
};
3447

3548
}
36-
#endif // PARALLEL_ALL_NODE_H
49+
#endif // REACTIVE_SEQUENCE_NODE_H

src/bt_factory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ BehaviorTreeFactory::BehaviorTreeFactory()
2222
registerNodeType<SequenceNode>("Sequence");
2323
registerNodeType<SequenceStarNode>("SequenceStar");
2424
registerNodeType<ParallelNode>("Parallel");
25-
registerNodeType<ParallelAllNode>("ParallelAll");
26-
registerNodeType<ParallelFirstNode>("ParallelFirst");
25+
registerNodeType<ReactiveSequence>("ReactiveSequence");
26+
registerNodeType<ReactiveFallback>("ReactiveFallback");
2727

2828
registerNodeType<InverterNode>("Inverter");
2929
registerNodeType<RetryNode>("RetryUntilSuccesful");

0 commit comments

Comments
 (0)