From dd77155c9499e964203708596839aa0b00874dcc Mon Sep 17 00:00:00 2001 From: Romain Bazile Date: Tue, 15 Dec 2020 16:44:47 +0100 Subject: [PATCH] stepper: improve speed --- scripts/planktoscope/stepper.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/planktoscope/stepper.py b/scripts/planktoscope/stepper.py index b41514d..123afd3 100644 --- a/scripts/planktoscope/stepper.py +++ b/scripts/planktoscope/stepper.py @@ -348,7 +348,6 @@ class StepperProcess(multiprocessing.Process): def treat_command(self): command = "" - if self.actuator_client.new_message_received(): logger.info("We received a new message") last_message = self.actuator_client.msg["payload"] logger.debug(last_message) @@ -366,7 +365,6 @@ class StepperProcess(multiprocessing.Process): logger.warning( f"We did not understand the received request {command} - {last_message}" ) - return def focus(self, direction, distance, speed=focus_max_speed): """moves the focus stepper @@ -507,22 +505,26 @@ class StepperProcess(multiprocessing.Process): self.actuator_client.client.publish("status/focus", '{"status":"Ready"}') logger.success("Stepper is READY!") + delay = 0.001 while not self.stop_event.is_set(): - # check if a new message has been received + if self.actuator_client.new_message_received(): self.treat_command() if self.pump_stepper.move(): + delay = 0.0001 planktoscope.light.ready() self.actuator_client.client.publish( "status/pump", '{"status":"Done"}', ) if self.focus_stepper.move(): + delay = 0.0001 planktoscope.light.ready() self.actuator_client.client.publish( "status/focus", '{"status":"Done"}', ) - time.sleep(0.0001) + time.sleep(delay) + delay = 0.001 logger.info("Shutting down the stepper process") self.actuator_client.client.publish("status/pump", '{"status":"Dead"}') self.actuator_client.client.publish("status/focus", '{"status":"Dead"}')