Skip to content

Commit 9309595

Browse files
committed
fix priority set
1 parent ba40697 commit 9309595

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

include/behaviortree_cpp_v3/decorators/DecoratorEvent.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ namespace BT {
1515
class DecoratorEvent : public DecoratorNode {
1616
public:
1717
DecoratorEvent(const std::string &name, const NodeConfiguration &config)
18-
: DecoratorNode(name, config) {}
18+
: DecoratorNode(name, config) {
19+
reset_priority();
20+
}
1921

2022
static PortsList providedPorts() {
2123
return {InputPort<int>(DECORATOR_PRIORITY_NAME), InputPort<int>(DECORATOR_INDEX_NAME)};
@@ -38,6 +40,8 @@ namespace BT {
3840
void halt() override;
3941

4042
private:
43+
void reset_priority();
44+
4145
bool m_reenter = false;
4246
bool m_initialized = false;
4347
int m_priority = 0;

src/decorators/DecoratorEvent.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,24 @@ namespace BT {
3232
if (auto prop = dynamic_cast<PropReenter *>(child())) {
3333
m_reenter = true;
3434
}
35-
Optional<int> ret = getInput<int>(DECORATOR_PRIORITY_NAME);
36-
if (ret) {
37-
m_priority = ret.value();
38-
} else {
39-
m_priority = 0;
40-
}
4135
return NodeStatus::SUCCESS;
4236
}
4337

4438
void DecoratorEvent::halt() {
39+
reset_priority();
4540
DecoratorNode::halt();
4641
}
4742

4843
void DecoratorEvent::set_priority(int prio) {
4944
m_priority = prio;
5045
}
46+
47+
void DecoratorEvent::reset_priority() {
48+
Optional<int> ret = getInput<int>(DECORATOR_PRIORITY_NAME);
49+
if (ret) {
50+
m_priority = ret.value();
51+
} else {
52+
m_priority = 0;
53+
}
54+
}
5155
}

0 commit comments

Comments
 (0)