From 1b5d9d71080875bef26d0f31e69ba5c51990fa71 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Wed, 7 Apr 2021 15:06:47 -0700 Subject: [PATCH] Remove _broken_path_v2_to_v1 for now. #555 --- map_model/src/pathfind/v2.rs | 81 ------------------------------------ 1 file changed, 81 deletions(-) diff --git a/map_model/src/pathfind/v2.rs b/map_model/src/pathfind/v2.rs index 8ef3ab25fb..6b81e35e0a 100644 --- a/map_model/src/pathfind/v2.rs +++ b/map_model/src/pathfind/v2.rs @@ -124,84 +124,3 @@ fn find_uber_turns( assert_eq!(num_uts, result.len()); result } - -// TODO This is an attempt that looks at windows of 2 roads at a time to pick particular lanes and -// turns. It doesn't work in most cases with multiple lane choices -- I think we need at least a -// window of 3 roads. I'll write that function in the future, for the simulation layer to use -// "lazily". -fn _broken_path_v2_to_v1( - req: PathRequest, - mut road_steps: Vec, - map: &Map, -) -> Result { - let mut path_steps = Vec::new(); - - // Pick the starting lane. - { - let lanes = road_steps.remove(0).lanes(req.constraints, map); - // TODO During the transition, try to use the original requested start lane. Relax this - // later to produce more realistic paths! - if !lanes.contains(&req.start.lane()) { - bail!( - "path_v2_to_v1 found a case where we can't start at the requested lane: {}", - req - ); - } - path_steps.push(PathStep::Lane(req.start.lane())); - } - let last_road = map.get_l(req.end.lane()).get_directed_parent(); - - for road in road_steps { - let prev_lane = if let Some(PathStep::Lane(l)) = path_steps.last() { - *l - } else { - unreachable!() - }; - - let mut current_lanes = road.lanes(req.constraints, map); - // Filter current_lanes based on available turns. - let parent = map.get_l(prev_lane).dst_i; - current_lanes.retain(|dst| { - map.maybe_get_t(TurnID { - parent, - src: prev_lane, - dst: *dst, - }) - .is_some() - }); - if current_lanes.is_empty() { - error!("Lookahead failed. Req: {}", req); - error!("Path so far:"); - for x in &path_steps { - error!("- {:?}", x); - } - - bail!( - "path_v2_to_v1 found a case where lookahead failed at {}: {}", - parent, - req - ); - } - if road == last_road { - current_lanes.retain(|l| *l == req.end.lane()); - } - - // TODO We could include the old lane-changing penalties here, but I'm not sure it's worth - // the complication. The simulation layer will end up tuning those anyway. - let next_lane = current_lanes[0]; - path_steps.push(PathStep::Turn(TurnID { - parent, - src: prev_lane, - dst: next_lane, - })); - path_steps.push(PathStep::Lane(next_lane)); - } - - // Sanity check we end in the right place. - assert_eq!( - Some(PathStep::Lane(req.end.lane())), - path_steps.last().cloned() - ); - // TODO No uber-turns yet! - Ok(Path::new(map, path_steps, req, Vec::new())) -}