瀏覽代碼

add check idle to homing (#81)

Tuan Nguyen 3 月之前
父節點
當前提交
ce331f93c8
共有 1 個文件被更改,包括 11 次插入2 次删除
  1. 11 2
      modules/connection/connection_manager.py

+ 11 - 2
modules/connection/connection_manager.py

@@ -445,8 +445,17 @@ def home(timeout=15):
                 finally:
                     loop.close()
 
-            state.current_theta = state.current_rho = 0
-            homing_success = True
+            # Wait for device to reach idle state after homing
+            logger.info("Waiting for device to reach idle state after homing...")
+            idle_reached = check_idle()
+
+            if idle_reached:
+                state.current_theta = state.current_rho = 0
+                homing_success = True
+                logger.info("Homing completed and device is idle")
+            else:
+                logger.error("Device did not reach idle state after homing")
+
             homing_complete.set()
         except Exception as e:
             logger.error(f"Error during homing: {e}")