mirror of
https://github.com/pim-n/road-gen.git
synced 2026-02-03 09:23:09 +01:00
fix generic reference to np.random to internal class rng
This commit is contained in:
@ -39,9 +39,6 @@ class SegmentedRoadGenerator(BaseRoadGenerator):
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
segments (list[str]): List of segments.
|
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.
|
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:
|
Raises:
|
||||||
@ -54,6 +51,8 @@ class SegmentedRoadGenerator(BaseRoadGenerator):
|
|||||||
if not all(segment in prefabs.PREFABS.keys() for segment in segments):
|
if not all(segment in prefabs.PREFABS.keys() for segment in segments):
|
||||||
raise ValueError(f"Invalid segment type provided. Available choices: {prefabs.SEGMENTS.keys()}")
|
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)
|
num_points = int(self.length / self.ds)
|
||||||
|
|
||||||
# divide num_points into len(segments) randomly sized parts.
|
# divide num_points into len(segments) randomly sized parts.
|
||||||
@ -84,7 +83,7 @@ class SegmentedRoadGenerator(BaseRoadGenerator):
|
|||||||
if R_min > R_max_angle:
|
if R_min > R_max_angle:
|
||||||
raise ValueError("No valid radius for this turn segment")
|
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"):
|
if seg_name.startswith("u_turn"):
|
||||||
curvature_s = seg_function(rand_radius)
|
curvature_s = seg_function(rand_radius)
|
||||||
|
|||||||
Reference in New Issue
Block a user