Added talker.py and ability to bag files
This commit is contained in:
@@ -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);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user