renamed from robot_display to data_display
This commit is contained in:
33
data_display/js/ros_scripts.js
Normal file
33
data_display/js/ros_scripts.js
Normal 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)
|
||||
});
|
||||
44
data_display/js/update_guis.js
Normal file
44
data_display/js/update_guis.js
Normal 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);
|
||||
Reference in New Issue
Block a user