Skip to content

Commit

Permalink
Fixed check_position()
Browse files Browse the repository at this point in the history
  • Loading branch information
Juliana Mashon authored and Juliana Mashon committed Aug 9, 2024
1 parent 40e760c commit b8e294d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions broker_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,21 +309,19 @@ def get_xyz(self):
return x_val, y_val, z_val

def check_position(self, user_x, user_y, user_z, tolerance):
# Check current xyz coord = user xyz coord within tolerance
# Return in or out of tolerance range
user_values = [user_x, user_y, user_z]

position = self.get_xyz()
actual_vals = list(position)

for user_value, actual_value in zip(user_values, actual_vals):
if actual_value - tolerance <= user_value <= actual_value + tolerance:
print(f"Farmbot is at position {position}")
return True
else:
if not actual_value - tolerance <= user_value <= actual_value + tolerance:
print(f"Farmbot is NOT at position {position}")
return False

print(f"Farmbot is at position {position}")
return True

def control_peripheral(self, id, value, mode=None):
# Change peripheral values
# No inherent return value
Expand Down

0 comments on commit b8e294d

Please sign in to comment.