Skip to content

Commit

Permalink
Align with black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Giulero committed Jan 12, 2024
1 parent 8c26f1e commit 349fbc6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/adam/model/std_factories/std_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
from adam.core.spatial_math import SpatialMath
from adam.model import ModelFactory, StdJoint, StdLink


def urdf_remove_sensors_tags(xml_string):
# Parse the XML string
root = ET.fromstring(xml_string)

# Find and remove all tags named "sensor" that are child of
# Find and remove all tags named "sensor" that are child of
# root node (i.e. robot)
for sensors_tag in root.findall("sensor"):
root.remove(sensors_tag)
Expand All @@ -21,6 +22,7 @@ def urdf_remove_sensors_tags(xml_string):

return modified_xml_string


class URDFModelFactory(ModelFactory):
"""This factory generates robot elements from urdf_parser_py
Expand All @@ -36,17 +38,19 @@ def __init__(self, path: str, math: SpatialMath):
raise FileExistsError(path)

# Read URDF, but before passing it to urdf_parser_py get rid of all sensor tags
# sensor tags are valid elements of URDF (see ),
# sensor tags are valid elements of URDF (see ),
# but they are ignored by urdf_parser_py, that complains every time it sees one.
# As there is nothing to be fixed in the used models, and it is not useful
# to have a useless and noisy warning, let's remove before hands all the sensor elements,
# that anyhow are not parser by urdf_parser_py or adam
# See https://github.com/ami-iit/ADAM/issues/59
xml_file = open(path, 'r')
xml_file = open(path, "r")
xml_string = xml_file.read()
xml_file.close()
xml_string_without_sensors_tags = urdf_remove_sensors_tags(xml_string)
self.urdf_desc = urdf_parser_py.urdf.URDF.from_xml_string(xml_string_without_sensors_tags)
self.urdf_desc = urdf_parser_py.urdf.URDF.from_xml_string(
xml_string_without_sensors_tags
)
self.name = self.urdf_desc.name

def get_joints(self) -> List[StdJoint]:
Expand Down

0 comments on commit 349fbc6

Please sign in to comment.