Improve homing

This commit is contained in:
2023-01-17 12:11:36 +02:00
parent c2ee6e6d0e
commit 63f707d355

View File

@@ -69,6 +69,7 @@ class AxidrawSerial(Node):
return response return response
def go_home(self): def go_home(self):
self.wait_ready()
self.status["motion"] = "busy" self.status["motion"] = "busy"
if self.status["serial"] == "ready": if self.status["serial"] == "ready":
self.ad.moveto(0,0) self.ad.moveto(0,0)
@@ -80,6 +81,11 @@ class AxidrawSerial(Node):
def set_ready(self): def set_ready(self):
self.status["motion"] = "ready" self.status["motion"] = "ready"
def wait_ready(self):
rate = node.create_rate(2) #2Hz
while self.status["motion"] != "ready":
rate.sleep()
def move_callback(self, msg): def move_callback(self, msg):
self.set_busy() self.set_busy()
@@ -119,8 +125,8 @@ def main(args=None):
axidraw_serial = AxidrawSerial() axidraw_serial = AxidrawSerial()
rclpy.on_shutdown(axidraw_serial.go_home())
rclpy.spin(axidraw_serial) rclpy.spin(axidraw_serial)
axidraw_serial.go_home()
rclpy.shutdown() rclpy.shutdown()