diff --git a/ProjectFiles/js/ros_scripts.js b/ProjectFiles/js/ros_scripts.js index 6b5c08b..8de6320 100644 --- a/ProjectFiles/js/ros_scripts.js +++ b/ProjectFiles/js/ros_scripts.js @@ -3,9 +3,11 @@ var ros = new ROSLIB.Ros(); ros.topics = []; ros.nodes = []; -ros.connectioninfo = ['ws://', '192', '168', '0', '100', '9090']; -// ros.connectionName = 'ws://localhost:9090'; +ros.recording = false; + + ros.connectionName = 'ws://192.168.0.100: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"; @@ -47,6 +49,56 @@ ros.on('close', function() { ros.connect(ros.connectionName); +/////////////////////////////////////////////////////////////////////////////////// +// Publishers +/////////////////////////////////////////////////////////////////////////////////// + +function publishBagMessage(bagFilename) +{ + var bagMessage = new ROSLIB.Message({ + data : bagFilename + }) + bagPublisher.publish(bagMessage) +} + +//////////////////////////////////////////////////////////////// +// Topics +//////////////////////////////////////////////////////////////// + +var bagPublisher = new ROSLIB.Topic({ + ros : ros, + name : 'bag_publisher', + messageType : 'std_msgs/String' +}); + +var bagNotifier = new ROSLIB.Topic({ + ros : ros, + name : 'bag_notifier', + messageType : 'std_msgs/String' +}); + +//////////////////////////////////////////////////////////////// +// Subscribers +//////////////////////////////////////////////////////////////// + + +bagNotifier.subscribe(function(message) { + if (message.data === "STARTED") { + document.getElementById("recordButtonText").innerHTML = "Stop" + document.getElementById("recordButton").className = "btn btn-danger" + } else { + document.getElementById("recordButtonText").innerHTML = "Start" + document.getElementById("recordButton").className = "btn btn-primary" + } +}); + + +/////////////////////////////////////////////////////////////////////////////////// +// Functions +/////////////////////////////////////////////////////////////////////////////////// + + + // attept to connect to the ros master from the IP given orgrab it from the form ros.attemptConnection = function(ipAddress) { @@ -113,4 +165,17 @@ function getTime() { console.log("Getting Time..."); console.log(result.time.secs); }); -}; \ No newline at end of file +}; + +function toggleRecording() +{ + document.getElementById("recordButtonText").innerHTML = "Wait" + document.getElementById("recordButton").className = "btn btn-warning" + if (!ros.recording) { + ros.recording = true + publishBagMessage(document.getElementById("recordText").value) + } else { + ros.recording = false + publishBagMessage("STOP") + } +} \ No newline at end of file diff --git a/data/_2015-06-01-12-38-44.bag b/data/_2015-06-01-12-38-44.bag new file mode 100644 index 0000000..a81b3f5 Binary files /dev/null and b/data/_2015-06-01-12-38-44.bag differ diff --git a/index.html b/index.html index ab3ff5b..aa67242 100644 --- a/index.html +++ b/index.html @@ -66,7 +66,7 @@ - +