fix generic reference to np.random to internal class rng

This commit is contained in:
Pim Nelissen
2026-01-30 19:51:48 +01:00
parent ddb962569c
commit 39625e4166

View File

@ -39,9 +39,6 @@ class SegmentedRoadGenerator(BaseRoadGenerator):
Args:
segments (list[str]): List of segments.
length (int): Total length of the path in meters.
velocity (float): Velocity of the car in km/h.
ds (float, optional): Step size. Defaults to 1.0.
alpha (float, optional): Dirichlet concentration parameter. A higher value leads to more uniform apportionment of the length amongst the segments, while a lower value allows more random apportionment. Defaults to 1.0.
Raises:
@ -54,6 +51,8 @@ class SegmentedRoadGenerator(BaseRoadGenerator):
if not all(segment in prefabs.PREFABS.keys() for segment in segments):
raise ValueError(f"Invalid segment type provided. Available choices: {prefabs.SEGMENTS.keys()}")
self.segments = segments
self.alpha = alpha
num_points = int(self.length / self.ds)
# divide num_points into len(segments) randomly sized parts.
@ -84,7 +83,7 @@ class SegmentedRoadGenerator(BaseRoadGenerator):
if R_min > R_max_angle:
raise ValueError("No valid radius for this turn segment")
rand_radius = np.random.uniform(R_min, R_max_angle)
rand_radius = self._rng.uniform(R_min, R_max_angle)
if seg_name.startswith("u_turn"):
curvature_s = seg_function(rand_radius)