Skip to content
Snippets Groups Projects
Commit 54b596b7 authored by Ziqi Zhou's avatar Ziqi Zhou
Browse files

feat: support road in TimeHeadway condition

parent 33308968
No related branches found
No related tags found
1 merge request!247Draft: Feat: support road coordinate in time headway condition
...@@ -25,9 +25,11 @@ bool TimeHeadwayCondition::IsSatisfied() const ...@@ -25,9 +25,11 @@ bool TimeHeadwayCondition::IsSatisfied() const
return false; return false;
} }
if (!(values.coordinateSystem == CoordinateSystem::kEntity || values.coordinateSystem == CoordinateSystem::kLane)) if ((values.coordinateSystem != CoordinateSystem::kEntity &&
values.coordinateSystem != CoordinateSystem::kLane &&
values.coordinateSystem != CoordinateSystem::kRoad))
{ {
Logger::Error(R"(TimeHeadwayCondition: The given CoordinateSystem is not supported. Only "entity" and "lane" coordinate systems are supported for now. Returning false.)"); Logger::Error(R"(TimeHeadwayCondition: The given CoordinateSystem is not supported. Only "entity", "lane" and "road" coordinate systems are supported for now. Returning false.)");
return false; return false;
} }
...@@ -74,6 +76,24 @@ bool TimeHeadwayCondition::IsSatisfied() const ...@@ -74,6 +76,24 @@ bool TimeHeadwayCondition::IsSatisfied() const
units::math::abs(ref_entity_corners_along_lane.back().x)); units::math::abs(ref_entity_corners_along_lane.back().x));
} }
} }
else if (values.coordinateSystem == CoordinateSystem::kRoad)
{
const auto longitudinal_lane_distance =
mantle.environment->GetQueryService().GetLongitudinalRoadDistanceBetweenPositions(trigger_entity.GetPosition(),
ref_entity.GetPosition());
if (!longitudinal_lane_distance.has_value())
{
throw std::runtime_error(
"TimeHeadwayCondition: CoordinateSystem is set to \"ROAD\", but can not get the longitudinal distance "
"of the reference and the triggering entities along the Road Refenrence line. Please adjust scenario.");
}
distance = longitudinal_lane_distance.value();
if (values.freespace)
{
Logger::Error(R"(TimeHeadwayCondition: The "road" coordinate system does not support freespace. Assuming freespace is false.)");
}
}
else else
{ {
// should never happen, as pre-conditions are already checked in the beginning // should never happen, as pre-conditions are already checked in the beginning
......
...@@ -2,13 +2,16 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") ...@@ -2,13 +2,16 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
_TAG = "v12.0.0" _TAG = "v12.0.0"
_TAG_TEST = "e740a459ce5442dc7ba36ec2f266931a7a6c91b4"
# dc712b5495e1928bf63a4334e8fbd084b67f1625c8d397d010d58a550bc99783
def mantle_api(): def mantle_api():
maybe( maybe(
http_archive, http_archive,
name = "mantle_api", name = "mantle_api",
url = "https://gitlab.eclipse.org/eclipse/openpass/mantle-api/-/archive/{tag}/mantle-api-{tag}.tar.gz".format(tag = _TAG), url = "https://gitlab.eclipse.org/eclipse/openpass/mantle-api/-/archive/{tag}/mantle-api-{tag}.tar.gz".format(tag = _TAG_TEST),
sha256 = "dc712b5495e1928bf63a4334e8fbd084b67f1625c8d397d010d58a550bc99783", sha256 = "7ca4f46b468b5be91c46a847a2fb4875ee97c0feb5cac9e9a3fdaf405794a706",
strip_prefix = "mantle-api-{tag}".format(tag = _TAG), strip_prefix = "mantle-api-{tag}".format(tag = _TAG_TEST),
type = "tar.gz", type = "tar.gz",
) )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment