Skip to content

Commit daa43b0

Browse files
committed
fix samples
1 parent 603bda4 commit daa43b0

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

sample_nodes/crossdoor_nodes.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,13 @@ NodeStatus CrossDoor::openDoor()
3636
NodeStatus CrossDoor::pickLock()
3737
{
3838
SleepMS(500);
39-
_pick_attempts++;
4039
// succeed at 3rd attempt
41-
if (_door_locked && _pick_attempts < 3)
40+
if (_pick_attempts++ > 3)
4241
{
4342
_door_locked = false;
4443
_door_open = true;
45-
return NodeStatus::FAILURE;
4644
}
47-
return NodeStatus::SUCCESS;
45+
return _door_open ? NodeStatus::SUCCESS : NodeStatus::FAILURE;
4846
}
4947

5048
NodeStatus CrossDoor::smashDoor()
@@ -72,3 +70,10 @@ void CrossDoor::registerNodes(BT::BehaviorTreeFactory &factory)
7270
factory.registerSimpleCondition(
7371
"SmashDoor", std::bind(&CrossDoor::smashDoor, this));
7472
}
73+
74+
void CrossDoor::reset()
75+
{
76+
_door_open = false;
77+
_door_locked = true;
78+
_pick_attempts = 0;
79+
}

sample_nodes/crossdoor_nodes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ class CrossDoor
77
public:
88
void registerNodes(BT::BehaviorTreeFactory& factory);
99

10+
void reset();
11+
1012
// SUCCESS if _door_open == true
1113
BT::NodeStatus isDoorClosed();
1214

sample_nodes/movebase_node.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef MOVEBASE_BT_NODES_H
2-
#define MOVEBASE_BT_NODES_H
1+
#pragma once
32

43
#include "behaviortree_cpp/behavior_tree.h"
54

@@ -69,4 +68,3 @@ class MoveBaseAction : public BT::StatefulActionNode
6968
chr::system_clock::time_point _completion_time;
7069
};
7170

72-
#endif // MOVEBASE_BT_NODES_H

0 commit comments

Comments
 (0)