parent
9a764a67ec
commit
8e2a03b46d
2 changed files with 0 additions and 86 deletions
@ -1,49 +0,0 @@ |
||||
#!/usr/bin/env python3 |
||||
import os |
||||
import random |
||||
import subprocess |
||||
import time |
||||
from pathlib import Path |
||||
from common.basedir import BASEDIR |
||||
|
||||
os.environ["LD_LIBRARY_PATH"] = "" |
||||
|
||||
# pull this from the provisioning tests |
||||
play_sound = os.path.join(BASEDIR, "selfdrive/ui/test/play_sound") |
||||
waste = os.path.join(BASEDIR, "scripts/waste") |
||||
sound_path = Path(os.path.join(BASEDIR, "selfdrive/assets/sounds")) |
||||
|
||||
def sound_test(): |
||||
|
||||
# max volume |
||||
vol = 15 |
||||
sound_files = [p.absolute() for p in sound_path.iterdir() if str(p).endswith(".wav")] |
||||
|
||||
# start waste |
||||
p = subprocess.Popen([waste], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) |
||||
|
||||
start_time = time.monotonic() |
||||
frame = 0 |
||||
while True: |
||||
# start a few processes |
||||
procs = [] |
||||
for _ in range(random.randint(5, 20)): |
||||
sound = random.choice(sound_files) |
||||
p = subprocess.Popen([play_sound, str(sound), str(vol)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) |
||||
procs.append(p) |
||||
time.sleep(random.uniform(0, 0.75)) |
||||
|
||||
# and kill them |
||||
time.sleep(random.uniform(0, 5)) |
||||
for p in procs: |
||||
p.terminate() |
||||
|
||||
# write stats |
||||
stats = f"running time {time.monotonic() - start_time}s, cycle {frame}" |
||||
with open("/tmp/sound_stats.txt", "a") as f: |
||||
f.write(stats) |
||||
print(stats) |
||||
frame +=1 |
||||
|
||||
if __name__ == "__main__": |
||||
sound_test() |
@ -1,37 +0,0 @@ |
||||
#!/usr/bin/env python3 |
||||
import numpy as np |
||||
import cereal.messaging as messaging |
||||
from PIL import ImageFont, ImageDraw, Image |
||||
|
||||
font = ImageFont.truetype("arial", size=72) |
||||
def get_frame(idx): |
||||
img = np.zeros((874, 1164, 3), np.uint8) |
||||
img[100:400, 100:100+(idx % 10) * 100] = 255 |
||||
|
||||
# big number |
||||
im2 = Image.new("RGB", (200, 200)) |
||||
draw = ImageDraw.Draw(im2) |
||||
draw.text((10, 100), "%02d" % idx, font=font) |
||||
img[400:600, 400:600] = np.array(im2.getdata()).reshape((200, 200, 3)) |
||||
return img.tostring() |
||||
|
||||
if __name__ == "__main__": |
||||
from common.realtime import Ratekeeper |
||||
rk = Ratekeeper(20) |
||||
|
||||
pm = messaging.PubMaster(['roadCameraState']) |
||||
frm = [get_frame(x) for x in range(30)] |
||||
idx = 0 |
||||
while 1: |
||||
print("send %d" % idx) |
||||
dat = messaging.new_message('roadCameraState') |
||||
dat.valid = True |
||||
dat.frame = { |
||||
"frameId": idx, |
||||
"image": frm[idx % len(frm)], |
||||
} |
||||
pm.send('roadCameraState', dat) |
||||
|
||||
idx += 1 |
||||
rk.keep_time() |
||||
#time.sleep(1.0) |
Loading…
Reference in new issue