From 96595558395847c16b8c7700ee976c071c2492c2 Mon Sep 17 00:00:00 2001 From: IDavGal Date: Tue, 13 Jun 2023 11:17:57 -0300 Subject: [PATCH] Parse mesh prefixes out before normalizing filepath --- urdf2webots/parserURDF.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/urdf2webots/parserURDF.py b/urdf2webots/parserURDF.py index e23b00f..1879dff 100644 --- a/urdf2webots/parserURDF.py +++ b/urdf2webots/parserURDF.py @@ -594,13 +594,16 @@ def getVisual(link, node, path, outputDirectory): link.visual.append(visual) elif hasElement(geometryElement, 'mesh'): meshfile = geometryElement.getElementsByTagName('mesh')[0].getAttribute('filename') - if not os.path.isabs(meshfile): - # Use the path relative to the output file - meshfile = os.path.normpath(os.path.relpath(os.path.join(path, meshfile), outputDirectory)) # hack for gazebo mesh database if meshfile.count('package'): idx0 = meshfile.find('package://') meshfile = meshfile[idx0 + len('package://'):] + elif meshfile.count('file'): + idx0 = meshfile.find('file://') + meshfile = meshfile[idx0 + len('file://'):] + if not os.path.isabs(meshfile): + # Use the path relative to the output file + meshfile = os.path.normpath(os.path.relpath(os.path.join(path, meshfile), outputDirectory)) if geometryElement.getElementsByTagName('mesh')[0].getAttribute('scale'): meshScale = geometryElement.getElementsByTagName('mesh')[0].getAttribute('scale').split() visual.scale[0] = float(meshScale[0])