File tree Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -36,15 +36,13 @@ NodeStatus CrossDoor::openDoor()
36
36
NodeStatus CrossDoor::pickLock ()
37
37
{
38
38
SleepMS (500 );
39
- _pick_attempts++;
40
39
// succeed at 3rd attempt
41
- if (_door_locked && _pick_attempts < 3 )
40
+ if (_pick_attempts++ > 3 )
42
41
{
43
42
_door_locked = false ;
44
43
_door_open = true ;
45
- return NodeStatus::FAILURE;
46
44
}
47
- return NodeStatus::SUCCESS;
45
+ return _door_open ? NodeStatus::SUCCESS : NodeStatus::FAILURE ;
48
46
}
49
47
50
48
NodeStatus CrossDoor::smashDoor ()
@@ -72,3 +70,10 @@ void CrossDoor::registerNodes(BT::BehaviorTreeFactory &factory)
72
70
factory.registerSimpleCondition (
73
71
" SmashDoor" , std::bind (&CrossDoor::smashDoor, this ));
74
72
}
73
+
74
+ void CrossDoor::reset ()
75
+ {
76
+ _door_open = false ;
77
+ _door_locked = true ;
78
+ _pick_attempts = 0 ;
79
+ }
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ class CrossDoor
7
7
public:
8
8
void registerNodes (BT::BehaviorTreeFactory& factory);
9
9
10
+ void reset ();
11
+
10
12
// SUCCESS if _door_open == true
11
13
BT::NodeStatus isDoorClosed ();
12
14
Original file line number Diff line number Diff line change 1
- #ifndef MOVEBASE_BT_NODES_H
2
- #define MOVEBASE_BT_NODES_H
1
+ #pragma once
3
2
4
3
#include " behaviortree_cpp/behavior_tree.h"
5
4
@@ -69,4 +68,3 @@ class MoveBaseAction : public BT::StatefulActionNode
69
68
chr::system_clock::time_point _completion_time;
70
69
};
71
70
72
- #endif // MOVEBASE_BT_NODES_H
You can’t perform that action at this time.
0 commit comments