Untitled
def _movement_worker(self): """Worker thread to process movement queue""" while True: try: target_bin = self.movement_queue.get() if not self.is_calibrated: self.calibrate() # Get target position in degrees target_position = self.positions[target_bin] # Calculate required movement steps, direction = self._calculate_steps(target_position) # Execute movement self._move_motor(steps, direction) # Update current position self.current_position = target_position print(f"Moved to {target_bin} at position {target_position}") # After movement is complete, rotate servo and measure fill level self.hardware.rotate_and_measure(target_bin) self.movement_queue.task_done() except Exception as e: print(f"Error in movement worker: {e}") continue
Leave a Comment