X-Git-Url: https://defiant.homedns.org/gitweb/?p=ros_wild_thumper.git;a=blobdiff_plain;f=www%2Fassets%2Fjavascripts%2Fapplication.js;h=2fc417603ea6f876252041e5240209263a38e466;hp=3f85f00359078679d2be5b09d15aa8acb4c06d94;hb=38fd577a1efa5248a91105c1a907cb0f364a6dfa;hpb=c8ec98bdd30f8e533da331fe48742237ccc230d2 diff --git a/www/assets/javascripts/application.js b/www/assets/javascripts/application.js index 3f85f00..2fc4176 100644 --- a/www/assets/javascripts/application.js +++ b/www/assets/javascripts/application.js @@ -1,8 +1,12 @@ function init() { var ros = new ROSLIB.Ros(); - ros.connect('ws://wildthumper:9090'); + connect(); var isDragging = false; + function connect() { + ros.connect('ws://wildthumper:9090'); + } + ros.on('connection', function() { information.alerts.push({message: "Connected to websocket server.", success: true}); }); @@ -13,6 +17,9 @@ function init() { ros.on('close', function() { information.alerts.push({message: "Connection to websocket server closed.", info: true}); + setTimeout(function() { + connect(); + }, 2000); }); //tfClient.subscribe('base_link', function(tf) { @@ -182,12 +189,12 @@ function init() { Y = e.pageY; } // relative click position - var Xrel = X - this.offsetLeft - $(this).width()/2; - var Yrel = Y - this.offsetTop - $(this).height()/2; + var Xrel = X - this.getBoundingClientRect().left - $(this).width()/2; + var Yrel = Y - this.getBoundingClientRect().top - $(this).height()/2; // scale to -1..+1 var trans = -Yrel / ($(this).height()/2); var rot = -Xrel / ($(this).width()/2); - setSpeed(trans, rot*3); + setSpeed(trans*$("#scale_trans").val(), rot*$("#scale_rot").val()); } }); @@ -227,6 +234,12 @@ function init() { } }) + $(".imagelink").on('click',function(){ + // reload + $("img").attr("src", $("img").attr("src")) + }); + + $("input[type='number']").spinner(); } Vue.component('input-value', {