From 185fca15a165c07696f3a931d8e4429a14c8b3f7 Mon Sep 17 00:00:00 2001 From: Mohamed Fazil Date: Wed, 10 Jul 2024 10:31:50 -0700 Subject: [PATCH 1/2] Add a try exception block on loading URDF from export folder --- prepare_specialized_urdf.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/prepare_specialized_urdf.py b/prepare_specialized_urdf.py index 71f0c35c..271eaf1e 100644 --- a/prepare_specialized_urdf.py +++ b/prepare_specialized_urdf.py @@ -2,6 +2,7 @@ import pathlib import pprint import subprocess +import sys from typing import Dict, Optional, Tuple # Third-party imports @@ -94,7 +95,11 @@ def save_urdf_file(robot, file_name): print("Loading URDF from:") print(urdf_filename) print("The specialized URDFs will be derived from this URDF.") -robot = ud.Robot.from_xml_file(urdf_filename) +try: + robot = ud.Robot.from_xml_file(urdf_filename) +except FileNotFoundError: + print(f"The URDF file was not found in path {urdf_filename}. Unable to create specialized URDFs.") + sys.exit(0) # Change any joint that should be immobile for end effector IK into a fixed joint for j in robot.joint_map.keys(): From cec8388787ccca9bed568baf85ee1ce275a0629c Mon Sep 17 00:00:00 2001 From: Mohamed Fazil Date: Wed, 10 Jul 2024 11:02:45 -0700 Subject: [PATCH 2/2] formatting fix --- prepare_specialized_urdf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/prepare_specialized_urdf.py b/prepare_specialized_urdf.py index 271eaf1e..ecb64a03 100644 --- a/prepare_specialized_urdf.py +++ b/prepare_specialized_urdf.py @@ -98,7 +98,9 @@ def save_urdf_file(robot, file_name): try: robot = ud.Robot.from_xml_file(urdf_filename) except FileNotFoundError: - print(f"The URDF file was not found in path {urdf_filename}. Unable to create specialized URDFs.") + print( + f"The URDF file was not found in path {urdf_filename}. Unable to create specialized URDFs." + ) sys.exit(0) # Change any joint that should be immobile for end effector IK into a fixed joint