Skip to content

Commit

Permalink
Fix lanes being skipped when they share an anchor
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Della Vedova <[email protected]>
  • Loading branch information
luca-della-vedova committed Jan 31, 2024
1 parent 2873565 commit d76f218
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions rmf_site_format/src/legacy/nav_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ impl NavGraph {
};

let lanes_with_anchor = {
let mut lanes_with_anchor = HashMap::new();
let mut lanes_with_anchor: HashMap<u32, Vec<u32>> = HashMap::new();
for (lane_id, lane) in &site.navigation.guided.lanes {
if !lane.graphs.includes(graph_id) {
continue;
}
for a in lane.anchors.array() {
lanes_with_anchor.insert(a, (*lane_id, lane));
let entry = lanes_with_anchor.entry(a).or_default();
entry.push(*lane_id);
}
}
lanes_with_anchor
Expand All @@ -67,12 +68,14 @@ impl NavGraph {
let mut vertices = Vec::new();
let mut lanes_to_include = HashSet::new();
for (id, anchor) in &level.anchors {
let (lane, _) = match lanes_with_anchor.get(id) {
Some(v) => v,
None => continue,
let Some(lanes) = lanes_with_anchor.get(id) else {
continue;
};

lanes_to_include.insert(*lane);
for lane in lanes.iter() {
lanes_to_include.insert(*lane);
}

anchor_to_vertex.insert(*id, vertices.len());
vertices.push(NavVertex::from_anchor(anchor, location_at_anchor.get(id)));
}
Expand Down

0 comments on commit d76f218

Please sign in to comment.