PierreRouanet commited on
Commit
8ee87fa
·
1 Parent(s): 55f8404

Update commands to typed protocol format

Browse files
Files changed (1) hide show
  1. index.html +6 -6
index.html CHANGED
@@ -881,7 +881,7 @@
881
  updateStatus('connected', 'Connected');
882
  enableControls(true);
883
  document.getElementById('robotSelector').classList.add('hidden');
884
- stateRefreshInterval = setInterval(() => sendCommand({ get_state: true }), 500);
885
  } else if (state === 'failed' || state === 'disconnected') {
886
  updateStatus('', 'Connection lost');
887
  }
@@ -889,7 +889,7 @@
889
 
890
  peerConnection.ondatachannel = (e) => {
891
  dataChannel = e.channel;
892
- dataChannel.onopen = () => sendCommand({ get_state: true });
893
  dataChannel.onmessage = (e) => handleRobotMessage(JSON.parse(e.data));
894
  };
895
 
@@ -1102,7 +1102,7 @@
1102
  const roll = parseFloat(rollSlider.value);
1103
  const pitch = parseFloat(pitchSlider.value);
1104
  const yaw = parseFloat(yawSlider.value);
1105
- sendCommand({ set_target: buildMatrix(yaw, pitch, roll) });
1106
  }
1107
 
1108
  function onSliderStart() {
@@ -1169,7 +1169,7 @@
1169
  function sendAntennas() {
1170
  const r = parseFloat(rightSlider.value) * Math.PI / 180;
1171
  const l = parseFloat(leftSlider.value) * Math.PI / 180;
1172
- sendCommand({ set_antennas: [r, l] });
1173
  }
1174
 
1175
  rightSlider.addEventListener('input', () => {
@@ -1186,12 +1186,12 @@
1186
  // ===================== Sound =====================
1187
  function playSound() {
1188
  const file = document.getElementById('soundInput').value.trim();
1189
- if (file) sendCommand({ play_sound: file });
1190
  }
1191
 
1192
  function playSoundPreset(file) {
1193
  document.getElementById('soundInput').value = file;
1194
- sendCommand({ play_sound: file });
1195
  }
1196
  </script>
1197
  </body>
 
881
  updateStatus('connected', 'Connected');
882
  enableControls(true);
883
  document.getElementById('robotSelector').classList.add('hidden');
884
+ stateRefreshInterval = setInterval(() => sendCommand({ type: 'get_state' }), 500);
885
  } else if (state === 'failed' || state === 'disconnected') {
886
  updateStatus('', 'Connection lost');
887
  }
 
889
 
890
  peerConnection.ondatachannel = (e) => {
891
  dataChannel = e.channel;
892
+ dataChannel.onopen = () => sendCommand({ type: 'get_state' });
893
  dataChannel.onmessage = (e) => handleRobotMessage(JSON.parse(e.data));
894
  };
895
 
 
1102
  const roll = parseFloat(rollSlider.value);
1103
  const pitch = parseFloat(pitchSlider.value);
1104
  const yaw = parseFloat(yawSlider.value);
1105
+ sendCommand({ type: 'set_target', head: buildMatrix(yaw, pitch, roll).flat() });
1106
  }
1107
 
1108
  function onSliderStart() {
 
1169
  function sendAntennas() {
1170
  const r = parseFloat(rightSlider.value) * Math.PI / 180;
1171
  const l = parseFloat(leftSlider.value) * Math.PI / 180;
1172
+ sendCommand({ type: 'set_antennas', antennas: [r, l] });
1173
  }
1174
 
1175
  rightSlider.addEventListener('input', () => {
 
1186
  // ===================== Sound =====================
1187
  function playSound() {
1188
  const file = document.getElementById('soundInput').value.trim();
1189
+ if (file) sendCommand({ type: 'play_sound', file: file });
1190
  }
1191
 
1192
  function playSoundPreset(file) {
1193
  document.getElementById('soundInput').value = file;
1194
+ sendCommand({ type: 'play_sound', file: file });
1195
  }
1196
  </script>
1197
  </body>