Skip to content

Possible wrong comparson in traffic_simulator::pose::isInLanelet #1377

@gmajrobotec

Description

@gmajrobotec

Description
In traffic_simulator::pose::isInLanelet to compare distance_to_start_lanelet_pose and distance_to_end_lanelet_pose with tolerance operator "<" is used. This can possibly lead to wrong result when tolerance is 0 and one of the measured distances is also 0, which means pose is in lanelet (start or end of it). If this is not expected behaviour operator "<=" should be used.

To Reproduce

  1. Switch to RJD-1197/pose_module. This branch contains needed test file
  2. Add this testcase to the test_pose.cpp file.
  3. Run the test suite.
TEST_F(PoseTest, isInLanelet_end_of_previous_lanelet)
{
  const auto pose =
    traffic_simulator::helper::constructCanonicalizedLaneletPose(3002163, 0.0, 0.0, hdmap_utils);

  const auto end_lanelet_pose = traffic_simulator::helper::constructCanonicalizedLaneletPose(
    195, hdmap_utils->getLaneletLength(195), 0.0, hdmap_utils);
  const auto distance_to_end_lanelet_pose =
    longitudinalDistance(pose, end_lanelet_pose, false, false, false, hdmap_utils);

  ASSERT_TRUE(distance_to_end_lanelet_pose);
  ASSERT_TRUE(std::abs(distance_to_end_lanelet_pose.value()) == 0.0);

  EXPECT_TRUE(traffic_simulator::pose::isInLanelet(pose, 195, 0.0, hdmap_utils));
}

Expected behavior
If pose is at the start or end of lanelet function traffic_simulator::pose::isInLanelet should return true;

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions