Skip to content

Commit d6cbdd6

Browse files
jominki354ajouatom
authored andcommitted
web work (#283)
1 parent 733871c commit d6cbdd6

10 files changed

Lines changed: 609 additions & 95 deletions

File tree

selfdrive/carrot/realtime/transports/raw_ws.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ def is_allowed_service(self, service: str) -> bool:
3535
# 0 = no throttle (send every message)
3636
_THROTTLE_MAP = {
3737
"modelV2": 0, # camera-synced, don't throttle
38+
"carState": 0, # plot 1,2,5,7,8 — needs full rate for dense graphs
39+
"controlsState": 0, # plot 6 — needs full rate for dense graphs
40+
"longitudinalPlan": 0, # plot 1,2,4 — needs full rate for dense graphs
41+
"carControl": 0, # plot 1,6,7,8 — needs full rate for dense graphs
42+
"radarState": 0, # plot 4,5 — needs full rate for dense graphs
43+
"lateralPlan": 0, # overlay path rendering
44+
"carrotMan": 0, # HUD status updates
3845
"roadCameraState": 0.25, # metadata/debug only on web HUD
3946
"deviceState": 0.5, # slow-changing HUD stats
4047
"peripheralState": 0.5,

selfdrive/carrot/server/core.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import numpy as np
2828
from typing import Dict, Any, Tuple, Optional, List
2929

30-
from aiohttp import web, ClientSession, WSMsgType
30+
from aiohttp import web, ClientSession, ClientTimeout, WSMsgType
3131
from cereal import messaging
3232
from opendbc.car import structs
3333
import shlex
@@ -204,14 +204,16 @@ async def proxy_stream(request: web.Request) -> web.StreamResponse:
204204
sess: ClientSession = request.app["http"]
205205

206206
try:
207-
async with sess.post(WEBRTCD_URL, data=body, headers={"Content-Type": ct}) as resp:
207+
async with sess.post(WEBRTCD_URL, data=body, headers={"Content-Type": ct},
208+
timeout=ClientTimeout(total=15)) as resp:
208209
resp_body = await resp.read()
209-
# 그대로 전달
210210
out = web.Response(body=resp_body, status=resp.status)
211211
rct = resp.headers.get("Content-Type")
212212
if rct:
213213
out.headers["Content-Type"] = rct
214214
return out
215+
except asyncio.TimeoutError:
216+
return web.json_response({"ok": False, "error": "webrtcd timeout"}, status=504)
215217
except Exception as e:
216218
return web.json_response({"ok": False, "error": str(e)}, status=502)
217219

selfdrive/carrot/web/css/app.css

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2152,16 +2152,13 @@ body[data-page="carrot"] #driveHudCard.driveHudCard--loading {
21522152
border-radius: calc(var(--r-2xl) + 2px);
21532153
overflow: hidden;
21542154
border: 1px solid color-mix(in srgb, var(--md-outline-var) 82%, rgba(255,255,255,0.12));
2155-
background:
2156-
radial-gradient(circle at 16% 20%, rgba(255, 146, 77, 0.15), transparent 28%),
2157-
radial-gradient(circle at 80% 80%, rgba(104, 201, 255, 0.12), transparent 24%),
2158-
linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0)),
2159-
#04070c;
2155+
background: #0b0e12;
21602156
box-shadow: 0 20px 48px rgba(0, 0, 0, 0.24);
21612157
contain: layout style;
21622158
}
21632159

21642160
.carrot-stage__video,
2161+
.carrot-stage__videoHold,
21652162
.carrot-stage__canvas,
21662163
.carrot-stage__hud {
21672164
position: absolute;
@@ -2212,6 +2209,10 @@ body[data-page="carrot"] #driveHudCard.driveHudCard--loading {
22122209
opacity: 1;
22132210
}
22142211

2212+
.carrot-stage.is-video-held .carrot-stage__videoHold {
2213+
opacity: 1;
2214+
}
2215+
22152216
.carrot-stage.is-loading .carrot-stage__controls {
22162217
opacity: 0;
22172218
transform: translateY(8px);
@@ -2225,6 +2226,14 @@ body[data-page="carrot"] #driveHudCard.driveHudCard--loading {
22252226
pointer-events: none;
22262227
}
22272228

2229+
.carrot-stage__videoHold {
2230+
transform-origin: 0 0;
2231+
will-change: transform;
2232+
background: #000;
2233+
pointer-events: none;
2234+
z-index: 1;
2235+
}
2236+
22282237
.carrot-stage__canvas {
22292238
transform-origin: 0 0;
22302239
will-change: transform;

selfdrive/carrot/web/index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<link rel="icon" type="image/png" href="/assets/img_chffr_wheel.png?v=2604-01" />
88
<link rel="stylesheet" href="/css/tokens.css?v=2603-73" />
99
<link rel="stylesheet" href="/css/hud_card.css?v=2604-09" />
10-
<link rel="stylesheet" href="/css/app.css?v=2604-38" />
10+
<link rel="stylesheet" href="/css/app.css?v=2604-40" />
1111
</head>
1212

1313
<body>
@@ -243,6 +243,7 @@ <h2 id="carrotTitle" class="page-title">Home</h2>
243243

244244
<div id="carrotStage" class="carrot-stage">
245245
<video id="carrotRoadVideo" class="carrot-stage__video" autoplay playsinline muted style="display:none;"></video>
246+
<canvas id="carrotLastFrameCanvas" class="carrot-stage__videoHold" aria-hidden="true"></canvas>
246247
<canvas id="carrotOverlayCanvas" class="carrot-stage__canvas"></canvas>
247248
<canvas id="carrotHudCanvas" class="carrot-stage__hud"></canvas>
248249
<div id="carrotOnroadAlert" class="carrot-stage__alert" hidden aria-live="polite" aria-atomic="true">
@@ -441,7 +442,7 @@ <h2 id="carrotTitle" class="page-title">Home</h2>
441442
<script src="/js/app_core.js?v=2604-18"></script>
442443
<script src="/js/app_pages.js?v=2604-23"></script>
443444
<script src="/js/raw_capnp.js?v=2604-05"></script>
444-
<script src="/js/app_realtime.js?v=2604-11"></script>
445-
<script src="/js/home_drive.js?v=2604-26"></script>
445+
<script src="/js/app_realtime.js?v=2604-16"></script>
446+
<script src="/js/home_drive.js?v=2604-27"></script>
446447
</body>
447448
</html>

0 commit comments

Comments
 (0)