Public: anyone can read this; the crew can change it.

Migrated from github.com/Trevato/SO-ARM100

Point the app at my real arm: a setting for the server with the camera and the SO-101, simulation when unset #4

Merged opened this in answer to

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

The hosted app now has an ARMSERVER setting. Point it at your so101 serve (ws:// :8101, http://… or https://…) and the app relays the arm's controls, the /follow stream and the camera to it. With it unset, the app runs the simulated arm as before.

Notes

shipped merged

opened this

The hosted app now has an ARM_SERVER setting. Point it at your so101 serve (ws://<host>:8101, http://… or https://…) and the app relays the arm's controls, the /follow stream and the camera to it. With it unset, the app runs the simulated arm as before.

What changed

  • Software/so101/src/relay.ts (new): a relay in front of the simulated arm, using no new dependencies.
    • The page itself, the 3D model files and three.js always come from the app. Everything else goes to the real arm while it answers, or to the simulation when it doesn't.
    • The cameras come through at /camera/<1|2>/stream, so the browser never has to reach your network. By default they are on ports 8080 and 8081 of the same host; ARM_CAMERA_1 and ARM_CAMERA_2 take full URLs if they live elsewhere.
    • GET /link tells the page which arm it is on: live or simulated, the host, and why the real arm isn't in use.
    • The relay checks the real arm when it starts (giving up after 1.5 s) and again every 5 s. A failed read falls back to the simulation at once.
    • A move or playback has no timeout, since it only answers when the arm arrives. It is cut only when the link drops, and then comes back as an error (502); it is not replayed on the simulation.
  • Security: POST/PUT requests and the /follow stream are only accepted from the app's own page. This uses the browser's Sec-Fetch-Site header, or failing that Origin checked against X-Forwarded-Host/Host. Every response sets X-Content-Type-Options, Referrer-Policy and a small Content-Security-Policy.
  • bench/fake-serve.ts: the simulated arm now listens on a private loopback port, and the relay takes PORT/HOST. forge.json is unchanged.
  • viewer.html: the top bar shows "Live arm · host", "Simulated", or "Simulated · host unreachable (why)". Behind the relay the cameras load through the app. The page reloads when the arm switches between real and simulated (because the limits, poses and joints differ), but waits if the page itself is driving the arm.
  • README: a "Pointing the hosted app at your real arm" section: run so101 serve on the arm machine, set ARM_SERVER, and make sure the forge can reach that machine (for example, both on the same Tailscale network). It also warns not to expose so101 serve to the internet, since it has no login.

What I chose not to do

  • No login on so101 serve itself.
  • No WebRTC: the existing setup serves MJPEG, and the relay passes that through as a stream.
  • The Content-Security-Policy is limited to framing, base URL, plugins and form targets. A strict script/connect policy would have to account for the viewer's inline module and its ?stream= override, and I couldn't check that in a browser here.

How to try it

  • bun test in Software/so101 passes (101 tests), and so does bun x tsc --noEmit. The new tests in src/relay.test.ts cover status, saved poses and /follow reaching the "real" arm, camera bytes and /state coming through, the simulation when unset, a server that accepts connections but never answers falling back within 3 s, a server that disappears mid-session, a bad setting, and a request from another site being refused.
  • Locally: ARM_SERVER=ws://<pi>:8101 PORT=8102 FORGE_APP_DATA=./data bun run Software/so101/bench/fake-serve.ts, then open http://127.0.0.1:8102/.
  • On the preview, set ARM_SERVER on the app's settings page.

🤖 Generated with Claude Code

Closes #3

commented

The hosted app now has an ARM_SERVER setting. Point it at your so101 serve (ws://<host>:8101, http://… or https://…) and the app relays the arm's controls, the /follow stream and the camera to it. With it unset, the app runs the simulated arm as before.

What changed

  • Software/so101/src/relay.ts (new): a relay in front of the simulated arm, using no new dependencies.
    • The page itself, the 3D model files and three.js always come from the app. Everything else goes to the real arm while it answers, or to the simulation when it doesn't.
    • The cameras come through at /camera/<1|2>/stream, so the browser never has to reach your network. By default they are on ports 8080 and 8081 of the same host; ARM_CAMERA_1 and ARM_CAMERA_2 take full URLs if they live elsewhere.
    • GET /link tells the page which arm it is on: live or simulated, the host, and why the real arm isn't in use.
    • The relay checks the real arm when it starts (giving up after 1.5 s) and again every 5 s. A failed read falls back to the simulation at once.
    • A move or playback has no timeout, since it only answers when the arm arrives. It is cut only when the link drops, and then comes back as an error (502); it is not replayed on the simulation.
  • Security: POST/PUT requests and the /follow stream are only accepted from the app's own page. This uses the browser's Sec-Fetch-Site header, or failing that Origin checked against X-Forwarded-Host/Host. Every response sets X-Content-Type-Options, Referrer-Policy and a small Content-Security-Policy.
  • bench/fake-serve.ts: the simulated arm now listens on a private loopback port, and the relay takes PORT/HOST. forge.json is unchanged.
  • viewer.html: the top bar shows "Live arm · host", "Simulated", or "Simulated · host unreachable (why)". Behind the relay the cameras load through the app. The page reloads when the arm switches between real and simulated (because the limits, poses and joints differ), but waits if the page itself is driving the arm.
  • README: a "Pointing the hosted app at your real arm" section: run so101 serve on the arm machine, set ARM_SERVER, and make sure the forge can reach that machine (for example, both on the same Tailscale network). It also warns not to expose so101 serve to the internet, since it has no login.

What I chose not to do

  • No login on so101 serve itself.
  • No WebRTC: the existing setup serves MJPEG, and the relay passes that through as a stream.
  • The Content-Security-Policy is limited to framing, base URL, plugins and form targets. A strict script/connect policy would have to account for the viewer's inline module and its ?stream= override, and I couldn't check that in a browser here.

How to try it

  • bun test in Software/so101 passes (101 tests), and so does bun x tsc --noEmit. The new tests in src/relay.test.ts cover status, saved poses and /follow reaching the "real" arm, camera bytes and /state coming through, the simulation when unset, a server that accepts connections but never answers falling back within 3 s, a server that disappears mid-session, a bad setting, and a request from another site being refused.
  • Locally: ARM_SERVER=ws://<pi>:8101 PORT=8102 FORGE_APP_DATA=./data bun run Software/so101/bench/fake-serve.ts, then open http://127.0.0.1:8102/.
  • On the preview, set ARM_SERVER on the app's settings page.

🤖 Generated with Claude Code

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs