Skip to content

Commit 0c1f7db

Browse files
v0.2.0
1 parent ede70a2 commit 0c1f7db

File tree

6 files changed

+26
-26
lines changed

6 files changed

+26
-26
lines changed

omega_prime/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@
4242
"MovingObjectSubtype",
4343
"MovingObjectRole",
4444
"MapSegmentation",
45-
"MapOsiCenterlineSegmentation"
45+
"MapOsiCenterlineSegmentation",
4646
]

omega_prime/map.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,13 +457,13 @@ def map_to_centerline_mcap(self, output_mcap_path: Path = None) -> betterosi.Gro
457457
else:
458458
# Convert string to Path if needed
459459
output_mcap_path = Path(output_mcap_path)
460-
460+
461461
if output_mcap_path.is_dir():
462462
output_mcap_path = output_mcap_path / "map_to_centerline.mcap"
463463
elif not output_mcap_path.suffix == ".mcap":
464464
logging.warning(f"Output path must be a directory or .mcap file: {output_mcap_path}")
465465
return ground_truth
466-
466+
467467
with betterosi.Writer(output_mcap_path) as writer:
468468
writer.add(ground_truth, topic="ground_truth_map", log_time=0)
469469
logging.info(f"Successfully saved map with {len(osi_lanes)} lanes to {output_mcap_path}")

omega_prime/maposicenterlinesegmentation.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@
1919
logger = logging.getLogger(__name__)
2020

2121

22-
23-
24-
25-
def add_lanexy_to_graph(G : nx.Graph, lanes):
22+
def add_lanexy_to_graph(G: nx.Graph, lanes):
2623
"""
2724
Adds lane coordinates to the graph as node attributes.
2825
@@ -40,7 +37,7 @@ def add_lanexy_to_graph(G : nx.Graph, lanes):
4037
return G
4138

4239

43-
def plot_graph(G : nx.Graph, output : Path):
40+
def plot_graph(G: nx.Graph, output: Path):
4441
"""
4542
Plots the graph with lane coordinates.
4643
@@ -71,7 +68,7 @@ def _get_lane_geometry(self, lane) -> shapely.LineString:
7168
def set_trafficlight(self):
7269
trafficlight = []
7370
for lane in self.lanes:
74-
if hasattr(lane, 'trafficlight') and lane.trafficlight:
71+
if hasattr(lane, "trafficlight") and lane.trafficlight:
7572
trafficlight.append(lane.trafficlight)
7673
self.trafficlights = trafficlight
7774

