Skip to content

Commit

Permalink
reformatted files
Browse files Browse the repository at this point in the history
  • Loading branch information
hamza.begic committed Jan 2, 2024
1 parent 62745d9 commit 250c1a6
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 34 deletions.
2 changes: 1 addition & 1 deletion crdesigner/map_conversion/common/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def bernstein(n: int, i: int, t: float) -> float:
:return: result of the polynomial
:rtype: float
"""
return scipy.special.binom(n, i) * t**i * (1 - t) ** (n - i)
return scipy.special.binom(n, i) * t ** i * (1 - t) ** (n - i)


def bezier(points: np.ndarray, t: float) -> np.ndarray:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def lane_section_to_parametric_lanes(
inner_neighbour=inner_neighbour_id,
inner_neighbour_same_direction=inner_neighbour_same_dir,
outer_neighbour=outer_neighbour_id,
inner_linemarking=inner_linemarking
inner_linemarking=inner_linemarking,
)

# Create new lane for each width segment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,26 @@ def update_line_markings(lanelet_network: ConversionLaneletNetwork) -> Conversio
if la.adj_left is not None:
# if the adjacent left lanelet is of the same direction, copy the line marking of the right vertices
if la.adj_left_same_direction is True:
la.line_marking_left_vertices = (lanelet_network.find_lanelet_by_id(la.adj_left).
line_marking_right_vertices)
la.line_marking_left_vertices = lanelet_network.find_lanelet_by_id(
la.adj_left
).line_marking_right_vertices
else:
la.line_marking_left_vertices = (lanelet_network.find_lanelet_by_id(la.adj_left).
line_marking_left_vertices)
la.line_marking_left_vertices = lanelet_network.find_lanelet_by_id(
la.adj_left
).line_marking_left_vertices
# right vertices line marking
if la.line_marking_right_vertices is LineMarking.UNKNOWN:
# check if there exists an adjacent right lanelet
if la.adj_right is not None:
# if the adjacent right lanelet is of the same direction, copy the line marking of the left
if la.adj_right_same_direction is True:
la.line_marking_right_vertices = (lanelet_network.find_lanelet_by_id(la.adj_right).
line_marking_left_vertices)
la.line_marking_right_vertices = lanelet_network.find_lanelet_by_id(
la.adj_right
).line_marking_left_vertices
else:
la.line_marking_right_vertices = (lanelet_network.find_lanelet_by_id(la.adj_right).
line_marking_right_vertices)
la.line_marking_right_vertices = lanelet_network.find_lanelet_by_id(
la.adj_right
).line_marking_right_vertices

return lanelet_network

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
from crdesigner.map_conversion.opendrive.opendrive_conversion.plane_elements.plane import (
ParametricLane,
)

from crdesigner.map_conversion.opendrive.opendrive_parser.elements.roadLanes import RoadMark
from crdesigner.map_conversion.opendrive.opendrive_parser.elements.roadLanes import (
RoadMark,
)


def convert_line_marking(plane_line_marking: RoadMark) -> LineMarking:
Expand Down Expand Up @@ -68,7 +69,7 @@ def __init__(
inner_neighbour=None,
inner_neighbour_same_direction=True,
outer_neighbour=None,
inner_linemarking=None
inner_linemarking=None,
):
"""Initializes a ParametricLaneGroup object.
Expand All @@ -95,7 +96,7 @@ def __init__(
self.signal_references = []
if inner_linemarking is None:
inner_linemarking = RoadMark()
inner_linemarking.type = 'unknown'
inner_linemarking.type = "unknown"
self.inner_linemarking = inner_linemarking

if parametric_lanes is not None:
Expand Down Expand Up @@ -254,17 +255,31 @@ def access_map(_set: list, allow: bool, _user: str):
if vehicle_set.issubset(users):
users = set.union({"vehicle"}, set.difference(users, vehicle_set))
if self.type == "bidirectional":
lanelet = ConversionLanelet(copy.deepcopy(self), left_vertices, center_vertices, right_vertices, self.id_,
lanelet_type=self.type, line_marking_left_vertices=convert_line_marking(self.inner_linemarking),
line_marking_right_vertices=line_marking_right_vertices,
speed=self.parametric_lanes[0].speed,
user_bidirectional=users)
lanelet = ConversionLanelet(
copy.deepcopy(self),
left_vertices,
center_vertices,
right_vertices,
self.id_,
lanelet_type=self.type,
line_marking_left_vertices=convert_line_marking(self.inner_linemarking),
line_marking_right_vertices=line_marking_right_vertices,
speed=self.parametric_lanes[0].speed,
user_bidirectional=users,
)
else:
lanelet = ConversionLanelet(copy.deepcopy(self), left_vertices, center_vertices, right_vertices, self.id_,
lanelet_type=self.type, line_marking_left_vertices=convert_line_marking(self.inner_linemarking),
line_marking_right_vertices=line_marking_right_vertices,
speed=self.parametric_lanes[0].speed,
user_one_way=users)
lanelet = ConversionLanelet(
copy.deepcopy(self),
left_vertices,
center_vertices,
right_vertices,
self.id_,
lanelet_type=self.type,
line_marking_left_vertices=convert_line_marking(self.inner_linemarking),
line_marking_right_vertices=line_marking_right_vertices,
speed=self.parametric_lanes[0].speed,
user_one_way=users,
)
# Adjacent lanes
self._set_adjacent_lanes(lanelet)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ def calculate_stop_line_position(
lane_width = (
coefficients[0]
+ coefficients[1] * signal.s
+ coefficients[2] * signal.s**2
+ coefficients[3] * signal.s**3
+ coefficients[2] * signal.s ** 2
+ coefficients[3] * signal.s ** 3
)

total_width += lane_width
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def calc(
Cs = self._calc_fresnel_integral(s, kappa0, theta0, C0)

# Tangent at each point
theta = self._gamma * s**2 / 2 + kappa0 * s + theta0
theta = self._gamma * s ** 2 / 2 + kappa0 * s + theta0

return Cs.real, Cs.imag, theta, self.curvature(s, kappa0)

Expand All @@ -95,7 +95,7 @@ def _calc_fresnel_integral(self, s: float, kappa0: float, theta0: float, C0: com
Sb, Cb = special.fresnel(kappa0 / np.sqrt(np.pi * np.abs(self._gamma)))

# Euler Spiral
Cs1 = np.sqrt(np.pi / np.abs(self._gamma)) * np.exp(1j * (theta0 - kappa0**2 / 2 / self._gamma))
Cs1 = np.sqrt(np.pi / np.abs(self._gamma)) * np.exp(1j * (theta0 - kappa0 ** 2 / 2 / self._gamma))
Cs2 = np.sign(self._gamma) * (Ca - Cb) + 1j * Sa - 1j * Sb

Cs = C0 + Cs1 * Cs2
Expand Down
4 changes: 2 additions & 2 deletions crdesigner/map_conversion/sumo_map/cr2sumo/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def _filter_disallowed_vehicle_classes(self, max_curvature: float, lanelet_width

for veh_class, veh_length in self.conf.veh_params["length"].items():
# only disallow vehicles longer than car (class passenger)
if veh_length**2 > max_vehicle_length_sq and veh_length > self.conf.veh_params["length"]["passenger"]:
if veh_length ** 2 > max_vehicle_length_sq and veh_length > self.conf.veh_params["length"]["passenger"]:
disallow.append(veh_class)
# print("{} disallowed on lanelet {}, allowed max_vehicle_length={}".format(veh_class, lanelet_id,
# max_vehicle_length))
Expand Down Expand Up @@ -1956,7 +1956,7 @@ def compute_polyline_length(polyline: np.ndarray) -> float:

distance_between_points = np.diff(polyline, axis=0)
# noinspection PyTypeChecker
return np.sum(np.sqrt(np.sum(distance_between_points**2, axis=1)))
return np.sum(np.sqrt(np.sum(distance_between_points ** 2, axis=1)))

def resample_polyline_with_length_check(polyline):
length = np.linalg.norm(polyline[-1] - polyline[0])
Expand Down
2 changes: 1 addition & 1 deletion crdesigner/map_conversion/sumo_map/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def compute_max_curvature_from_polyline(polyline: np.ndarray) -> float:
y_dd = np.gradient(y_d)

# compute curvature
curvature = (x_d * y_dd - x_dd * y_d) / ((x_d**2 + y_d**2) ** (3.0 / 2.0))
curvature = (x_d * y_dd - x_dd * y_d) / ((x_d ** 2 + y_d ** 2) ** (3.0 / 2.0))

# compute maximum curvature
part_curvature = np.abs(curvature)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1507,7 +1507,7 @@ def _calculate_distance(self, start_x: float, start_y: float, end_x: float, end_
"""
dx = end_x - start_x
dy = end_y - start_y
distance = math.sqrt(dx**2 + dy**2)
distance = math.sqrt(dx ** 2 + dy ** 2)

return distance

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def update_length(self):
self.toolbox.lanelet_end_position_y.text().replace(",", ".")
)
self.toolbox.length_changed = True
self.toolbox.lanelet_length.setText(str(math.sqrt(x**2 + y**2)))
self.toolbox.lanelet_length.setText(str(math.sqrt(x ** 2 + y ** 2)))

def update_end_position(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ def update_selected_length(self):
self.toolbox.selected_lanelet_end_position_y.text().replace(",", ".")
)
self.toolbox.selected_length_changed = True
self.toolbox.selected_lanelet_length.setText(str(math.sqrt(x**2 + y**2)))
self.toolbox.selected_lanelet_length.setText(str(math.sqrt(x ** 2 + y ** 2)))

def update_selected_end_position(self):
"""
Expand Down

0 comments on commit 250c1a6

Please sign in to comment.