Ejemplo n.º 1
0
def spawn_car(random_start_end=True):
    plate_number = generate_license_plate()
    #rand_num = np.random.choice(10)
    if random_start_end:
        start_node = random.sample(car_graph.G._sources, 1)[0] 
        end_node = random.sample(car_graph.G._sinks, 1)[0]
    color = np.random.choice(tuple(car.car_colors))
    the_car = car.KinematicCar(init_state=start_node, color=color, plate_number=plate_number)
    if random_start_end:
        return start_node, end_node, the_car
Ejemplo n.º 2
0
    background.paste(person_fig, (int(x_corner), int(y_corner)), person_fig)


# creates figure
fig = plt.figure()
ax = fig.add_axes([0, 0, 1, 1])  # get rid of white border

# turn on/off axes
plt.axis('off')
# sampling time
dt = 0.1
# creates cars
prim_id = 0  # first primitive
prim = mat['MA3'][prim_id, 0]
x0 = np.array(prim['x0'][0, 0][:, 0])
car_1a = car.KinematicCar(init_state=np.reshape(x0, (-1, 1)))  # primitive car
car_1a.prim_queue.enqueue((prim_id, 0))
car_1a.prim_queue.enqueue((4, 0))
car_1a.prim_queue.enqueue((8, 0))
car_1a.prim_queue.enqueue((15, 0))
car_1a.prim_queue.enqueue((17, 0))

prim_id = 6  # first primitive
prim = mat['MA3'][prim_id, 0]
x0 = np.array(prim['x0'][0, 0][:, 0])
car_1b = car.KinematicCar(init_state=np.reshape(x0, (-1, 1)))  # primitive car
car_1b.prim_queue.enqueue((prim_id, 0))
car_1b.prim_queue.enqueue((8, 0))
car_1b.prim_queue.enqueue((13, 0))
car_1b.prim_queue.enqueue((14, 0))