Skip to content

Commit

Permalink
restore path name
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlottaSartore committed Jun 10, 2024
1 parent 7ea5b26 commit 25096ab
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 10 additions & 10 deletions src/adam/model/std_factories/std_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,30 @@ def __init__(self, path: str, math: SpatialMath):
isPath = False
isUrdf = False
# Checking if it is a path or an urdf
if type(urdf_string) is not (pathlib.Path):
if os.path.exists(urdf_string):
urdf_string = pathlib.Path(urdf_string)
if type(path) is not (pathlib.Path):
if os.path.exists(path):
path = pathlib.Path(path)
isPath = True
else:
root = ET.fromstring(urdf_string)
root = ET.fromstring(path)
robot_el = None
for elem in root.iter():
if elem.tag == "robot":
xml_string = urdf_string
xml_string = path
isUrdf = True
elif urdf_string.exists():
elif path.exists():
isPath = True

if not (isPath) and not (isUrdf):
raise ValueError(
f"Invalid urdf string: {urdf_string}. It is neither a path nor a urdf string"
f"Invalid urdf string: {path}. It is neither a path nor a urdf string"
)

if isPath:
if not (urdf_string.exists()):
if not (path.exists()):
raise FileExistsError(path)
urdf_string = pathlib.Path(urdf_string)
xml_file = open(urdf_string, "r")
path = pathlib.Path(path)
xml_file = open(path, "r")
xml_string = xml_file.read()
xml_file.close()
# Read URDF, but before passing it to urdf_parser_py get rid of all sensor tags
Expand Down
20 changes: 10 additions & 10 deletions src/adam/parametric/model/parametric_factories/parametric_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,30 @@ def __init__(
isPath = False
isUrdf = False
# Checking if it is a path or an urdf
if type(urdf_string) is not (pathlib.Path):
if os.path.exists(urdf_string):
urdf_string = pathlib.Path(urdf_string)
if type(path) is not (pathlib.Path):
if os.path.exists(path):
path = pathlib.Path(path)
isPath = True
else:
root = ET.fromstring(urdf_string)
root = ET.fromstring(path)
robot_el = None
for elem in root.iter():
if elem.tag == "robot":
xml_string = urdf_string
xml_string = path
isUrdf = True
elif urdf_string.exists():
elif path.exists():
isPath = True

if not (isPath) and not (isUrdf):
raise ValueError(
f"Invalid urdf string: {urdf_string}. It is neither a path nor a urdf string"
f"Invalid urdf string: {path}. It is neither a path nor a urdf string"
)

if isPath:
if not (urdf_string.exists()):
if not (path.exists()):
raise FileExistsError(path)
urdf_string = pathlib.Path(urdf_string)
xml_file = open(urdf_string, "r")
path = pathlib.Path(path)
xml_file = open(path, "r")
xml_string = xml_file.read()
xml_file.close()
self.links_name_list = links_name_list
Expand Down

0 comments on commit 25096ab

Please sign in to comment.