This commit is contained in:
Your Name
2024-05-12 00:33:45 -05:00
parent 65bcdde866
commit 62115b2e34
179 changed files with 19155 additions and 390 deletions

4
tools/bodyteleop/.gitignore vendored Executable file
View File

@@ -0,0 +1,4 @@
av
av-10.0.0/*
key.pem
cert.pem

View File

@@ -6,10 +6,9 @@ import os
import ssl
import subprocess
from aiohttp import web, ClientSession
import pyaudio
import wave
from aiohttp import web
from aiohttp import ClientSession
from openpilot.common.basedir import BASEDIR
from openpilot.system.webrtc.webrtcd import StreamRequestBody
@@ -23,7 +22,7 @@ WEBRTCD_HOST, WEBRTCD_PORT = "localhost", 5001
## UTILS
async def play_sound(sound: str):
async def play_sound(sound):
SOUNDS = {
"engage": "selfdrive/assets/sounds/engage.wav",
"disengage": "selfdrive/assets/sounds/disengage.wav",
@@ -52,7 +51,7 @@ async def play_sound(sound: str):
p.terminate()
## SSL
def create_ssl_cert(cert_path: str, key_path: str):
def create_ssl_cert(cert_path, key_path):
try:
proc = subprocess.run(f'openssl req -x509 -newkey rsa:4096 -nodes -out {cert_path} -keyout {key_path} \
-days 365 -subj "/C=US/ST=California/O=commaai/OU=comma body"',
@@ -76,17 +75,17 @@ def create_ssl_context():
return ssl_context
## ENDPOINTS
async def index(request: 'web.Request'):
async def index(request):
with open(os.path.join(TELEOPDIR, "static", "index.html"), "r") as f:
content = f.read()
return web.Response(content_type="text/html", text=content)
async def ping(request: 'web.Request'):
async def ping(request):
return web.Response(text="pong")
async def sound(request: 'web.Request'):
async def sound(request):
params = await request.json()
sound_to_play = params["sound"]
@@ -94,7 +93,7 @@ async def sound(request: 'web.Request'):
return web.json_response({"status": "ok"})
async def offer(request: 'web.Request'):
async def offer(request):
params = await request.json()
body = StreamRequestBody(params["sdp"], ["driver"], ["testJoystick"], ["carState"])
body_json = json.dumps(dataclasses.asdict(body))