var ros = new ROSLIB.Ros(); ros.connectionName = 'ws://192.168.1.102:9090'; // ros.connectionName = 'ws://localhost:9090'; // If there is an error on the backend, an 'error' emit will be emitted. ros.on('error', function(error) { document.getElementById("ConnectionIPForm").className = "form-group has-warning has-feedback"; document.getElementById("ConnectionIPInput").value = ros.connectionName; document.getElementById("ConnectionIPLabel").innerHTML = 'No connection'; document.getElementById("ConnectionButton").className = "btn btn-warning" console.log(error); }); // Find out exactly when we made a connection. ros.on('connection', function() { console.log('Connection made!'); document.getElementById("ConnectionIPForm").className = "form-group has-success has-feedback"; document.getElementById("ConnectionIPInput").value = ros.connectionName; document.getElementById("ConnectionIPLabel").innerHTML = 'Connection made at:'; document.getElementById("ConnectionButton").className = "btn btn-success" }); ros.on('close', function() { console.log('Connection closed.'); }); // Create a connection to the rosbridge WebSocket server. ros.connect(ros.connectionName); // attept to connect to the ros master from the IP given orgrab it from the form ros.attemptConnection = function(ipAddress) { if( typeof ipAddress !== "undefined") { ros.connectionName = ipAddress; } else { ros.connectionName = document.getElementById("ConnectionIPInput").value } console.log('Connection = ' + ros.connectionName); ros.connect(ros.connectionName); } // LISTENER /// var voltageListener = new ROSLIB.Topic({ ros : ros, name : '/asctec/LL_STATUS', messageType : '/asctec_msgs/LLStatus' }); voltageListener.subscribe(function(message) { updateVoltage(message.battery_voltage_1/1000); updateUpTime(message.up_time) });