Skip to content

Commit

Permalink
Merge pull request #63 from ami-iit/Giulero-patch-1
Browse files Browse the repository at this point in the history
Update black.yml
  • Loading branch information
Giulero authored Jan 12, 2024
2 parents 4f36ed4 + 29c985c commit 68c1e80
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Black action

on:
pull_request:
push:
branches:
- main
Expand All @@ -9,11 +10,11 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: black
uses: lgeiger/black[email protected]
uses: psf/black@stable
with:
args: .
options: "--check --verbose"
- name: Check for modified files
id: git-check
run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)
Expand Down
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 68c1e80

Please sign in to comment.