Add a React web app for visualization of the graph and constraints#135
Open
DiegoP-G wants to merge 11 commits intohumanoid-path-planner:develfrom
Open
Add a React web app for visualization of the graph and constraints#135DiegoP-G wants to merge 11 commits intohumanoid-path-planner:develfrom
DiegoP-G wants to merge 11 commits intohumanoid-path-planner:develfrom
Conversation
… a WebSocket server for communication with interactive_viewer.py
…p and improve code formatting
for more information, see https://pre-commit.ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Web Plot Viewer — Functional Documentation
This document describes the functioning of the web plot viewer component.
1. General Architecture
sequenceDiagram autonumber participant GVT as GraphViewerThread participant IGV as InteractiveGraphViewer participant HTTP as StaticWebAppService:5173 participant WSB as GraphWebSocketBridge:8765 participant UI as React Web App participant HPP as HPP Graph APIs Note over GVT: start_qt_viewer = false GVT->>IGV: init(graph, problem, _on_config_generated) GVT->>HTTP: start() GVT->>WSB: start(on_message=handle_web_app_message, snapshot_provider) WSB-->>GVT: is_running=true GVT->>WSB: send_viewer_snapshot(graph) WSB-->>UI: viewer_snapshot {graph} UI->>WSB: WS connect WSB-->>UI: hello UI->>WSB: request_snapshot WSB->>GVT: _build_snapshot_payload() GVT-->>WSB: {type:viewer_snapshot, graph} WSB-->>UI: viewer_snapshot {graph} UI->>WSB: menu_action {action, elementKind, elementId} WSB->>GVT: handle_web_app_message(message) GVT->>IGV: handle_web_app_message(message) alt action on node IGV->>HPP: getState / applyStateConstraints HPP-->>IGV: projected config else action on edge IGV->>HPP: getTransition / generateTargetConfig HPP-->>IGV: generated config end IGV-->>GVT: _on_config_generated(config, label) GVT-->>GVT: config_callback(config, label) UI->>WSB: ping / request_status WSB-->>UI: pong / status Note over GVT: stop requested GVT->>WSB: stop() GVT->>HTTP: stop()2. Life Cycle
GraphViewerThread.run()instantiatesInteractiveGraphViewerwithgraph,problem, and a callback_on_config_generated.start_qt_viewer=True, the thread callsself._viewer.show()and does not start the web app.StaticWebAppService.start();GraphWebSocketBridgethat handles communication between Python and JavaScript;send_viewer_snapshot(self.graph).stop()is called and the bridge is no longer running.GraphWebSocketBridge.stop()thenStaticWebAppService.stop()are called.3. Communication
Messages: Python → UI
hellotype: hello,source: python,url: <websocket URL>viewer_snapshottype: viewer_snapshot,graph: _serialize_graph(graph)pongpingackmenu_actionstatusrequest_statusMessages: UI → Python
request_snapshotmenu_actionaction,elementKind: node | edge,elementIdpingrequest_status4. Business Action Routing
Front-end action routing to HPP is handled in
InteractiveGraphViewer.handle_web_app_message.Supported node actions:
generate_random_configgenerate_from_current_configset_target_stateSupported edge actions:
extend_current_to_currentextend_current_to_random5. Reference Files
src/pyhpp_plot/graph_viewer_thread.pysrc/pyhpp_plot/interactive_viewer.pysrc/pyhpp_plot/websocket_bridge.pysrc/pyhpp_plot/web_app_server.pyThe CI does not pass because the web app build uses npm, which is not yet installed in the Nix dependencies.