diff --git a/tools/bodyteleop/static/js/controls.js b/tools/bodyteleop/static/js/controls.js
index b1e0e7ee7..3a11f78b9 100644
--- a/tools/bodyteleop/static/js/controls.js
+++ b/tools/bodyteleop/static/js/controls.js
@@ -18,37 +18,3 @@ export const handleKeyX = (key, setValue) => {
$("#pos-vals").text(x+","+y);
}
};
-
-export async function executePlan() {
- let plan = $("#plan-text").val();
- const planList = [];
- plan.split("\n").forEach(function(e){
- let line = e.split(",").map(k=>parseInt(k));
- if (line.length != 5 || line.slice(0, 4).map(e=>[1, 0].includes(e)).includes(false) || line[4] < 0 || line[4] > 10){
- console.log("invalid plan");
- }
- else{
- planList.push(line)
- }
- });
-
- async function execute() {
- for (var i = 0; i < planList.length; i++) {
- let [w, a, s, d, t] = planList[i];
- while(t > 0){
- console.log(w, a, s, d, t);
- if(w==1){$("#key-w").mousedown();}
- if(a==1){$("#key-a").mousedown();}
- if(s==1){$("#key-s").mousedown();}
- if(d==1){$("#key-d").mousedown();}
- await sleep(50);
- $("#key-w").mouseup();
- $("#key-a").mouseup();
- $("#key-s").mouseup();
- $("#key-d").mouseup();
- t = t - 0.05;
- }
- }
- }
- execute();
-}
\ No newline at end of file
diff --git a/tools/bodyteleop/static/js/jsmain.js b/tools/bodyteleop/static/js/jsmain.js
index 83205a876..0db1dcd9b 100644
--- a/tools/bodyteleop/static/js/jsmain.js
+++ b/tools/bodyteleop/static/js/jsmain.js
@@ -1,5 +1,5 @@
-import { handleKeyX, executePlan } from "./controls.js";
-import { start, stop, lastChannelMessageTime, playSoundRequest } from "./webrtc.js";
+import { handleKeyX } from "./controls.js";
+import { start, stop, lastChannelMessageTime } from "./webrtc.js";
export var pc = null;
export var dc = null;
@@ -8,12 +8,6 @@ document.addEventListener('keydown', (e)=>(handleKeyX(e.key.toLowerCase(), 1)));
document.addEventListener('keyup', (e)=>(handleKeyX(e.key.toLowerCase(), 0)));
$(".keys").bind("mousedown touchstart", (e)=>handleKeyX($(e.target).attr('id').replace('key-', ''), 1));
$(".keys").bind("mouseup touchend", (e)=>handleKeyX($(e.target).attr('id').replace('key-', ''), 0));
-$("#plan-button").click(executePlan);
-$(".sound").click((e)=>{
- const sound = $(e.target).attr('id').replace('sound-', '')
- return playSoundRequest(sound);
-});
-
setInterval( () => {
const dt = new Date().getTime();
if ((dt - lastChannelMessageTime) > 1000) {
diff --git a/tools/bodyteleop/static/js/webrtc.js b/tools/bodyteleop/static/js/webrtc.js
index 165a2ce6c..28bea238e 100644
--- a/tools/bodyteleop/static/js/webrtc.js
+++ b/tools/bodyteleop/static/js/webrtc.js
@@ -15,15 +15,6 @@ export function offerRtcRequest(sdp, type) {
}
-export function playSoundRequest(sound) {
- return fetch('/sound', {
- body: JSON.stringify({sound}),
- headers: {'Content-Type': 'application/json'},
- method: 'POST'
- });
-}
-
-
export function pingHeadRequest() {
return fetch('/', {
method: 'HEAD'
@@ -38,20 +29,18 @@ export function createPeerConnection(pc) {
pc = new RTCPeerConnection(config);
- // connect audio / video
+ // connect video
pc.addEventListener('track', function(evt) {
console.log("Adding Tracks!")
if (evt.track.kind == 'video')
document.getElementById('video').srcObject = evt.streams[0];
- else
- document.getElementById('audio').srcObject = evt.streams[0];
});
return pc;
}
export function negotiate(pc) {
- return pc.createOffer({offerToReceiveAudio:true, offerToReceiveVideo:true}).then(function(offer) {
+ return pc.createOffer({offerToReceiveVideo:true}).then(function(offer) {
return pc.setLocalDescription(offer);
}).then(function() {
return new Promise(function(resolve) {
@@ -90,14 +79,6 @@ function isMobile() {
export const constraints = {
- audio: {
- autoGainControl: false,
- sampleRate: 48000,
- sampleSize: 16,
- echoCancellation: true,
- noiseSuppression: true,
- channelCount: 1
- },
video: isMobile()
};
@@ -105,23 +86,8 @@ export const constraints = {
export function start(pc, dc) {
pc = createPeerConnection(pc);
- // add audio track
- navigator.mediaDevices.enumerateDevices()
- .then(function(devices) {
- const hasAudioInput = devices.find((device) => device.kind === "audioinput");
- var modifiedConstraints = {};
- modifiedConstraints.video = constraints.video;
- modifiedConstraints.audio = hasAudioInput ? constraints.audio : false;
-
- return Promise.resolve(modifiedConstraints);
- })
- .then(function(constraints) {
- if (constraints.audio || constraints.video) {
- return navigator.mediaDevices.getUserMedia(constraints);
- } else{
- return Promise.resolve(null);
- }
- })
+ // add a local video track on mobile
+ (constraints.video ? navigator.mediaDevices.getUserMedia(constraints) : Promise.resolve(null))
.then(function(stream) {
if (stream) {
stream.getTracks().forEach(function(track) {
diff --git a/tools/bodyteleop/static/main.css b/tools/bodyteleop/static/main.css
index 1bfb5982b..79fe8052f 100644
--- a/tools/bodyteleop/static/main.css
+++ b/tools/bodyteleop/static/main.css
@@ -172,13 +172,6 @@ video {
display: none;
}
-.plan-form {
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- align-items: center;
-}
-
.details {
display: flex;
padding: 0px 10px 0px 10px;