json with parameters for calibrate

This commit is contained in:
shalenikol 2023-12-01 15:09:08 +03:00
parent cb3082ca44
commit 8a1f2aa4dc
4 changed files with 40 additions and 2 deletions

View file

@ -199,6 +199,23 @@ class PoseEstimator(Node):
mesh_path = y["mesh_path"]
if "gtpose" in y:
gtpose = y["gtpose"]
elif str_param[0] == "!": # filename json
json_file = str_param[1:]
if not os.path.isfile(json_file):
self.get_logger().info("not JSon '"+ json_file +"'")
return TransitionCallbackReturn.FAILURE
str_param = Path(json_file).read_text()
try:
y = json.loads(str_param)
except json.JSONDecodeError as e:
self.get_logger().info(f"JSon error: {e}")
return TransitionCallbackReturn.FAILURE
if "mesh_path" not in y:
self.get_logger().info("JSon 'mesh_path' not set")
return TransitionCallbackReturn.FAILURE
mesh_path = y["mesh_path"]
if "gtpose" in y:
gtpose = y["gtpose"]
else:
mesh_path = str_param