DebugView
class DebugViewImportable as dream.DebugView.
Serves the page of a client’s round trips on 127.0.0.1, from now until close() or the program’s exit.
It registers itself with DreamClient.on_round_trip(), or, for a loop that calls the HTTP API itself, takes each call from add(); it keeps the last KEEP round trips in memory; the page asks for them twice a second and draws the newest, or the one picked. Nothing is uploaded, and the page is not reachable from another computer (forward the port, ssh -L <port>:localhost:<port>, to see it from one).
Attributes
url: The page,http://127.0.0.1:<port>/.
A context manager: use it in a with block. Entering: Returns the view; leaving the block calls close(). Leaving: Calls close().
Constructor
Section titled “Constructor”DebugView(client: DreamClient | None, port: int = 0)
Starts the page’s server on a thread of its own and registers with client.
Parameters
client(DreamClient| None): The client whose round trips the page shows, any policy it opens, now or later; None for a loop that calls the HTTP API itself and hands each call to add().port(int, default0): The port on 127.0.0.1; 0 lets the system pick a free one, whichurlnames.
Raises
OSError: The port cannot be listened on (another program holds it).
DebugView.watch
Section titled “DebugView.watch”DebugView.watch(client: DreamClient) -> None
Shows client’s round trips too: a station that opens a client per run hands each one here.
Parameters
client(DreamClient): A client whose every get_action() the page shows from now on.
DebugView.add
Section titled “DebugView.add”DebugView.add(sent: Mapping[str, Any], reply: Mapping[str, Any] | None) -> None
Shows one call a loop made to the HTTP API itself, without a DreamClient: what it sent and what came back.
Parameters
sent(Mapping[str, Any]): The JSON body of the loop’s inference request, as a dict. Itsobservationis shown: eachvideo.<role>as that camera’s frames (one base64 JPEG, or a list of them oldest first), the rest as the state and the prompt.reply(Mapping[str, Any] | None): The JSON reply, as a dict: itsactionsare the chunk and itstimingthe timing; a reply whose status is not an answer shows as a refusal with its code and reason. None when the call got no reply.
Raises
TypeError:senthas noobservationdict.
DebugView.show_arms
Section titled “DebugView.show_arms”DebugView.show_arms(motion: Callable[[], Mapping[str, Any] | None]) -> None
Draws the arms in 3D at the top of the page too, from a scripted motion (python -m dream.check).
A ghost of each arm moves where the motion commands it, and a solid arm stands at the pose the loop reported at its last call, with each hand’s commanded path and a dot where each call’s pose put the hand; live while the arms move, then replayed. A YAM, a reBot (seeed_faas), a Metal or a Maker arm (makers) is drawn whole, another arm the check knows as its chain of joints, and an arm it does not know as its hand’s tool point. For this the page loads three.js from cdn.jsdelivr.net; the frames and values still never leave this computer.
Parameters
motion(Callable[[], Mapping[str, Any] | None]): Returnsarms(): the targets per row, each call’s state and the clock; None before the loop’s first call.
DebugView.close
Section titled “DebugView.close”DebugView.close() -> None
Stops the server; the page then says it lost its program.