Sync from GitHub via hub-sync
Browse files- port_hf.js +15 -4
port_hf.js
CHANGED
|
@@ -648,10 +648,6 @@ async function setupRobot() {
|
|
| 648 |
|
| 649 |
robot.addEventListener('streaming', async () => {
|
| 650 |
isStreaming = true;
|
| 651 |
-
// In simulation the robot's WebRTC track may auto-attach; restore webcam
|
| 652 |
-
if (isSimulation && webcamStream) {
|
| 653 |
-
document.getElementById('rv-video').srcObject = webcamStream;
|
| 654 |
-
}
|
| 655 |
showRVState('rv-monitoring');
|
| 656 |
const placeholder = document.getElementById('rv-video-placeholder');
|
| 657 |
if (placeholder) placeholder.style.display = 'none';
|
|
@@ -680,9 +676,24 @@ async function setupRobot() {
|
|
| 680 |
robot.addEventListener('error', e => console.error('Robot error:', e));
|
| 681 |
}
|
| 682 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 683 |
async function startSession(robotId) {
|
| 684 |
if (!robot || robot.state !== 'connected') return;
|
| 685 |
try {
|
|
|
|
|
|
|
|
|
|
| 686 |
const videoEl = document.getElementById('rv-video');
|
| 687 |
if (isSimulation) {
|
| 688 |
webcamStream = await navigator.mediaDevices.getUserMedia({ video: true, audio: false });
|
|
|
|
| 648 |
|
| 649 |
robot.addEventListener('streaming', async () => {
|
| 650 |
isStreaming = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 651 |
showRVState('rv-monitoring');
|
| 652 |
const placeholder = document.getElementById('rv-video-placeholder');
|
| 653 |
if (placeholder) placeholder.style.display = 'none';
|
|
|
|
| 676 |
robot.addEventListener('error', e => console.error('Robot error:', e));
|
| 677 |
}
|
| 678 |
|
| 679 |
+
async function queryDaemonSimulation() {
|
| 680 |
+
try {
|
| 681 |
+
const resp = await fetch('http://localhost:8000/daemon/status',
|
| 682 |
+
{ signal: AbortSignal.timeout(2000) });
|
| 683 |
+
if (resp.ok) {
|
| 684 |
+
const s = await resp.json();
|
| 685 |
+
return !!(s.simulation_enabled || s.mockup_sim_enabled);
|
| 686 |
+
}
|
| 687 |
+
} catch {}
|
| 688 |
+
return null; // daemon unreachable — fall back to name-based value
|
| 689 |
+
}
|
| 690 |
+
|
| 691 |
async function startSession(robotId) {
|
| 692 |
if (!robot || robot.state !== 'connected') return;
|
| 693 |
try {
|
| 694 |
+
const daemonSim = await queryDaemonSimulation();
|
| 695 |
+
if (daemonSim !== null) isSimulation = daemonSim;
|
| 696 |
+
|
| 697 |
const videoEl = document.getElementById('rv-video');
|
| 698 |
if (isSimulation) {
|
| 699 |
webcamStream = await navigator.mediaDevices.getUserMedia({ video: true, audio: false });
|