Skip to content

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

Closed

Description

@dbasa

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

Activity

  1. traversaro commented on Nov 20, 2017

    @traversaro
    Contributor

    Related urdfdom issue: ros/urdfdom#98 .

  2. clalancette commented on Nov 20, 2017

    @clalancette
    Contributor

    So I ended up looking into this a bit. @traversaro did some good investigating of the issue in gbionics/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.

  3. greimela-si commented on Feb 15, 2018

    @greimela-si

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions