From b56f9d2323ffbddde750e6a33bf646e4f58cef14 Mon Sep 17 00:00:00 2001 From: zeborg Date: Sun, 31 Jan 2021 23:20:10 +0530 Subject: [PATCH 1/2] Added gate_traversal_state.py --- .../states/gate_traversal_state.py | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 path_planning/src/path_planning/states/gate_traversal_state.py diff --git a/path_planning/src/path_planning/states/gate_traversal_state.py b/path_planning/src/path_planning/states/gate_traversal_state.py new file mode 100644 index 00000000..95daf1e7 --- /dev/null +++ b/path_planning/src/path_planning/states/gate_traversal_state.py @@ -0,0 +1,52 @@ +class GateTraversalState(BaseState): + """ + Each state should define how it interacts with the depth and orientation control systems, because those are + persisted across state changes. + """ + def state_name(self): + return "gate_traversal_state" + + def initialize(self, t, controls, sub_state, world_state, sensors): + """ + Set up anything that needs initializing + Run EACH time the state is chosen as the next state + process(...) will be called with the next available data + Note the parameters passed into function may be the same as the ones first passed into process. + """ + pass + + def process(self, t, controls, sub_state, world_state, sensors): + """ + This function will be called at a regular rate. + When the state has finished and wants to finalize, it should just ensure that has_completed returns True. + Do not manually call finalize, or else it will be called twice! + """ + pass + + def finalize(self, t, controls, sub_state, world_state, sensors): + """ + Clean up anything necessary. + Note the parameters passed into function may be the same as the last ones passed into process. + Note this may be called before the state has completed. If this occurs, + the state should clean up any resources like normal; the exit_code in this case is not important. + """ + pass + + def has_completed(self): + """ + When this function returns True, the state should exit. + Control may be passed to another state if this is part of a state machine. + The reason for exiting should be documented and returned in the exit_code function. + """ + pass + + def exit_code(self): + """ + This function should only be called once has_completed returns True. + Indicates the reason that the state has exited. + The code 0 signifies that the state completed its objective and exited successfully. + The code -1 signifies that ros was shutdown. + Other codes should be numbered 1 and higher, and their explanations should be documented. + """ + return 0 + From cee0ae76bbf5a8900fcf33ad3993877eb71f642f Mon Sep 17 00:00:00 2001 From: zeborg Date: Sun, 31 Jan 2021 23:23:42 +0530 Subject: [PATCH 2/2] Fixed missing base import in gate_traversal_state.py --- path_planning/src/path_planning/states/gate_traversal_state.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/path_planning/src/path_planning/states/gate_traversal_state.py b/path_planning/src/path_planning/states/gate_traversal_state.py index 95daf1e7..5c844876 100644 --- a/path_planning/src/path_planning/states/gate_traversal_state.py +++ b/path_planning/src/path_planning/states/gate_traversal_state.py @@ -1,3 +1,5 @@ +from path_planning.states.base_state import BaseState + class GateTraversalState(BaseState): """ Each state should define how it interacts with the depth and orientation control systems, because those are