From 5dd74b7200d22036352fc59aa654a577ba896720 Mon Sep 17 00:00:00 2001 From: MaximeBouton Date: Sun, 9 Aug 2020 19:35:02 -0700 Subject: [PATCH] fix bug, correct s position when projecting on lane --- Project.toml | 4 ++-- src/feature-extraction/neighbors_features.jl | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index a69f4bf..66eec91 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "AutomotiveSimulator" uuid = "6aa42d20-6c96-11ea-1103-339224409280" repo = "https://github.com/sisl/AutomotiveSimulator.jl.git" -version = "0.1.0" +version = "0.1.1" [deps] DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" @@ -21,7 +21,7 @@ Parameters = "0.12" Reexport = "0.2" StaticArrays = "0.12" Tricks = "0.1" -julia = "1.3, 1.4" +julia = "1.3, 1.4, 1.5" [extras] AutomotiveVisualization = "0faf7fd0-6c98-11ea-1740-03605baa3b07" diff --git a/src/feature-extraction/neighbors_features.jl b/src/feature-extraction/neighbors_features.jl index b93df8b..e5df918 100644 --- a/src/feature-extraction/neighbors_features.jl +++ b/src/feature-extraction/neighbors_features.jl @@ -57,6 +57,7 @@ const VEHICLE_TARGET_POINT_CENTER = VehicleTargetPointCenter() find_neighbor(scene::Scene, roadway::Roawday, ego::Entity; kwargs...) Search through lanes and road segments to find a neighbor of `ego` in the `scene`. +Returns a `NeighborLongitudinalResult` object with the index of the neighbor in the scene and its relative distance. # Arguments @@ -81,15 +82,18 @@ function find_neighbor(scene::Scene, roadway::Roadway, ego::Entity{S,D,I}; ids_to_ignore::Union{Nothing, Set{I}} = nothing) where {S,D,I} - if lane == nothing + if lane === nothing return NeighborLongitudinalResult(nothing, max_distance) elseif get_lane(roadway, ego).tag == lane.tag tag_start = lane.tag + s_start = posf(ego.state).s else # project ego on desired lane roadproj = proj(posg(ego.state), lane, roadway) + roadind = RoadIndex(roadproj) tag_start = roadproj.tag + s_start = roadway[roadind].s end - s_base = posf(ego.state).s + targetpoint_delta(targetpoint_ego, ego) + s_base = s_start + targetpoint_delta(targetpoint_ego, ego) tag_target = tag_start best_ind = nothing