@@ -90,7 +87,7 @@ def __init__(self, recording, lane_buffer=None, intersection_overlap_buffer=None
9087
self.lane_buffer = lane_buffer if lane_buffer is not None else 0.3
9188
self.intersection_overlap_buffer = intersection_overlap_buffer if intersection_overlap_buffer is not None else 1
9289
self.do_combine_intersections = True
93-
90+
9491
for tl_state in recording.traffic_light_states.values():
9592
for tl in tl_state:
9693
if tl.id.value not in self.trafficlight_ids:
@@ -108,17 +105,15 @@ def _get_lane_centerline(self, lane) -> shapely.LineString:
108105

109106
def _get_lane_successors(self, lane) -> list:
110107
"""Extract successor IDs from OSI centerline lane."""
111-
return [succ_id.lane_id if hasattr(succ_id, "lane_id") else succ_id
112-
for succ_id in lane.successor_ids]
108+
return [succ_id.lane_id if hasattr(succ_id, "lane_id") else succ_id for succ_id in lane.successor_ids]
113109

114110
def _get_lane_predecessors(self, lane) -> list:
115111
"""Extract predecessor IDs from OSI centerline lane."""
116-
return [pred_id.lane_id if hasattr(pred_id, "lane_id") else pred_id
117-
for pred_id in lane.predecessor_ids]
112+
return [pred_id.lane_id if hasattr(pred_id, "lane_id") else pred_id for pred_id in lane.predecessor_ids]
118113

119114
def _has_traffic_light(self, lane) -> bool:
120115
"""Check if OSI centerline lane has traffic light."""
121-
return hasattr(lane, 'trafficlight') and lane.trafficlight is not None
116+
return hasattr(lane, "trafficlight") and lane.trafficlight is not None
122117

123118
def _get_traffic_light(self, lane):
124119
"""Get traffic light object from OSI centerline lane."""
@@ -134,7 +129,7 @@ def _set_lane_is_approaching(self, lane, value: bool):
134129

135130
def _get_lane_on_intersection(self, lane) -> bool:
136131
"""Get the on_intersection status of OSI centerline lane."""
137-
return lane.on_intersection if hasattr(lane, 'on_intersection') else False
132+
return lane.on_intersection if hasattr(lane, "on_intersection") else False
138133

139134
def init_intersections(self):
140135
"""
@@ -523,7 +518,9 @@ def combine_intersection_on_polygon(self, intersection1, intersection2):
523518
"""
524519
if self.intersections_overlap(intersection1, intersection2):
525520
# Create a new intersection object with the lanes from both intersections
526-
combined_intersection = Intersection(intersection1.lanes + intersection2.lanes, concave_hull_ratio=self.concave_hull_ratio)
521+
combined_intersection = Intersection(
522+
intersection1.lanes + intersection2.lanes, concave_hull_ratio=self.concave_hull_ratio
523+
)
527524

528525
return combined_intersection
529526
else:
@@ -652,7 +649,11 @@ def find_isolated_connections(self):
652649
new_connections = []
653650
for component in nx.connected_components(G):
654651
if len(component) > 0:
655-
isolated_connections.append(ConnectionSegment([self.lane_dict[i] for i in component], concave_hull_ratio=self.concave_hull_ratio))
652+
isolated_connections.append(
653+
ConnectionSegment(
654+
[self.lane_dict[i] for i in component], concave_hull_ratio=self.concave_hull_ratio
655+
)
656+
)
656657
# Check if any of the lanes in the isolated connections are part of an intersection
657658
for connection in isolated_connections:
658659
pre = False
@@ -909,7 +910,7 @@ def plot(
909910
plt.savefig(output_path)
910911
plt.close()
911912

912-
def plot_intersections(self, output_plot : Path):
913+
def plot_intersections(self, output_plot: Path):
913914
"""
914915
Plots all intersections and saves them to the output path.
915916
Args:

omega_prime/mapsegment.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class MapSegmentType(Enum): # Added class for map segment from the scenario-dat
1313
RAMP_ON = "ramp_on"
1414
RAMP_OFF = "ramp_off"
1515
UNKNOWN = "unknown"
16-
17-
16+
17+
1818
class Segment(ABC):
1919
"""A class that represents a segment of the map"""
2020

@@ -52,7 +52,7 @@ def _compute_polygon_key(self):
5252

5353
def _compute_segment_polygon(self):
5454
lane_centerline = [self._get_lane_geometry(lane) for lane in self.lanes]
55-
multilinestring = shapely.MultiLineString(lane_centerline).buffer(.1)
55+
multilinestring = shapely.MultiLineString(lane_centerline).buffer(0.1)
5656
combined = shapely.unary_union(multilinestring).buffer(0.1)
5757
try:
5858
hull = shapely.concave_hull(combined, self.concave_hull_ratio)
@@ -218,4 +218,4 @@ def check_if_all_lanes_are_on_segment(self):
218218
lane_id = self._get_lane_id(lane)
219219
if lane_id not in self.lane_segment_dict or self.lane_segment_dict[lane_id].segment is None:
220220
return False
221-
return True
221+
return True

omega_prime/recording.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def from_file(
350350
"""
351351
if filepath is None and map_path is None:
352352
raise ValueError("Either `filepath` or `map_path` must be provided.")
353-
353+
354354
if filepath is not None and Path(filepath).suffix == ".parquet":
355355
r = cls.from_parquet(filepath, parse_map=parse_map, validate=validate, step_size=step_size)
356356
elif filepath is not None:
@@ -649,7 +649,6 @@ def plot_altair(
649649
return view.add_params(op_var)
650650

651651
def create_mapsegments(self):
652-
653652
if isinstance(self.map, MapOsiCenterline):
654653
self.mapsegment = MapOsiCenterlineSegmentation(self)
655654
self.mapsegment.init_intersections()

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ dependencies = [
4848
'tqdm_joblib',
4949
'filelock>=3.18.0'
5050
]
51-
version = "0.1.21"
51+
version = "0.2.0"
5252

5353
[project.urls]
5454
Homepage = "https://github.com/ika-rwth-aachen/omega-prime"

0 commit comments

Comments
 (0)