renamed from robot_display to data_display

This commit is contained in:
Glen Turner
2015-07-01 12:51:19 -07:00
parent 4aef194cb8
commit bcdaa87d34
4 changed files with 3 additions and 3 deletions

View File

@@ -0,0 +1,33 @@
///////////////////////////////////////////////////////////////////////////////////
// Publishers
///////////////////////////////////////////////////////////////////////////////////
function publishStringExample(msg)
{
var stringMessage = new ROSLIB.Message({
data : msg
})
stringPublisherTopic.publish(stringMessage)
console.log(stringMessage)
}
////////////////////////////////////////////////////////////////
// Topics
////////////////////////////////////////////////////////////////
var stringPublisherTopic = new ROSLIB.Topic({
ros : ros,
name : 'stringPublisher',
messageType : 'std_msgs/String'
});
////////////////////////////////////////////////////////////////
// Subscribers
////////////////////////////////////////////////////////////////
stringPublisherTopic.subscribe(function(message) {
console.log("stringPublisherTopic: " + message.data)
update_sendRosMessageExample(message.data)
});

View File

@@ -0,0 +1,44 @@
function sendRosMessageExample()
{
publishStringExample(String(document.getElementById("sendRosMessageExample").value))
}
function update_sendRosMessageExample(msg)
{
document.getElementById("recievedMessageDiv").innerHTML = msg
}
function update_ProgressBar(value)
{
// This would be a great way of getting a float or int from a rosTopic and displaying it.
// I would suggest storing the data as a data field in the ros_scripts then updating it every 500 or 1000 ms rather than updating the gui every time you recieve a message
var num_string = "";
num_string = num_string.concat(value);
num_string = num_string.substring(0,4);
num_string = num_string.concat("%");
doc = document.getElementById("progressBar1");
doc.style.width = num_string;
doc.innerHTML = num_string;
if (value < 50 && value > 25 ) {
doc.className = "progress-bar progress-bar-warning";
}
else if ( value <= 25)
{
doc.className = "progress-bar progress-bar-danger";
}
else
{
doc.className = "progress-bar progress-bar-success";
}
}
window.setInterval(function(){
update_ProgressBar(Math.random() * 100);
}, 1000);