Ver código fonte

fix: error handling; update positions in config

SG/Cellrobot 5 meses atrás
pai
commit
595fd32d5e

+ 3 - 0
playgrounds/camera_playground.py

@@ -6,11 +6,14 @@ def main():
     picam2.configure(picam2.create_preview_configuration(main={"format": "BGR888", "size": (640, 480)}))
     picam2.start()
 
+    x, y, w, h = [290, 260, 240, 170]
+
     print("Type 's' to save a still image. Type 'q' to quit.")
     while True:
         cmd = input("Command [s/q]: ").strip().lower()
         if cmd == 's':
             frame = picam2.capture_array()
+            frame = frame[y:y+h, x:x+w]
             cv2.imwrite("still_image.jpg", frame)
             print("Saved still_image.jpg")
         elif cmd == 'q':

+ 13 - 13
robot_control/config/config.yaml

@@ -1,34 +1,34 @@
 measurement_devices:
   - id: device_1
-    position: [25, 804, 68]
+    position: [1, 802, 70]
     slots:
-      - position: [10, 0, 0]
+      - position: [0, 0, 0]
         occupied: False
         slot_id: 0
-      - position: [31, 0, 0]
+      - position: [21, 0, 0]
         occupied: False
         slot_id: 1
-      - position: [52, 0, 0]
+      - position: [42, 0, 0]
         occupied: False
         slot_id: 2
-      - position: [75, 0, 0]
+      - position: [65, 0, 0]
         occupied: False
         slot_id: 3
-      - position: [98, 0, 0]
+      - position: [88, 0, 0]
         occupied: False
         slot_id: 4
-      - position: [120, 0, 0]
+      - position: [110, 0, 0]
         occupied: False
         slot_id: 5
-      - position: [142, 0, 0]
+      - position: [132, 0, 0]
         occupied: False
         slot_id: 6
-      - position: [165, 0, 0]
+      - position: [155, 0, 0]
         occupied: False
         slot_id: 7
 
 feeder:
-  robot_pos: [27.5, 621.5, 47.5]
+  robot_pos: [13, 714, 45]
   mag_pos: 
     pos_mm: 0
     rot_deg: 0
@@ -36,7 +36,7 @@ feeder:
   max_num_cells: 10
 
 defeeder:
-  robot_pos: [167.5, 630, 40]
+  robot_pos: [40, 530, 68]
   mag_pos: 
     pos_mm: 0
     rot_deg: -90
@@ -101,11 +101,11 @@ vision:
   frame_rate: 30
   exposure: 0.1
   gain: 1.0
-  bbox: [100, 100,  200, 200]  # (x, y, width, height)
+  bbox: [290, 260, 240, 170]  # (x, y, width, height)
 
 vacuum:
   min_pressure_bar: 0.13
-  max_pressure_bar: 0.6
+  max_pressure_bar: 0.4
   max_pump_time_s: 20
   gripping_threshold_bar: 0.6
   pump_watchdog_timeout_s: 30

+ 3 - 1
robot_control/src/api/grbl_handler.py

@@ -131,6 +131,8 @@ class GRBLHandler:
                 if not (await self._process_response(timeout_s)):
                     raise RuntimeError("Did not receive response from GRBL")
         except RuntimeError as e:
+            if "ALARM" in str(e):
+                raise
             logger.error(f"Failed to send G-Code commands: {str(e)}")
         finally:
             self.controller_active.clear()
@@ -258,7 +260,7 @@ class GRBLHandler:
             for code, message in alarm_messages.items():
                 if f":{code}" in line:
                     raise RuntimeError(f"Grbl ALARM {code}: {message}")
-                raise RuntimeError(f"Grbl threw ALARM: {line}")
+            raise RuntimeError(f"Grbl threw ALARM: {line}")
 
         return response_lines