Hello,
I am currently facing an issue with obtaining different random values using the random.choice(Car_models)
in my code. The problem is that on each frame, it consistently provides me with the same cars from the list.
Here is the relevant portion of the code:
cars =
def car(num_cars, choicesList, lane_orientation):
for i in range(num_cars): # Randomly select a car model from the list car_model_path = random.choice(CAR_MODELS) # Create an instance from the random car car_instance = rep.create.from_usd(car_model_path, semantics=[('class', 'car')]) # Position instances with car_instance: rep.modify.pose( position=rep.distribution.choice(choicesList, with_replacements=False), rotation=rep.distribution.uniform(lane_orientation[0], lane_orientation[1]), ) cars.append(car_instance) return cars
rep.randomizer.register(car)
Also in this part of the code:
position=rep.distribution.choice(choicesList, with_replacements=False),
While randomization appears to be functioning on each frame, it often selects the same value, despite the with_replacements=False
argument that should prevent this.
I attempted to replace random.choice(car_models)
with rep.distribution.choice(car_models)
, as the latter function randomizes every frame. However, upon making this change, the code ceased to function.
I would greatly appreciate any insights or guidance on resolving this issue. Thank you in advance for your assistance.
Best regards,
Ivan