Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

refactor: remove scent feedback code #88

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions client/drivers/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
"""
Expand Down
31 changes: 0 additions & 31 deletions client/drivers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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...")
Expand Down