tuanchris 3 mesiacov pred
rodič
commit
941a4ac5c9
1 zmenil súbory, kde vykonal 14 pridanie a 10 odobranie
  1. 14 10
      modules/connection/connection_manager.py

+ 14 - 10
modules/connection/connection_manager.py

@@ -470,13 +470,15 @@ def home(timeout=60):
                     # Import pattern_manager here to avoid circular import
                     # Import pattern_manager here to avoid circular import
                     from modules.core import pattern_manager
                     from modules.core import pattern_manager
 
 
-                    # Move radial arm to perimeter (theta=0, rho=1)
-                    logger.info("Moving radial arm to perimeter (theta=0, rho=1)")
+                    # Move radial arm to perimeter
+                    # Since current_rho is already 0 from radial homing, we move from (0,0) to (0,1)
+                    logger.info("Moving radial arm to perimeter (rho: 0 -> 1)")
                     loop = asyncio.new_event_loop()
                     loop = asyncio.new_event_loop()
                     asyncio.set_event_loop(loop)
                     asyncio.set_event_loop(loop)
                     try:
                     try:
-                        # Move to perimeter and wait for completion
-                        loop.run_until_complete(pattern_manager.move_polar(0, 1.0, homing_speed))
+                        # Move radially outward to perimeter while keeping theta at 0
+                        # current_theta is 0, so this moves from (theta=0, rho=0) to (theta=0, rho=1)
+                        loop.run_until_complete(pattern_manager.move_polar(state.current_theta, 1.0, homing_speed))
 
 
                         # Wait for device to reach idle state
                         # Wait for device to reach idle state
                         idle_reached = check_idle()
                         idle_reached = check_idle()
@@ -486,26 +488,28 @@ def home(timeout=60):
                             return
                             return
 
 
                         # Wait 1 second for stabilization
                         # Wait 1 second for stabilization
+                        logger.info("Radial arm now at perimeter. Starting angular rotation...")
                         time.sleep(1)
                         time.sleep(1)
 
 
                         # Perform angular rotation until reed switch is triggered
                         # Perform angular rotation until reed switch is triggered
-                        logger.info("Rotating around perimeter to find home position (theta=6.28, rho=1)")
+                        logger.info("Rotating around perimeter to find home position (up to one full rotation)")
 
 
                         # Rotate in small increments, checking reed switch after each move
                         # Rotate in small increments, checking reed switch after each move
-                        increment = 0.2  # Angular increment in radians
+                        increment = 0.2  # Angular increment in radians (~11.5 degrees)
                         current_theta = 0
                         current_theta = 0
-                        max_theta = 6.28  # One full rotation (2*pi)
+                        max_theta = 6.28  # One full rotation (2*pi radians)
                         reed_switch_triggered = False
                         reed_switch_triggered = False
 
 
                         while current_theta < max_theta:
                         while current_theta < max_theta:
                             # Check reed switch before moving
                             # Check reed switch before moving
                             if reed_switch.is_triggered():
                             if reed_switch.is_triggered():
-                                logger.info(f"Reed switch triggered at theta={current_theta}")
+                                logger.info(f"Reed switch triggered at theta={current_theta:.2f} rad ({current_theta*57.3:.1f} deg)")
                                 reed_switch_triggered = True
                                 reed_switch_triggered = True
                                 break
                                 break
 
 
-                            # Move to next position
+                            # Move to next angular position while maintaining rho=1.0
                             current_theta += increment
                             current_theta += increment
+                            logger.debug(f"Moving to theta={current_theta:.2f} rad ({current_theta*57.3:.1f} deg), rho=1.0")
                             loop.run_until_complete(
                             loop.run_until_complete(
                                 pattern_manager.move_polar(current_theta, 1.0, homing_speed)
                                 pattern_manager.move_polar(current_theta, 1.0, homing_speed)
                             )
                             )
@@ -518,7 +522,7 @@ def home(timeout=60):
 
 
                             # Check reed switch after move completes
                             # Check reed switch after move completes
                             if reed_switch.is_triggered():
                             if reed_switch.is_triggered():
-                                logger.info(f"Reed switch triggered at theta={current_theta}")
+                                logger.info(f"Reed switch triggered at theta={current_theta:.2f} rad ({current_theta*57.3:.1f} deg)")
                                 reed_switch_triggered = True
                                 reed_switch_triggered = True
                                 break
                                 break