Skip to content

Commit 78c3fa0

Browse files
Juliana MashonJuliana Mashon
authored andcommitted
All tests passing
1 parent b5b2ddd commit 78c3fa0

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

functions/information.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def read_status(self):
132132
}
133133
self.broker.publish(status_message)
134134

135-
time.sleep(5)
135+
time.sleep(15)
136136
self.broker.stop_listen()
137137

138138
status_tree = self.broker.state.last_message

functions/movements.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,6 @@ def __init__(self, state):
1919
self.broker = BrokerConnect(state)
2020
self.info = Information(state)
2121

22-
def get_xyz(self):
23-
"""Returns the current (x, y, z) coordinates of the FarmBot."""
24-
25-
tree_data = self.info.read_status()
26-
27-
x_val = tree_data["location_data"]["position"]["x"]
28-
y_val = tree_data["location_data"]["position"]["y"]
29-
z_val = tree_data["location_data"]["position"]["z"]
30-
31-
self.broker.state.print_status("get_xyz()", description=f"Current coordinate: ({x_val}, {y_val}, {z_val}).")
32-
return x_val, y_val, z_val
33-
3422
def move(self, x, y, z):
3523
"""Moves to the specified (x, y, z) coordinate."""
3624

@@ -67,10 +55,8 @@ def axis_overwrite(axis, value):
6755

6856
self.broker.publish(move_message)
6957

70-
x_val, y_val, z_val = self.get_xyz()
71-
72-
self.broker.state.print_status("move()", description=f"Moved to coordinates: ({x_val}, {y_val}, {z_val}).")
73-
return x_val, y_val, z_val
58+
self.broker.state.print_status("move()", description=f"Moved to coordinates: ({x}, {y}, {z}).")
59+
return x, y, z
7460

7561
def set_home(self, axis="all"):
7662
"""Sets the current position as the home position for a specific axis."""
@@ -116,10 +102,8 @@ def find_home(self, axis="all", speed=100):
116102
}
117103
self.broker.publish(message)
118104

119-
x_val, y_val, z_val = self.get_xyz()
120-
121-
self.broker.state.print_status("find_home()", description=f"Moved to home: ({x_val}, {y_val}, {z_val}).")
122-
return x_val, y_val, z_val
105+
self.broker.state.print_status("find_home()", description="Moved to home position.")
106+
return
123107

124108
def axis_length(self, axis="all"):
125109
"""Returns the length of a specified axis."""
@@ -137,6 +121,18 @@ def axis_length(self, axis="all"):
137121
self.broker.publish(axis_length_message)
138122
return # TODO: return axis length as values(?)
139123

124+
def get_xyz(self):
125+
"""Returns the current (x, y, z) coordinates of the FarmBot."""
126+
127+
tree_data = self.info.read_status()
128+
129+
x_val = tree_data["location_data"]["position"]["x"]
130+
y_val = tree_data["location_data"]["position"]["y"]
131+
z_val = tree_data["location_data"]["position"]["z"]
132+
133+
self.broker.state.print_status("get_xyz()", description=f"Current coordinate: ({x_val}, {y_val}, {z_val}).")
134+
return x_val, y_val, z_val
135+
140136
def check_position(self, user_x, user_y, user_z, tolerance):
141137
"""Verifies position of the FarmBot within specified tolerance range."""
142138

0 commit comments

Comments
 (0)