Closed tylerjw closed 2 months ago
Hello!
I admit not knowing much about yaserde
but I can reproduce in some cases, I played with the unit test and got something similar to yours to "work" by editing the visual to include an <origin>
tag. Can you give it a try?
Now that is not the solution but I wonder if yaserde
tries to deserialize the urdf
, doesn't find the origin
element even though it is currently required, and for this reason falls back to Default
. If this is the case I believe that even if your material had a name it wouldn't be parsed, so it's really about material being Material::default()
rather than a color parsing issue.
If origin
is indeed optional it could be considered to make the struct an Option
rather than a mandatory field, but that would be API breaking and require a new major release.
Might be related to #94 that is affecting the same struct.
Thanks for the report! This is another regression introduced in https://github.com/openrr/urdf-rs/pull/64. I confirmed urdf-rs 0.6 (that uses serde-xml-rs) doesn't have this problem.
@luca-della-vedova
Thanks for the investigation! Since the main branch already has a breaking change (https://github.com/openrr/urdf-rs/pull/92), there is no problem with making a new breaking change.
Now that is not the solution but I wonder if
yaserde
tries to deserialize theurdf
, doesn't find theorigin
element even though it is currently required
If this is the cause of this problem, it seems that yaserde is behaving quite badly in not treating the lack of the required element as an error.
Thank you for looking into this. I can confirm adding the required origin element fixes this behavior. I'm building a new library that depends on this so feel free to ping me to ask for help with changes here. I'm happy to test any new changes.
I wonder if we should reconsider what fields are mandatory and what are options, for example we currently set origin
, or even name
, as mandatory, i.e. here then default to the origin if this is not provided, which kinda follows the specification where it states:
<origin> (optional: defaults to identity if not specified)
This creates a bit of an issue since it is not possible, for a user, to figure out if a pose in the origin was specified or if it was just the derived default.
This creates a bit of confusion in deserialization use cases like the above, since there is a lot of empty data that is autogenerated, and is actively harmful in serialization since a round trip will add a lot of unnecessary defaults and noise to the URDF file.
Should we reconsider and make all these fields Option
instead? We can (and should) still implement Default
so users can unwrap_or_default()
the option if needed, which is a bit of API noise but technically more correct.
What do y'all think?
@tylerjw can you give a try to this branch and see if it works for you?
Tested and got it to compile with some small changes around the GeometryTag type. It seems effort
is a required argument to limit tags?
UrdfError(Other("missing field `@effort`"))
I followed the specification http://wiki.ros.org/urdf/XML/joint which says that while lower
and upper
are optional, effort and velocity are required, are there a lot of urdfs in the wild that don't have one of the two and are successfully parsed by other parsers?
I think it is likely you are correct and my test urdfs are malformed. I'll go look at the actual urdf files we have for robots to see if this is the case. The ones in my tests are copied from the C++ parser's tests in ROS.
Fixed in 0.9.0 (#98, #107).
We allowed for missing effort
, but we might actually want to consider allowing for missing velocity
as well, since all the missing effort
URDFs I have actually found seem to be missing velocity
as well.
Using this test urdf:
I parse calling your
read_from_string
function, the color value is always a None. Here is a debug output of each of the visual objects after the parse: