www: reconnect after error
authorErik Andresen <erik@vontaene.de>
Fri, 28 Dec 2018 10:50:14 +0000 (11:50 +0100)
committerErik Andresen <erik@vontaene.de>
Fri, 28 Dec 2018 10:50:14 +0000 (11:50 +0100)
www/assets/javascripts/application.js
www/index.html

index 3f85f00..a7b4785 100644 (file)
@@ -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) {
@@ -227,6 +234,10 @@ function init() {
                }
        })
 
+       $(".imagelink").on('click',function(){
+               // reload
+               $("img").attr("src", $("img").attr("src"))
+       });
 }
 
 Vue.component('input-value', {
index 8376405..7a86765 100644 (file)
@@ -47,6 +47,9 @@
                                        <li class="nav-item">
                                                <a class="nav-link" href="#drive" data-toggle="tab" role="tab">Drive</a>
                                        </li>
+                                       <li class="nav-item">
+                                               <a class="nav-link imagelink" href="#image" data-toggle="tab" role="tab">Image</a>
+                                       </li>
                                </ul>
                        </nav>
 
                                <div id="drive" class="tab-pane" role="tabpanel">
                                        <div class="cmd_vel_circle"></div>
                                </div>
+                               <div id="image" class="tab-pane" role="tabpanel">
+                                       <img id="usb_cam" src="http://wildthumper:8080/stream?topic=/usb_cam/image_raw" style="transform:rotate(-90deg); transform-origin: 60% 60%;"></img>
+                               </div>
                        </div>
                </div>
        </body>