This commit is contained in:
cheng
2026-07-03 09:44:59 +08:00
commit 15088f9810
33 changed files with 3466 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
import copy
import json
import os
import tempfile
DEFAULT_ROTATION1 = {
"rotation_angle": 90,
"flip_x": True,
"flip_y": False,
}
DEFAULT_ROTATION2 = {
"rotation_angle": 90,
"flip_x": False,
"flip_y": False,
}
def normalize_rotation_config(value, default_config):
if value is None:
return copy.deepcopy(default_config)
if isinstance(value, dict):
return copy.deepcopy(value)
if isinstance(value, str):
text = value.strip()
if not text or text.lower() == "default":
return copy.deepcopy(default_config)
if text.startswith("{"):
return json.loads(text)
return value
def write_temp_rotation_config(config, label):
path = os.path.join(tempfile.gettempdir(), f"gripper_{label}_rotation.json")
with open(path, "w", encoding="utf-8") as f:
json.dump(config, f, ensure_ascii=False, indent=2)
return path