Skip to content
Snippets Groups Projects
Commit d532acd2 authored by Xiao Pan's avatar Xiao Pan
Browse files

Adapt target lane-id type in the performance lane change control strategy

parent 34e6b7f8
No related merge requests found
...@@ -73,7 +73,7 @@ void LaneChangeAction::SetupControlStrategy() ...@@ -73,7 +73,7 @@ void LaneChangeAction::SetupControlStrategy()
if (const auto absolute_target_lane = lane_change_target->GetAbsoluteTargetLane()) if (const auto absolute_target_lane = lane_change_target->GetAbsoluteTargetLane())
{ {
control_strategy_->target_lane_id = std::stoul(absolute_target_lane->GetValue()); control_strategy_->target_lane_id = std::stol(absolute_target_lane->GetValue());
} }
else if (const auto relative_target_lane = lane_change_target->GetRelativeTargetLane()) else if (const auto relative_target_lane = lane_change_target->GetRelativeTargetLane())
{ {
...@@ -87,16 +87,22 @@ void LaneChangeAction::SetupControlStrategy() ...@@ -87,16 +87,22 @@ void LaneChangeAction::SetupControlStrategy()
const auto relative_pose = mantle_api::Pose{relative_entity.value().get().GetPosition(), const auto relative_pose = mantle_api::Pose{relative_entity.value().get().GetPosition(),
relative_entity.value().get().GetOrientation()}; relative_entity.value().get().GetOrientation()};
if (const auto target_lane_id = const auto target_lane_id =
environment_->GetQueryService().GetRelativeLaneId(relative_pose, relative_target_lane->GetValue())) environment_->GetQueryService().GetRelativeLaneId(relative_pose, relative_target_lane->GetValue());
{
control_strategy_->target_lane_id = target_lane_id.value(); if (!target_lane_id.has_value())
}
else
{ {
throw std::runtime_error("LaneChangeAction: Cannot find the target lane to the reference entity \"" + throw std::runtime_error("LaneChangeAction: Cannot find the target lane to the reference entity \"" +
relative_entity_name + "\". Please adjust the scenario."); relative_entity_name + "\". Please adjust the scenario.");
} }
if (target_lane_id.value() > static_cast<mantle_api::UniqueId>(std::numeric_limits<std::int64_t>::max()))
{
throw std::runtime_error("LaneChangeAction: Integer overflow detected in converting the target lane id \"" +
std::to_string(target_lane_id.value()) + "\".");
}
control_strategy_->target_lane_id = static_cast<int>(target_lane_id.value());
} }
else else
{ {
......
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