Conversation
This is already specified by the xsd, so just make sure we implement it and enforce it in the code. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
|
looks good, just one minor suggestion about the error message |
urdf_parser/src/model.cpp
Outdated
| model->name_ = std::string(name); | ||
|
|
||
| float version = -1.0; | ||
| int version_ret = robot_xml->QueryFloatAttribute("version", &version); |
There was a problem hiding this comment.
QueryFloatAttribute uses sscanf for parsing the string to a float, so I am afraid it is not locale-safe and it will not behave correctly on system with a locale that does not use . as decimal separator, see ros/urdfdom_headers#41 and #98 .
There was a problem hiding this comment.
Arg, you are right, of course. Thanks for pointing this out. But I'm going to address the bigger issue of how to store the version number from @scpeters before doing anything here.
|
I thought a little more about this, and do we want to parse to a float to store a version number? It won't be able to distinguish between 1.1 and 1.10 |
Hm, good point. It also has the system locale problems pointed out. I chose a float to store it since it would make comparisons ( |
Indeed, in the Line 321 in 06f5f9b |
|
it would be great if c++ had a primitive type for version numbers, but without that a custom version number class sounds good to me. we already have a |
|
should we add that class to urdfdom_headers or here? |
The previous attempt used a float to store the version number. That has two problems: 1. It runs into locale issues, and 2. The XSD specifies it as a string This alternative introduces a class to do parsing of the version string. Besides conforming to the XSD, and getting us away from the locale issues, it also allows us to provide additional constraints on the version (like not allowing negative numbers). The UDFVersion class ends up living in the header file so we can write tests against it. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
|
So I just pushed commit 088bf6c, which implements a class for URDF version parsing. A few things to note:
@scpeters @sloretz @traversaro Please take another look. Thanks! |
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
|
the |
Right. I didn't implement them since there are no callers to them, and I don't like adding code that isn't currently used. I just figured we would implement them as we needed them. Alternatively, I guess I could add them in and just write tests for them. What do you think? |
|
if the plan is to add them in the future when we have multiple versions, I guess that's fine |
| } | ||
|
|
||
| // We accept any of the following strings: | ||
| // 1 |
There was a problem hiding this comment.
Is this comment correct? It looks like the code below will throw runtime_error if the version is 1.
There was a problem hiding this comment.
Oops, that's an outdated comment. I can open a PR to fix that.
|
This pull request has been mentioned on ROS Discourse. There might be relevant details there: |
|
This pull request has been mentioned on ROS Discourse. There might be relevant details there: https://discourse.ros.org/t/proposal-to-extend-jointlimits-in-urdf/42831/2 |
This is already specified by the xsd, so just make sure we
implement it and enforce it in the code.
Signed-off-by: Chris Lalancette clalancette@openrobotics.org
@sloretz @scpeters FYI