Skip to content

Commit 903fec5

Browse files
Juliana MashonJuliana Mashon
Juliana Mashon
authored and
Juliana Mashon
committed
Added check_position()
1 parent 8b3d149 commit 903fec5

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

broker_functions.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,23 @@ def get_xyz(self):
365365
y_val = position['y']
366366
z_val = position['z']
367367

368-
return print(f'Garden size:\n'
369-
f'\tx = {x_val:.2f}\n'
370-
f'\ty = {y_val:.2f}\n'
371-
f'\tz = {z_val:.2f}')
368+
return {'x': x_val, 'y': y_val, 'z': z_val}
372369

373370
# check_position(coordinate, tolerance) USE COORDS?
374371

372+
def check_position(self, user_x, user_y, user_z, tolerance):
373+
374+
user_values = [user_x, user_y, user_z]
375+
376+
position_data = self.get_xyz()
377+
actual_vals = [position_data['x'], position_data['y'], position_data['z']]
378+
379+
for user_value, actual_value in zip(user_values, actual_vals):
380+
if actual_value - tolerance <= user_value <= actual_value + tolerance:
381+
print("Farmbot is at position.")
382+
else:
383+
print("Farmbot is NOT at position.")
384+
375385
def move(self, x, y, z):
376386
"""Move to new x, y, z position via message broker."""
377387
def axis_overwrite(axis, value):

0 commit comments

Comments
 (0)