From c40cad25abc5f2a61ffa4d07b31218409384946e Mon Sep 17 00:00:00 2001 From: Limao Chang <80520563+LimaoC@users.noreply.github.com> Date: Thu, 10 Oct 2024 22:28:57 +1000 Subject: [PATCH] refactor: remove scent feedback code --- client/drivers/data_structures.py | 29 ----------------------------- client/drivers/main.py | 31 ------------------------------- 2 files changed, 60 deletions(-) diff --git a/client/drivers/data_structures.py b/client/drivers/data_structures.py index 69628de..ab0f116 100644 --- a/client/drivers/data_structures.py +++ b/client/drivers/data_structures.py @@ -47,8 +47,6 @@ class ControlledData: _last_snapshot_time: datetime _last_cushion_time: datetime _last_plant_time: datetime - """Time of the last successful scent feedback event.""" - _last_sniff_time: datetime # SECTION: Constructors @@ -62,7 +60,6 @@ def __init__(self): self._last_snapshot_time = datetime.now() self._last_cushion_time = datetime.now() self._last_plant_time = datetime.now() - self._last_sniff_time = datetime.now() self._DEBUG_current_graph_list_index = 0 self._DEBUG_current_graph_function = lambda x: 30 * ( 1 + sin(2 * pi * x / WIDTH) @@ -83,7 +80,6 @@ def make_empty(cls, user_id: int) -> "ControlledData": return_me._last_snapshot_time = datetime.now() return_me._last_cushion_time = datetime.now() return_me._last_plant_time = datetime.now() - return_me._last_sniff_time = datetime.now() print(" Made a new empty ControlledData() with user_id", return_me._user_id) return return_me @@ -99,7 +95,6 @@ def make_failed(cls) -> "ControlledData": return_me._last_snapshot_time = datetime.now() return_me._last_cushion_time = datetime.now() return_me._last_plant_time = datetime.now() - return_me._last_sniff_time = datetime.now() return return_me # SECTION: Getters/Setters @@ -173,19 +168,6 @@ def set_last_plant_time(self, time: datetime) -> None: """ self._last_plant_time = time - def get_last_sniff_time(self) -> datetime: - """ - Returns the last time that the user was provided olfactory feedback. - """ - return self._last_cushion_time - - def set_last_sniff_time(self, time: datetime) -> None: - """ - Args: - time: the last time that the user was provided olfactory feedback. - """ - self._last_sniff_time = time - def accept_new_posture_data( self, posture_data: List[float] ) -> None: # TODO: Refine type signature @@ -225,17 +207,6 @@ def get_plant_posture_data( print(" WARNING: get_plant_posture_data() not implemented!") return None - def get_sniff_posture_data( - self, - ) -> "SNIFF_POSTURE_DATA": # TODO: Decide what this type looks like - """ - Returns posture data necessary for scent feedback. - - TODO: Implement this. - """ - print(" WARNING: get_sniff_posture_data() not implemented!") - return None - class HardwareComponents: """ diff --git a/client/drivers/main.py b/client/drivers/main.py index fc14433..024497b 100644 --- a/client/drivers/main.py +++ b/client/drivers/main.py @@ -66,10 +66,6 @@ #: FIXME: Fine-tune this value later. PLANT_PROPORTION_GOOD_THRESHOLD = 0.5 -# KILLME: -#: Minimum delay between consecutive uses of the scent bottle-controlling servos. Used in handle_feedback(). -HANDLE_SNIFF_FEEDBACK_TIMEOUT = timedelta(milliseconds=20000) - #: DEBUG Number of milliseconds between each loop iteration in do_everything(). DEBUG_DO_EVERYTHING_INTERVAL = 1000 @@ -388,9 +384,6 @@ def handle_feedback(auspost: ControlledData) -> bool: if datetime.now() > auspost.get_last_plant_time() + HANDLE_PLANT_FEEDBACK_TIMEOUT: if not handle_plant_feedback(auspost): return False - if datetime.now() > auspost.get_last_sniff_time() + HANDLE_SNIFF_FEEDBACK_TIMEOUT: - if not handle_sniff_feedback(auspost): - return False return True @@ -518,30 +511,6 @@ def handle_plant_feedback(auspost: ControlledData) -> bool: return True -def handle_sniff_feedback(auspost: ControlledData) -> bool: - """ - Dispense olfactory reward (if necessary), and update the timestamp of when olfactory - feedback was last given. - - Args: - auspost: Data encapsulating the current state of the program. - - Returns: - True, always. If you get a False return value, then something has gone VERY wrong. - - Requires: - ! auspost.is_failed() - - Ensures: - ! auspost.is_failed() - """ - # DEBUG: - print(" handle_sniff_feedback()") - # :DEBUG - auspost.set_last_sniff_time(datetime.now()) - return True - - def _reset_garden() -> None: """Reset data, faces and hardware.""" print(" Burning the garden to the ground...")