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

feat: support ds

parent 9c66a924
No related branches found
No related tags found
1 merge request!257Feat: support ds in relative lane position
......@@ -125,47 +125,64 @@ mantle_api::Pose ConvertRelativeLanePosition(
const NET_ASAM_OPENSCENARIO::v1_3::IRelativeLanePosition& relative_lane_position)
{
mantle_api::Pose pose{};
if (relative_lane_position.IsSetDs())
bool has_ds = relative_lane_position.IsSetDs();
bool has_ds_lane = relative_lane_position.IsSetDsLane();
if (has_ds && has_ds_lane)
{
Logger::Error("ConvertRelativeLanePosition: \"ds\" is not implemented for RelativeLanePosition.");
Logger::Error(R"(ConvertRelativeLanePosition: "ds" and "dsLane" are mutually exclusive. Only one should be set.)");
return pose;
}
if (!relative_lane_position.IsSetDsLane())
if (!has_ds && !has_ds_lane)
{
Logger::Error("ConvertRelativeLanePosition: \"dsLane\" is not set, required for RelativeLanePosition.");
Logger::Error(R"(ConvertRelativeLanePosition: Either "ds" or "dsLane" must be set for RelativeLanePosition.)");
return pose;
}
const auto ref_entity_name = relative_lane_position.GetEntityRef()->GetNameRef();
const auto ref_entity = environment.GetEntityRepository().Get(ref_entity_name);
if (const auto ref_entity = environment.GetEntityRepository().Get(ref_entity_name))
if (!ref_entity)
{
const auto d_lane = relative_lane_position.GetDLane();
const auto ds_lane = relative_lane_position.GetDsLane();
const auto offset = relative_lane_position.GetOffset();
Logger::Error("ConvertRelativeLanePosition: Entity with name = \"" + ref_entity_name +
"\" for RelativeLanePosition does not exist. Please adjust the scenario.");
return pose;
}
const mantle_api::Pose pose_ref{environment.GetGeometryHelper()->TranslateGlobalPositionLocally(
ref_entity->GetPosition(),
ref_entity->GetOrientation(),
-ref_entity->GetProperties()->bounding_box.geometric_center),
ref_entity->GetOrientation()};
const mantle_api::Pose pose_ref{
environment.GetGeometryHelper()->TranslateGlobalPositionLocally(
ref_entity->GetPosition(),
ref_entity->GetOrientation(),
-ref_entity->GetProperties()->bounding_box.geometric_center),
ref_entity->GetOrientation()};
const auto calculated_pose = environment.GetQueryService().FindRelativeLanePoseAtDistanceFrom(
pose_ref, d_lane, units::length::meter_t(ds_lane), units::length::meter_t(offset));
if (calculated_pose.has_value())
{
pose.position = calculated_pose.value().position;
detail::FillOrientation(environment, relative_lane_position.GetOrientation(), pose.position, pose);
return pose;
}
const auto d_lane = relative_lane_position.GetDLane();
const auto offset = units::length::meter_t(relative_lane_position.GetOffset());
Logger::Error("ConvertRelativeLanePosition: Conversion from RelativeLanePosition is not possible. Please check the scenario.");
std::optional<mantle_api::Pose> calculated_pose;
if (has_ds)
{
const auto d_s = units::length::meter_t(relative_lane_position.GetDs());
calculated_pose = environment.GetQueryService().FindRelativeLanePoseAtReferenceLineOffsetFrom(
pose_ref, d_lane, d_s, offset);
}
else
{
Logger::Error("ConvertRelativeLanePosition: Entity with name = \"" + ref_entity_name + "\" for RelativeLanePosition does not exist. Please adjust the scenario.");
const auto ds_lane = units::length::meter_t(relative_lane_position.GetDsLane());
calculated_pose = environment.GetQueryService().FindRelativeLanePoseAtDistanceFrom(
pose_ref, d_lane, ds_lane, offset);
}
if (!calculated_pose.has_value())
{
Logger::Error("ConvertRelativeLanePosition: Conversion from RelativeLanePosition is not possible. Please check the scenario.");
return pose;
}
pose.position = calculated_pose->position;
detail::FillOrientation(environment, relative_lane_position.GetOrientation(), pose.position, pose);
return pose;
}
......
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
_TAG = "v21.0.0"
_TAG = "4680104fdb9f3494cbe46171ddd58de49f1216fb"
def mantle_api():
maybe(
http_archive,
name = "mantle_api",
url = "https://gitlab.eclipse.org/eclipse/openpass/mantle-api/-/archive/{tag}/mantle-api-{tag}.tar.gz".format(tag = _TAG),
sha256 = "68465d0e9d7f9c082781e33b06da24c4dbae218160899de34c5a8f1764de0eeb",
sha256 = "d71596e98db0b0c6846c79c8afe7020322075449fe8e3fac551f3f4cc5bdce41",
strip_prefix = "mantle-api-{tag}".format(tag = _TAG),
type = "tar.gz",
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment