Closed S-Dafarra closed 7 months ago
Probably related to https://github.com/ami-iit/adam/pull/49#issuecomment-1804137575
This should work
## Ack to remove the encoding urdf, see https://github.com/icub-tech-iit/ergocub-gazebo-simulations/issues/49
robot_file_read = open(model_path, "r")
robot_urdf_string = robot_file_read.read()
robot_urdf_string = robot_urdf_string.replace("<?xml", "")
robot_urdf_string = robot_urdf_string.replace("version='1.0'", "")
robot_urdf_string = robot_urdf_string.replace("encoding='UTF-8'?>", "")
robot_file_write = open(model_path, "w")
@S-Dafarra how did you installed adam
?
@S-Dafarra how did you installed
adam
?
conda
now I switched to source installation. I noticed that in the standard case, there is this snippet https://github.com/ami-iit/adam/blob/2f18e9e737beeb00a4687a37d10a4822d0e5959b/src/adam/model/std_factories/std_model.py#L11-L23
I have added it with the following diff
index 1a46094..cbcb3ed 100644
--- a/src/adam/parametric/model/parametric_factories/parametric_model.py
+++ b/src/adam/parametric/model/parametric_factories/parametric_model.py
@@ -2,9 +2,9 @@ import pathlib
from typing import List
import urdf_parser_py.urdf
-
from adam.core.spatial_math import SpatialMath
from adam.model import ModelFactory, StdJoint, StdLink, Link, Joint
+from adam.model.std_factories.std_model import urdf_remove_sensors_tags
from adam.parametric.model import ParmetricJoint, ParametricLink
@@ -29,7 +29,22 @@ class URDFParametricModelFactory(ModelFactory):
if not path.exists():
raise FileExistsError(path)
self.links_name_list = links_name_list
- self.urdf_desc = urdf_parser_py.urdf.URDF.from_xml_file(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 ),
+ # 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_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.name = self.urdf_desc.name
self.length_multiplier = length_multiplier
self.densities = densities
and now the model is loaded correctly
Have you tried using:
xml_file = open(path, "r", encoding="utf-8")
Because using the system default implicitly can create problems on Windows.
mmm, I think the error is "hidden" from removing the sensor tag, but it is resolved because now urf_parser_py
is loading a file without the declaration.
Which version of urdf_parser_py
you are using?
Since it should be fixed https://github.com/ros/urdf_parser_py/pull/83, maybe I am biased and the issue is another one.
@S-Dafarra how did you installed
adam
?
For reference, this is my current
mamba list
Relevant PR: https://github.com/ami-iit/adam/pull/72
Since it should be fixed ros/urdf_parser_py#83, maybe I am biased and the issue is another one.
Actually the issue is still there as the fix still needs to be released.
If I try to load the model https://github.com/icub-tech-iit/ergocub-gazebo-simulations/blob/1179630a88541479df51ebb108a21865ea251302/models/stickBot/model.urdf in
KinDynComputationsParametric
I have the following issue:The normal
KinDynComputations
instead works fine.cc @CarlottaSartore