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

Only the integer part of the float matters in sizes! #21

Closed
gstavrinos opened this issue Jul 14, 2018 · 5 comments
Closed

Only the integer part of the float matters in sizes! #21

gstavrinos opened this issue Jul 14, 2018 · 5 comments
Labels

Comments

@gstavrinos
Copy link

gstavrinos commented Jul 14, 2018

A simple example to show this bug is the following:

`

<link name="base_link">

  <visual>

    <geometry>

      <box size="1 1 1"/>

    </geometry>

    <origin xyz="0 0 0"/>

    <material name="black"/>

  </visual>

</link>

`

The example above works like a charm. If you use the following, the y dimension is equal to 0, even though it should be 0.9:

`

<link name="base_link">

  <visual>

    <geometry>

      <box size="1 0.9 1"/>

    </geometry>

    <origin xyz="0 0 0"/>

    <material name="black"/>

  </visual>

</link>

`

Finally, with this description the box is completely invisible:

`

<link name="base_link">

  <visual>

    <geometry>

      <box size="0.3 0.9 0.2"/>

    </geometry>

    <origin xyz="0 0 0"/>

    <material name="black"/>

  </visual>

</link>`

I am using a super vanilla version of ROS Melodic.

@gstavrinos gstavrinos changed the title Sizes less than 1, are always equal to 0! Only the integer part of the float matters in sizes! Jul 14, 2018
@gstavrinos
Copy link
Author

I just realized that I am experiencing the same bug for origin values too!

@sloretz
Copy link
Contributor

sloretz commented Jul 17, 2018

Hi @gstavrinos, would you mind posting steps to reproduce? I'm unable to reproduce it.

I added this test to one of the test files.

TEST(model_parser_initxml, floating_point_values)
{
static const std::string good_robot{"<robot name=\"myrobot\">"
                                    "  <link name=\"one_link\">"
                                    "    <visual>"
                                    "      <origin xyz=\"1.2 1.3 1.4\" rpy=\"0.2 0.3 0.4\"/>"
                                    "      <geometry>"
                                    "        <box size=\"1.2 1.3 1.4\"/>"
                                    "      </geometry>"
                                    "    </visual>"
                                    "  </link>"
                                    "</robot>"};
  urdf::Model model;
  ASSERT_TRUE(model.initString(good_robot));

  auto pose = model.getLink("one_link")->visual->origin;
  EXPECT_DOUBLE_EQ(1.2, pose.position.x);
  EXPECT_DOUBLE_EQ(1.3, pose.position.y);
  EXPECT_DOUBLE_EQ(1.4, pose.position.z);

  auto * box_geometry = dynamic_cast<urdf::Box *>(model.getLink("one_link")->visual->geometry.get());

  EXPECT_DOUBLE_EQ(1.2, box_geometry->dim.x);
  EXPECT_DOUBLE_EQ(1.3, box_geometry->dim.y);
  EXPECT_DOUBLE_EQ(1.4, box_geometry->dim.z);
}

And it appears to work fine when running catkin run_tests

[ RUN      ] model_parser_initxml.floating_point_values
[       OK ] model_parser_initxml.floating_point_values (0 ms)

@mikaelarguedas
Copy link
Member

mikaelarguedas commented Jul 17, 2018

Are you using a locale that uses , instead of . for decimal points? this looks related to ros/urdfdom_headers#45

There is also a workaround at ros-visualization/rviz#1151 (comment)

@gstavrinos
Copy link
Author

I am currently in a ROS Kinetic machine, and I can't reproduce the problem. I will post a proper comment as soon as I get my hands on my ROS Melodic machine.

What I can say for now, is that the same urdf file was working on Kinetic but wasn't on Melodic. It could be a locale thingy of the OS setup. I will check that too, and get back to both of you. Thanks for your help, guys.

@gstavrinos
Copy link
Author

I confirm that the links Mike sent are related to the bug I am experiencing. The workaround is not working, but at least I know where to look for a future fix. Seems like Kinetic will have to stay for some time!

Thanks you both!

dreuter pushed a commit to dreuter/urdf that referenced this issue Jun 2, 2022
* Work around Windows min/max bug.

The comments in the code explain why we need this.

Signed-off-by: Chris Lalancette <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants