saltylab-firmware/ui/map_panel.css
sl-webui 5dac6337e6 feat: WebUI map view (Issue #587)
Standalone 3-file 2D map panel (ui/map_panel.{html,js,css}).
No build step. Open directly or serve ui/ directory.

Canvas layers (drawn every animation frame):
  - Grid lines (1m spacing) + world-origin axis cross + 1m scale bar
  - RPLIDAR scan dots (/scan, green, cbor-compressed, 100ms throttle)
  - Safety zone rings: danger 0.30m (red dashed) + warn 1.00m (amber dashed)
  - 100-position breadcrumb trail with fading cyan polyline + dots every 5 pts
  - UWB anchor markers (amber diamond + label, user-configured)
  - Robot marker: circle + forward arrow, red when e-stopped

Interactions:
  - Mouse wheel zoom (zooms around cursor)
  - Click+drag pan
  - Pinch-to-zoom (touch, two-finger)
  - Auto-center toggle (robot stays centered when on)
  - Zoom +/- buttons, Reset view button
  - Clear trail button
  - Mouse hover shows world coords (m) in bottom-left HUD

ROS topics:
  SUB /saltybot/pose/fused        geometry_msgs/PoseStamped   50ms throttle
  SUB /scan                       sensor_msgs/LaserScan       100ms + cbor
  SUB /saltybot/safety_zone/status std_msgs/String (JSON)     200ms throttle

Sidebar:
  - Robot position (x, y m) + heading (°)
  - Safety zone: forward zone (CLEAR/WARN/DANGER), closest obstacle (m), e-stop
  - UWB anchor manager: add/remove anchors with x/y/label, persisted localStorage
  - Topic reference

E-stop banner: pulsing red overlay when /saltybot/safety_zone/status estop_active=true

Mobile-responsive: sidebar hidden on <700px, canvas fills viewport.
WS URL persisted in localStorage.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-14 12:20:04 -04:00

237 lines
5.8 KiB
CSS

/* map_panel.css — Saltybot 2D Map View (Issue #587) */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg0: #050510;
--bg1: #070712;
--bg2: #0a0a1a;
--bd: #0c2a3a;
--bd2: #1e3a5f;
--dim: #374151;
--mid: #6b7280;
--base: #9ca3af;
--hi: #d1d5db;
--cyan: #06b6d4;
--green: #22c55e;
--amber: #f59e0b;
--red: #ef4444;
}
body {
font-family: 'Courier New', Courier, monospace;
font-size: 12px;
background: var(--bg0);
color: var(--base);
height: 100dvh;
display: flex;
flex-direction: column;
overflow: hidden;
}
/* ── Header ── */
#header {
display: flex;
align-items: center;
padding: 5px 12px;
background: var(--bg1);
border-bottom: 1px solid var(--bd);
flex-shrink: 0;
gap: 8px;
flex-wrap: wrap;
}
.logo { color: #f97316; font-weight: bold; letter-spacing: .15em; font-size: 13px; flex-shrink: 0; }
#conn-dot {
width: 8px; height: 8px; border-radius: 50%;
background: var(--dim); flex-shrink: 0; transition: background .3s;
}
#conn-dot.connected { background: var(--green); }
#conn-dot.error { background: var(--red); animation: blink 1s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }
#ws-input {
background: var(--bg2); border: 1px solid var(--bd2); border-radius: 4px;
color: #67e8f9; padding: 2px 7px; font-family: monospace; font-size: 11px; width: 185px;
}
#ws-input:focus { outline: none; border-color: var(--cyan); }
.hbtn {
padding: 2px 8px; border-radius: 4px; border: 1px solid var(--bd2);
background: var(--bg2); color: #67e8f9; font-family: monospace;
font-size: 10px; font-weight: bold; cursor: pointer; transition: background .15s;
white-space: nowrap;
}
.hbtn:hover { background: #0e4f69; }
.hbtn.on { background: #0e4f69; border-color: var(--cyan); color: #fff; }
.hbtn.warn-on { background: #3d1a00; border-color: #92400e; color: #fbbf24; }
/* ── Toolbar ── */
#toolbar {
display: flex;
align-items: center;
gap: 8px;
padding: 4px 12px;
background: var(--bg1);
border-bottom: 1px solid var(--bd);
flex-shrink: 0;
flex-wrap: wrap;
font-size: 10px;
}
.tsep { width: 1px; height: 16px; background: var(--bd2); }
#zoom-display { color: var(--mid); min-width: 45px; }
/* ── Main: map + sidebar ── */
#main {
flex: 1;
display: grid;
grid-template-columns: 1fr 240px;
min-height: 0;
}
@media (max-width: 700px) {
#main { grid-template-columns: 1fr; }
#sidebar { display: none; }
}
/* ── Canvas ── */
#map-canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#map-canvas.dragging { cursor: grabbing; }
#map-wrap {
position: relative;
overflow: hidden;
background: #010108;
}
/* No-signal overlay */
#no-signal {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 8px;
color: var(--dim);
pointer-events: none;
}
#no-signal.hidden { display: none; }
#no-signal .icon { font-size: 48px; }
/* E-stop overlay */
#estop-overlay {
position: absolute;
top: 8px; left: 50%; transform: translateX(-50%);
background: rgba(127,0,0,0.85);
border: 2px solid #ef4444;
color: #fca5a5;
padding: 4px 14px;
border-radius: 4px;
font-weight: bold;
font-size: 11px;
letter-spacing: .1em;
pointer-events: none;
display: none;
animation: blink 1s infinite;
}
#estop-overlay.visible { display: block; }
/* Mouse coords HUD */
#coords-hud {
position: absolute;
bottom: 6px; left: 8px;
background: rgba(0,0,0,.7);
color: var(--mid);
padding: 2px 6px;
border-radius: 3px;
font-size: 10px;
pointer-events: none;
}
/* ── Sidebar ── */
#sidebar {
background: var(--bg1);
border-left: 1px solid var(--bd);
display: flex;
flex-direction: column;
overflow-y: auto;
padding: 8px;
gap: 8px;
font-size: 11px;
}
.sb-card {
background: var(--bg2);
border: 1px solid var(--bd2);
border-radius: 6px;
padding: 8px;
}
.sb-title {
font-size: 9px; font-weight: bold; letter-spacing: .12em;
color: #0891b2; text-transform: uppercase; margin-bottom: 6px;
}
.sb-row {
display: flex; justify-content: space-between;
padding: 2px 0; border-bottom: 1px solid var(--bd);
font-size: 10px;
}
.sb-row:last-child { border-bottom: none; }
.sb-lbl { color: var(--mid); }
.sb-val { color: var(--hi); font-family: monospace; }
/* Status dots */
.sdot {
width: 8px; height: 8px; border-radius: 50%;
display: inline-block; margin-right: 4px;
}
.sdot.green { background: var(--green); }
.sdot.amber { background: var(--amber); }
.sdot.red { background: var(--red); animation: blink .8s infinite; }
.sdot.gray { background: var(--dim); }
/* Legend ── */
.legend-row {
display: flex; align-items: center; gap: 6px;
font-size: 10px; color: var(--base); padding: 2px 0;
}
.legend-swatch {
width: 20px; height: 3px; border-radius: 2px; flex-shrink: 0;
}
/* Anchor list */
#anchor-list .anchor-row {
display: flex; align-items: center; gap: 4px;
padding: 2px 0; font-size: 10px; color: var(--base);
border-bottom: 1px solid var(--bd);
}
#anchor-list .anchor-row:last-child { border-bottom: none; }
#anchor-add { width: 100%; margin-top: 4px; }
/* Anchor input row */
.anchor-inputs {
display: grid; grid-template-columns: 1fr 1fr 1fr;
gap: 4px; margin-top: 4px;
}
.anchor-inputs input {
background: var(--bg0); border: 1px solid var(--bd2);
border-radius: 3px; color: var(--hi); padding: 2px 4px;
font-family: monospace; font-size: 10px; text-align: center;
width: 100%;
}
.anchor-inputs input:focus { outline: none; border-color: var(--cyan); }
/* ── Footer ── */
#footer {
background: var(--bg1); border-top: 1px solid var(--bd);
padding: 3px 12px;
display: flex; align-items: center; justify-content: space-between;
flex-shrink: 0; font-size: 10px; color: var(--dim);
}