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()
3636NodeStatus 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
5048NodeStatus 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+ }
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ class CrossDoor
77public:
88 void registerNodes (BT::BehaviorTreeFactory& factory);
99
10+ void reset ();
11+
1012 // SUCCESS if _door_open == true
1113 BT::NodeStatus isDoorClosed ();
1214
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
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
You can’t perform that action at this time.
0 commit comments