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

Parsing floats in URDF yields wrong value depending on locale #41

Closed
dbasa opened this issue Nov 20, 2017 · 3 comments · Fixed by #42
Closed

Parsing floats in URDF yields wrong value depending on locale #41

dbasa opened this issue Nov 20, 2017 · 3 comments · Fixed by #42

Comments

@dbasa
Copy link

dbasa commented Nov 20, 2017

urdfdom_headers uses std::stod to parse floating point values like position (xyz) and rotation (rpy) from URDF files. The result of std::stod is locale dependant. So with e.g. a German locale (de_DE.UTF-8) "1.57079632679" is parsed to 1.
This is the case in urdfdom_headers/urdf_model/include/urdf_model/pose.h Line 70 (not necessarily exclusive)

In my opinion the issue described here can be linked to this error, as can be the issue described here.

This link states that "[...] using a stringstream to convert it worked perfectly fine."

If desired I can fix this issue using stringstream and create a pull request, but I have to admit I have no background knowledge in ros package building and testing procedures.

Cheers

@traversaro
Copy link
Contributor

Related urdfdom issue: ros/urdfdom#98 .

@clalancette
Copy link
Contributor

So I ended up looking into this a bit. @traversaro did some good investigating of the issue in robotology/idyntree#288 (comment), and digging down into the URDF schema, this is represented as an xs:double. Looking at the XSD document here, it says that the mantissa for a double is represented as a "decimal" number. And looking at the XSD document here, a decimal number is a "finite-length sequence of decimal digits (#x30-#x39) separated by a period as a decimal indicator". Thus, the locale should have no effect on how the document is parsed, and using str::stod is incorrect. I've prepared a patch for urdfdom_headers which switches to using the stream operator; I'll open that presently.

@greimela-si
Copy link

We also ran into this issue over at ros2/rviz when migrating the RobotModel display.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants