Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update black.yml #63

Merged
merged 6 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 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,9 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: black
uses: lgeiger/[email protected]
with:
args: .
uses: psf/black@stable
Giulero marked this conversation as resolved.
Show resolved Hide resolved
- 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
Loading