Skip to content

Commit

Permalink
Fix lines
Browse files Browse the repository at this point in the history
  • Loading branch information
fredyshox committed Jun 11, 2024
1 parent 87b2506 commit 3100d81
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions metadrive/component/lane/extension_lane.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ def width_at(self, longitudinal: float) -> float:
else:
return self.width - (longitudinal / self.length) * self.width

def get_polyline(self, interval=2, lateral=0):
ret = []
for i in np.arange(0, self.length, interval):
max_lateral = self.width_at(i) - self.width / 2
ret.append(self.position(i, min(lateral, max_lateral)))
last_lateral = self.width_at(self.length) - self.width / 2
ret.append(self.position(self.length, min(lateral, last_lateral)))
return np.array(ret)

@property
def polygon(self):
if self._polygon is not None:
Expand Down
2 changes: 1 addition & 1 deletion metadrive/component/map/pg_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def get_boundary_line_vector(self, interval):
continue
color = l.line_colors[side]
line_type = self.get_line_type(type, color)
lateral = l.width_at(0) / 2
lateral = l.width / 2
if side == 0:
lateral *= -1
ret["{}_{}".format(l.index, side)] = {
Expand Down
2 changes: 1 addition & 1 deletion metadrive/component/pgblock/create_pg_block_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def create_extension(
):
extension_end = start_position + [extension_lane_length, 0.0]
extension = ExtendingLane(
direction, start_position, extension_end, width, [PGLineType.NONE, PGLineType.NONE], forbidden, speed_limit,
direction, start_position, extension_end, width, [PGLineType.NONE, PGLineType.CONTINUOUS], forbidden, speed_limit,
priority
)
return extension
Expand Down

0 comments on commit 3100d81

Please sign in to comment.