Spaces:
Sleeping
Sleeping
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Reachy Mini Controller</title> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- important for mobile --> | |
| <style> | |
| body { | |
| font-family: system-ui, sans-serif; | |
| padding: 1em; | |
| margin: 0; | |
| background: #f9f9f9; | |
| color: #333; | |
| } | |
| h1 { | |
| font-size: 1.5em; | |
| text-align: center; | |
| margin-bottom: 1em; | |
| } | |
| .btn-grid { | |
| display: grid; | |
| grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); | |
| gap: 1em; | |
| margin-bottom: 1em; | |
| } | |
| button { | |
| padding: 0.8em; | |
| font-size: 1em; | |
| border: none; | |
| border-radius: 8px; | |
| cursor: pointer; | |
| transition: 0.2s; | |
| width: 100%; | |
| } | |
| button.status { | |
| background: #2196F3; | |
| color: white; | |
| } | |
| button.wake { | |
| background: #4CAF50; | |
| color: white; | |
| } | |
| button.sleep { | |
| background: #f44336; | |
| color: white; | |
| } | |
| button.torque { | |
| background: #FF9800; | |
| color: white; | |
| } | |
| button:hover { | |
| opacity: 0.9; | |
| } | |
| pre { | |
| background: white; | |
| padding: 1em; | |
| border-radius: 8px; | |
| box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); | |
| overflow-x: auto; | |
| font-size: 0.9em; | |
| white-space: pre-wrap; | |
| word-wrap: break-word; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <h1>π€ Reachy Mini Controller</h1> | |
| <div class="btn-grid"> | |
| <button class="status" onclick="getStatus()">π Get Status</button> | |
| <button class="wake" onclick="sendCommand('/move/play/wake_up')">π Wake Up</button> | |
| <button class="sleep" onclick="sendCommand('/move/play/goto_sleep')">π Sleep</button> | |
| <button class="torque" onclick="sendCommand('/motors/set_mode/enabled')">β‘ Enable Torque</button> | |
| </div> | |
| <pre id="output">Ready...</pre> | |
| <script> | |
| // const API_BASE = "https://192.168.1.96:8000/api"; // change to LAN IP if needed | |
| const API_BASE = "http://localhost:8000/api"; // change to LAN IP if needed | |
| const out = document.getElementById("output"); | |
| async function getStatus() { | |
| out.textContent = "Fetching status..."; | |
| try { | |
| const res = await fetch(`${API_BASE}/state/full`); | |
| if (!res.ok) throw new Error("HTTP " + res.status); | |
| const data = await res.json(); | |
| out.textContent = JSON.stringify(data, null, 2); | |
| } catch (err) { | |
| out.textContent = "β Error: " + err; | |
| } | |
| } | |
| async function sendCommand(endpoint) { | |
| out.textContent = `Sending POST ${endpoint}...`; | |
| try { | |
| const res = await fetch(`${API_BASE}${endpoint}`, { | |
| method: "POST", | |
| headers: { "Content-Type": "application/json" }, | |
| body: "{}" | |
| }); | |
| if (!res.ok) throw new Error("HTTP " + res.status); | |
| const data = await res.json().catch(() => ({})); | |
| out.textContent = "β Success:\n" + JSON.stringify(data, null, 2); | |
| } catch (err) { | |
| out.textContent = "β Error: " + err; | |
| } | |
| } | |
| </script> | |
| </body> | |
| </html> |