From 6629fd5be96b0a76799f37114b078a5b3fad7d82 Mon Sep 17 00:00:00 2001 From: blankey1337 <42594751+blankey1337@users.noreply.github.com> Date: Fri, 28 Nov 2025 13:51:08 -0800 Subject: [PATCH 1/3] feat: wire up simulation controls to dashboard - Update `software/dashboard/app.py` to handle ZMQ Command socket (PUSH) alongside SUB. - Update `software/dashboard/templates/index.html` to add buttons for "Reset Simulation" and "Start/Stop Recording". - Update `software/examples/alohamini/isaac_sim/isaac_alohamini_env.py` to handle `reset=True` command. This allows basic control of the remote simulation directly from the web dashboard on the MacBook. --- software/dashboard/app.py | 37 ++++++++++- software/dashboard/templates/index.html | 64 ++++++++++++++++++- .../isaac_sim/isaac_alohamini_env.py | 8 +++ 3 files changed, 105 insertions(+), 4 deletions(-) diff --git a/software/dashboard/app.py b/software/dashboard/app.py index 6466d28..18a1308 100644 --- a/software/dashboard/app.py +++ b/software/dashboard/app.py @@ -5,7 +5,7 @@ import zmq import cv2 import numpy as np -from flask import Flask, render_template, Response, jsonify +from flask import Flask, render_template, Response, jsonify, request app = Flask(__name__) @@ -13,15 +13,24 @@ latest_observation = {} lock = threading.Lock() connected = False +recording = False +cmd_socket = None -def zmq_worker(ip='127.0.0.1', port=5556): - global latest_observation, connected +def zmq_worker(ip='127.0.0.1', port=5556, cmd_port=5555): + global latest_observation, connected, cmd_socket context = zmq.Context() + + # Sub Socket socket = context.socket(zmq.SUB) socket.setsockopt(zmq.SUBSCRIBE, b"") socket.connect(f"tcp://{ip}:{port}") socket.setsockopt(zmq.CONFLATE, 1) + # Cmd Socket (Push to Sim) + cmd_socket = context.socket(zmq.PUSH) + cmd_socket.setsockopt(zmq.CONFLATE, 1) + cmd_socket.connect(f"tcp://{ip}:{cmd_port}") + print(f"Connecting to ZMQ Stream at {ip}:{port}...") while True: @@ -93,6 +102,28 @@ def video_feed(camera_name): return Response(generate_frames(camera_name), mimetype='multipart/x-mixed-replace; boundary=frame') +@app.route('/api/command', methods=['POST']) +def send_command(): + global cmd_socket + if not request.json or 'command' not in request.json: + return jsonify({'error': 'No command provided'}), 400 + + cmd = request.json['command'] + print(f"Received command: {cmd}") + + # Example handling + if cmd == 'reset_sim': + # Send reset command (Isaac Sim needs to handle this logic) + # For now, we can just zero out velocities or send a special flag + if cmd_socket: + cmd_socket.send_string(json.dumps({"reset": True})) + + elif cmd == 'start_recording': + # Trigger recording logic (would need to signal record_bi.py or similar) + pass + + return jsonify({'status': 'ok'}) + @app.route('/api/status') def get_status(): with lock: diff --git a/software/dashboard/templates/index.html b/software/dashboard/templates/index.html index 28130c8..49d8ed2 100644 --- a/software/dashboard/templates/index.html +++ b/software/dashboard/templates/index.html @@ -11,14 +11,27 @@ .camera-box img { max-width: 100%; height: auto; display: block; } .camera-title { text-align: center; font-size: 0.9em; margin-bottom: 5px; } .status-panel { flex: 1; background: #333; padding: 15px; border-radius: 5px; min-width: 300px; } + .controls-panel { width: 100%; background: #333; padding: 15px; border-radius: 5px; margin-top: 20px; } table { width: 100%; border-collapse: collapse; } td, th { padding: 5px; border-bottom: 1px solid #444; font-size: 0.9em; } th { text-align: left; color: #aaa; } .value { font-family: monospace; color: #4f4; } + .btn { padding: 10px 20px; font-size: 16px; margin-right: 10px; cursor: pointer; background: #555; color: white; border: none; border-radius: 4px; } + .btn:hover { background: #777; } + .btn-record { background: #c00; } + .btn-record:hover { background: #e00; } + .status-indicator { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; } + .status-active { background: #0f0; } + .status-inactive { background: #555; } -

AlohaMini Dashboard

+
+

AlohaMini Dashboard

+
+ Disconnected +
+
@@ -33,14 +46,63 @@

Robot State

+
+

Simulation Controls

+

Control the remote simulation directly from here.

+ + + +
+