Skip to content

Commit 58dcc17

Browse files
committed
Apply formatting
1 parent 88bc290 commit 58dcc17

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

src/map.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use geo::{BooleanOps, Coord, LineString, MultiPolygon, Polygon};
22
use pyo3::prelude::*;
33

4-
use crate::{obstacle::{Obstacle, RoundObstacle}, planner::PathPlanner};
4+
use crate::{
5+
obstacle::{Obstacle, RoundObstacle},
6+
planner::PathPlanner,
7+
};
58

69
/// Configuration values for the ObstacleMap, these should be given by ROS parameters
710
#[pyclass(

src/planner.rs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use std::{cmp::Reverse, collections::{HashMap, HashSet}};
1+
use std::{
2+
cmp::Reverse,
3+
collections::{HashMap, HashSet},
4+
};
25

36
use geo::{Coord, Distance, Euclidean, Intersects, Line, MultiPolygon};
47
use keyed_priority_queue::{Entry, KeyedPriorityQueue};
@@ -20,7 +23,6 @@ pub struct PathPlanner {
2023

2124
const MULTIPLIER: f64 = 10.0;
2225

23-
2426
impl PathPlanner {
2527
pub fn new(map: &ObstacleMap, start: (f64, f64), goal: (f64, f64)) -> Self {
2628
let mut vertices = map.as_vertices();
@@ -76,12 +78,15 @@ impl PathPlanner {
7678

7779
fn expand_node(&mut self, vertex: usize) {
7880
let g_vertex = self
79-
.g_score
80-
.get(&vertex)
81-
.unwrap_or(&OrderedFloat(std::f64::INFINITY))
82-
.clone();
81+
.g_score
82+
.get(&vertex)
83+
.unwrap_or(&OrderedFloat(std::f64::INFINITY))
84+
.clone();
8385
for successor in self.successors.iter().cloned() {
84-
let multiplier = if self.obstacle.intersects(&Line::new(self.vertices[vertex], self.vertices[successor])) {
86+
let multiplier = if self
87+
.obstacle
88+
.intersects(&Line::new(self.vertices[vertex], self.vertices[successor]))
89+
{
8590
if self.goal == successor || self.start == vertex {
8691
OrderedFloat(MULTIPLIER)
8792
} else {
@@ -90,7 +95,11 @@ impl PathPlanner {
9095
} else {
9196
OrderedFloat(1.0)
9297
};
93-
let g_successor = self.g_score.get(&successor).unwrap_or(&OrderedFloat(std::f64::INFINITY)).clone();
98+
let g_successor = self
99+
.g_score
100+
.get(&successor)
101+
.unwrap_or(&OrderedFloat(std::f64::INFINITY))
102+
.clone();
94103
let g_tentative = g_vertex + multiplier * self.distance(vertex, successor);
95104
if g_tentative < g_successor {
96105
self.from.insert(successor, vertex);
@@ -99,10 +108,10 @@ impl PathPlanner {
99108
match self.open.entry(successor) {
100109
Entry::Occupied(entry) => {
101110
entry.set_priority(new_f_score);
102-
},
111+
}
103112
Entry::Vacant(entry) => {
104113
entry.set_priority(new_f_score);
105-
},
114+
}
106115
}
107116
}
108117
}

0 commit comments

Comments
 (0)