X-Git-Url: https://defiant.homedns.org/gitweb/?p=ros_wild_thumper.git;a=blobdiff_plain;f=www%2Findex.html;h=b08e6ec89a990722b911f159a5eba04bddb48ab3;hp=4e6b5650bc3225ea157c69a65d88365f7f2cce3e;hb=fae56e6c96b9a61d41799d013bed687bed058f50;hpb=17c670f1932371d1b1ba431eb0f331507445023e;ds=sidebyside diff --git a/www/index.html b/www/index.html index 4e6b565..b08e6ec 100644 --- a/www/index.html +++ b/www/index.html @@ -28,27 +28,15 @@ var isDragging = false; ros.on('connection', function() { - $("#information").append(` -
- Connected to websocket server. -
- `); + information.alerts.push({message: "Connected to websocket server.", success: true}); }); ros.on('error', function(error) { - $("#information").append(` -
- Error connecting to websocket server. -
- `); + information.alerts.push({message: "Error connecting to websocket server.", danger: true}); }); ros.on('close', function() { - $("#information").append(` -
- Connection to websocket server closed. -
- `); + information.alerts.push({message: "Connection to websocket server closed.", info: true}); }); //tfClient.subscribe('base_link', function(tf) { @@ -71,18 +59,16 @@ }); sensorTopic.subscribe(function(message) { - sensordiv = $("#sensors") - sensordiv.find("input[name=light]").val(message.light); - sensordiv.find("input[name=temp]").val(message.temp.toFixed(1)); - sensordiv.find("input[name=humidity]").val(message.humidity); - sensordiv.find("input[name=pressure]").val(message.pressure.toFixed(1)); - sensordiv.find("input[name=co]").val(message.co); + sensors.light = message.light; + sensors.temp = message.temp.toFixed(1); + sensors.humidity = message.humidity; + sensors.pressure = message.pressure.toFixed(1); + sensors.co = message.co; }); batteryTopic.subscribe(function(message) { - powerdiv = $("#power"); - powerdiv.find("input[name=voltage]").val(message.voltage.toFixed(1)); - powerdiv.find("input[name=current]").val(message.current.toFixed(1)); + power.voltage = message.voltage.toFixed(1); + power.current = message.current.toFixed(1); }); viewer2D = new ROS2D.Viewer({ @@ -143,14 +129,13 @@ value : 0.5, slide : function(event, ui) { // Change the speed label. - $('#speed-label').html('Speed: ' + ui.value + ' m/s'); + speed_label.speed = ui.value; // Scale the speed. teleop.scale = (ui.value * 2); } }); // Set the initial speed. - $('#speed-label').html('Speed: ' + ($('#speed-slider').slider('value')) + ' m/s'); teleop.scale = ($('#speed-slider').slider('value') * 2); $('.led_color').minicolors({ @@ -219,6 +204,42 @@ setSpeed(trans, rot*3); } }); + + information = new Vue({ + el: '#information', + data: { + alerts: [], + }, + methods: { + classObject: function(id) { + return { + "alert-success": this.alerts[id].success, + "alert-danger": this.alerts[id].danger, + "alert-info": this.alerts[id].info + } + } + } + }) + + sensors = new Vue({ + el: '#sensors', + data: {light: '', temp: '', humidity: '', pressure: '', co: ''} + }) + + power = new Vue({ + el: '#power', + data: { + voltage: '', + current: '', + } + }) + + speed_label = new Vue({ + el: '#speed-label', + data: { + speed: $('#speed-slider').slider('value'), + } + }) } Wild Thumper control @@ -226,6 +247,9 @@
+
+ {{alert.message}} +
@@ -358,7 +382,7 @@
- +
@@ -392,5 +416,6 @@ +