Skip to content

Commit bf87a58

Browse files
ready to test vision
1 parent 991ad44 commit bf87a58

File tree

5 files changed

+337
-4
lines changed

5 files changed

+337
-4
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ if [ -z "\$EXE" ]; then
341341
echo "No compatible vision executable found in \$ROOT/vision-runtime"
342342
exit 1
343343
fi
344-
exec "\$EXE" --config "\$ROOT/vision/config/runtime.json"
344+
exec "\$EXE" --config "\$ROOT/vision/config/runtime.default.json"
345345
"""
346346
}
347347
}

vision/config/runtime.default.json

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"nt": {
3+
"server": "localhost",
4+
"port": 5810,
5+
"client_name": "vision",
6+
"table_path": "FieldVision/main",
7+
"pose_base_path": "AdvantageKit/RealOutputs/Odometry",
8+
"pose_struct_key": "Robot",
9+
"connect_timeout_s": 2.0
10+
},
11+
"loop_hz": 20.0,
12+
"max_objects_per_tick": 256,
13+
"class_map_path": "yolo_classes.json",
14+
"cameras": [
15+
{
16+
"name": "cam0",
17+
"usb_index": 0,
18+
"width": 1280,
19+
"height": 720,
20+
"fps": 20.0,
21+
"hfov_deg": 95.0,
22+
"vfov_deg": 60.0,
23+
"max_range_m": 9.0,
24+
"pose_mode": "robot",
25+
"robot_pose": {
26+
"x": 0.35,
27+
"y": 0.0,
28+
"z": 1.35,
29+
"yaw_deg": 0.0,
30+
"pitch_deg": -12.0,
31+
"roll_deg": 0.0
32+
},
33+
"calibration": {
34+
"K": [
35+
[
36+
900.0,
37+
0.0,
38+
640.0
39+
],
40+
[
41+
0.0,
42+
900.0,
43+
360.0
44+
],
45+
[
46+
0.0,
47+
0.0,
48+
1.0
49+
]
50+
],
51+
"dist": [
52+
0.0,
53+
0.0,
54+
0.0,
55+
0.0,
56+
0.0
57+
]
58+
},
59+
"axis_cam_from_cv": [
60+
[
61+
0.0,
62+
0.0,
63+
1.0
64+
],
65+
[
66+
-1.0,
67+
0.0,
68+
0.0
69+
],
70+
[
71+
0.0,
72+
-1.0,
73+
0.0
74+
]
75+
],
76+
"pipeline": {
77+
"type": "yolo",
78+
"model_path": "../models/yolo.onnx",
79+
"output_format": "yolov8",
80+
"input_width": 640,
81+
"input_height": 640,
82+
"conf_threshold": 0.25,
83+
"nms_threshold": 0.45,
84+
"max_detections": 300
85+
}
86+
}
87+
]
88+
}

vision/config/runtime.example.json

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"nt": {
3+
"server": "localhost",
4+
"port": 5810,
5+
"client_name": "vision",
6+
"table_path": "FieldVision/main",
7+
"pose_base_path": "AdvantageKit/RealOutputs/Odometry",
8+
"pose_struct_key": "Robot",
9+
"connect_timeout_s": 2.0
10+
},
11+
"loop_hz": 20.0,
12+
"max_objects_per_tick": 256,
13+
"class_map_path": "yolo_classes.json",
14+
"cameras": [
15+
{
16+
"name": "cam0",
17+
"usb_index": 0,
18+
"width": 1280,
19+
"height": 720,
20+
"fps": 20.0,
21+
"hfov_deg": 95.0,
22+
"vfov_deg": 60.0,
23+
"max_range_m": 9.0,
24+
"pose_mode": "robot",
25+
"robot_pose": {
26+
"x": 0.35,
27+
"y": 0.0,
28+
"z": 1.35,
29+
"yaw_deg": 0.0,
30+
"pitch_deg": -12.0,
31+
"roll_deg": 0.0
32+
},
33+
"calibration": {
34+
"K": [
35+
[
36+
900.0,
37+
0.0,
38+
640.0
39+
],
40+
[
41+
0.0,
42+
900.0,
43+
360.0
44+
],
45+
[
46+
0.0,
47+
0.0,
48+
1.0
49+
]
50+
],
51+
"dist": [
52+
0.0,
53+
0.0,
54+
0.0,
55+
0.0,
56+
0.0
57+
]
58+
},
59+
"axis_cam_from_cv": [
60+
[
61+
0.0,
62+
0.0,
63+
1.0
64+
],
65+
[
66+
-1.0,
67+
0.0,
68+
0.0
69+
],
70+
[
71+
0.0,
72+
-1.0,
73+
0.0
74+
]
75+
],
76+
"pipeline": {
77+
"type": "yolo",
78+
"model_path": "../models/yolo.onnx",
79+
"output_format": "yolov8",
80+
"input_width": 640,
81+
"input_height": 640,
82+
"conf_threshold": 0.25,
83+
"nms_threshold": 0.45,
84+
"max_detections": 300
85+
}
86+
}
87+
]
88+
}

vision/lib/config.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,18 @@ def _read_calibration(raw: Any, width: int, height: int, hfov_deg: float, vfov_d
121121
return K, dist
122122

123123

124+
def _default_runtime_config_path() -> str:
125+
env_path = os.getenv("VISION_CONFIG")
126+
if env_path:
127+
return env_path
128+
for candidate in ("vision/config/runtime.default.json", "vision/config/runtime.json"):
129+
if Path(candidate).exists():
130+
return candidate
131+
return "vision/config/runtime.default.json"
132+
133+
124134
def load_runtime_config(path: str | None = None) -> RuntimeConfig:
125-
cfg_path = path or os.getenv("VISION_CONFIG", "vision/config/runtime.json")
135+
cfg_path = path or _default_runtime_config_path()
126136
p = Path(cfg_path).resolve()
127137
raw = json.loads(p.read_text(encoding="utf-8"))
128138
if not isinstance(raw, dict):

0 commit comments

Comments
 (0)