-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
172 lines (136 loc) · 4.81 KB
/
config.py
File metadata and controls
172 lines (136 loc) · 4.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
from pathlib import Path
# ==========================================================
# Project Paths
# ==========================================================
BASE_DIR = Path(__file__).resolve().parent
CORE_DIR = BASE_DIR / "core"
MODELS_DIR = BASE_DIR / "models"
DATA_DIR = BASE_DIR / "data"
SNAPSHOTS_DIR = DATA_DIR / "snapshots"
LOGS_DIR = BASE_DIR / "logs"
DECISIONS_LOG = LOGS_DIR / "decisions.csv"
EVENTS_LOG = LOGS_DIR / "events.jsonl"
SYSTEM_LOG = LOGS_DIR / "system.log"
ERROR_LOG = LOGS_DIR / "errors.log"
# ==========================================================
# Line Mode Defaults
# ==========================================================
# Options:
# igus_main = current igus chain inspection model
# charcuterie = Charcuterie Artisans prosciutto package label check
# igus_secondary = top-priority GM small size 13 igus chain check
DEFAULT_LINE_MODE = "igus_main"
# ==========================================================
# Hardware
# ==========================================================
# Raspberry Pi 5 GPIO pin numbers use BCM numbering.
# Motor 1: Conveyor
# Current swapped setup:
# Main conveyor is connected to GPIO22 / GPIO23
MOTOR1_IN1 = 22 # blue wire -> IN3
MOTOR1_IN2 = 23 # purple wire -> IN4
# Motor 2: Diverter / Sorter
# Sorter/diverter is connected to GPIO17 / GPIO27
MOTOR2_IN3 = 17 # white wire -> IN1
MOTOR2_IN4 = 27 # green wire -> IN2
# Camera
CAMERA_ENABLED = True
CAMERA_NAME = "Raspberry Pi Camera 64MP"
CAMERA_WIDTH = 1920
CAMERA_HEIGHT = 1080
# Coral AI
CORAL_ENABLED = True
# Old default paths kept for backwards compatibility.
# The new mode system uses core/line_modes.py for actual model selection.
MODEL_PATH = MODELS_DIR / "model.tflite"
LABELS_PATH = MODELS_DIR / "labels.txt"
# ==========================================================
# Old AI Decision Settings
# ==========================================================
# These are kept so older imports do not break.
# The new mode system uses per-mode labels from core/line_modes.py.
ACCEPT_LABELS = {
"correct_chain",
}
REJECT_LABELS = {
"incorrect_chain",
"scuffed_chain",
"wrong_size_chain",
}
CONFIDENCE_THRESHOLD = 0.70
UNKNOWN_ACTION = "reject"
PACKAGE_PRESENT_LABELS = {
"correct_chain",
"incorrect_chain",
"scuffed_chain",
"wrong_size_chain",
}
EMPTY_BELT_LABELS = {
"empty_view",
"empty_belt",
"no_chain",
"no_object",
"background",
}
PACKAGE_DETECTION_CONFIDENCE_THRESHOLD = 0.60
PACKAGE_SCAN_INTERVAL_SECONDS = 0.35
PACKAGE_STOP_DELAY_SECONDS = 0.25
PACKAGE_SEARCH_TIMEOUT_SECONDS = 0.0
# ==========================================================
# Easy Conveyor Timing Controls
# ==========================================================
SCAN_CONVEYOR_ADVANCE_SECONDS = 1.3
SCAN_CONVEYOR_PAUSE_SECONDS = 0.25
# ==========================================================
# Sorting Motion Timing
# ==========================================================
POST_DECISION_CONVEYOR_TO_SORTER_SECONDS = 1
PRE_DIVERTER_PAUSE_SECONDS = 0.20
DIVERTER_FIRE_SECONDS = 4
# ==========================================================
# Extra Motor Timing
# ==========================================================
DIVERTER_RETURN_SECONDS = 0.35
SORT_COOLDOWN_SECONDS = 0.25
CONVEYOR_SETTLE_SECONDS = 0.25
POST_DIVERT_CONVEYOR_DELAY_SECONDS = 0.25
CONTINUOUS_LOOP_DELAY_SECONDS = 0.10
# ==========================================================
# System Behavior
# ==========================================================
SAVE_SNAPSHOTS = True
MAX_RECENT_EVENTS = 100
MAX_RECENT_ERRORS = 50
HEARTBEAT_SECONDS = 2
# ==========================================================
# Dashboard
# ==========================================================
HOST = "0.0.0.0"
PORT = 8080
DEBUG = False
def ensure_directories() -> None:
paths = [
MODELS_DIR,
MODELS_DIR / "charcuterie",
MODELS_DIR / "igus_secondary",
DATA_DIR,
SNAPSHOTS_DIR,
LOGS_DIR,
DATA_DIR / "accepted",
DATA_DIR / "rejected",
DATA_DIR / "unknown",
DATA_DIR / "training" / "igus_main" / "empty_belt",
DATA_DIR / "training" / "igus_main" / "correct_chain",
DATA_DIR / "training" / "igus_main" / "incorrect_chain",
DATA_DIR / "training" / "igus_main" / "scuffed_chain",
DATA_DIR / "training" / "igus_main" / "wrong_size_chain",
DATA_DIR / "training" / "charcuterie" / "correct_package",
DATA_DIR / "training" / "charcuterie" / "no_label",
DATA_DIR / "training" / "charcuterie" / "empty_belt",
DATA_DIR / "training" / "igus_secondary" / "correct",
DATA_DIR / "training" / "igus_secondary" / "incorrect",
DATA_DIR / "training" / "igus_secondary" / "empty_belt",
DATA_DIR / "events",
]
for path in paths:
path.mkdir(parents=True, exist_ok=True)