moved files around to make it more user friendly
This commit is contained in:
25
ProjectFiles/HTML/RobotDisplayPanel.html
Normal file
25
ProjectFiles/HTML/RobotDisplayPanel.html
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
<div id="content">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
Example Pannel Heading My Changes
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<label class="col-sm-2"> Bar Title </label>
|
||||
<div class="progress">
|
||||
<div id="progressBar1" class="progress-bar progress-bar-striped active" role="progressbar"
|
||||
aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:100%" >
|
||||
No data recieved yet. </div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<label class="col-sm-2"> Up Time (s): </label>
|
||||
<div class="col-sm-1" id="UpTime">
|
||||
N/A
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
100
ProjectFiles/js/ros_scripts.js
Normal file
100
ProjectFiles/js/ros_scripts.js
Normal file
@@ -0,0 +1,100 @@
|
||||
var ros = new ROSLIB.Ros();
|
||||
|
||||
ros.connectioninfo = ['ws://', '192', '168', '0', '100', '9090'];
|
||||
// ros.connectionName = 'ws://localhost:9090';
|
||||
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";
|
||||
document.getElementById("ConnectionIPInput").value = ros.connectionName;
|
||||
document.getElementById("ConnectionIPLabel").innerHTML = 'No connection';
|
||||
document.getElementById("ConnectionButton").className = "btn btn-warning"
|
||||
document.getElementById("rosbridgeconnection_badge").innerHTML = 'No connection';
|
||||
|
||||
rosbridgeconnection_badge
|
||||
console.log(error);192
|
||||
});
|
||||
// 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("rosbridgeconnection_badge").innerHTML = 'Connected';
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
function getTopics() {
|
||||
|
||||
var topicsClient = new ROSLIB.Service({
|
||||
ros : ros,
|
||||
name : '/rosapi/topics',
|
||||
serviceType : '/rosapi/Topics'
|
||||
});
|
||||
|
||||
var request = new ROSLIB.ServiceRequest();
|
||||
|
||||
topicsClient.callService(request, function(result) {
|
||||
ros.topics = result.topics;
|
||||
});
|
||||
|
||||
return ros.topics
|
||||
};
|
||||
|
||||
function getNodes() {
|
||||
|
||||
var topicsClient = new ROSLIB.Service({
|
||||
ros : ros,
|
||||
name : '/rosapi/nodes',
|
||||
serviceType : '/rosapi/nodes'
|
||||
});
|
||||
|
||||
var request = new ROSLIB.ServiceRequest();
|
||||
|
||||
topicsClient.callService(request, function(result) {
|
||||
ros.nodes = result.nodes;
|
||||
});
|
||||
|
||||
return ros.nodes
|
||||
};
|
||||
|
||||
function getTime() {
|
||||
|
||||
var topicsClient = new ROSLIB.Service({
|
||||
ros : ros,
|
||||
name : '/rosapi/get_time',
|
||||
serviceType : '/rosapi/GetTime'
|
||||
});
|
||||
|
||||
var request = new ROSLIB.ServiceRequest({});
|
||||
|
||||
topicsClient.callService(request, function(result) {
|
||||
console.log("Getting Time...");
|
||||
console.log(result.time.secs);
|
||||
});
|
||||
};
|
||||
113
ProjectFiles/js/update_guis.js
Normal file
113
ProjectFiles/js/update_guis.js
Normal file
@@ -0,0 +1,113 @@
|
||||
|
||||
|
||||
|
||||
function updateVoltage(voltage)
|
||||
{
|
||||
|
||||
var voltage_min = 9.5;
|
||||
var voltage_max = 12.5;
|
||||
var voltage_range = voltage_max - voltage_min;
|
||||
|
||||
var voltage_percentage = (voltage - voltage_min) / voltage_range * 100;
|
||||
|
||||
var voltage_string = "";
|
||||
voltage_string = voltage_string.concat(voltage_percentage);
|
||||
voltage_string = voltage_string.substring(0,4);
|
||||
voltage_string = voltage_string.concat('%');
|
||||
|
||||
document.getElementById("VoltageDisplay").style.width = voltage_string;
|
||||
document.getElementById("VoltageDisplay").innerHTML = voltage_string;
|
||||
|
||||
if (voltage_percentage < 50 && voltage_percentage > 25 ) {
|
||||
document.getElementById("VoltageDisplay").className = "progress-bar progress-bar-warning"
|
||||
}
|
||||
else if ( voltage_percentage <= 25)
|
||||
{
|
||||
document.getElementById("VoltageDisplay").className = "progress-bar progress-bar-danger"
|
||||
var sound = document.getElementById("audio");
|
||||
sound.play()
|
||||
console.log("Pay Sound")
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById("VoltageDisplay").className = "progress-bar progress-bar-success"
|
||||
}
|
||||
};
|
||||
|
||||
function updateTopicsGUI()
|
||||
{
|
||||
|
||||
topics = getTopics()
|
||||
if(topics != null){
|
||||
var innerHTML = "";
|
||||
for (var i = 0; i < topics.length; i++ )
|
||||
{
|
||||
innerHTML = innerHTML.concat(topics[i]);
|
||||
innerHTML = innerHTML.concat("<br>");
|
||||
}
|
||||
document.getElementById("ROSTopics").innerHTML = innerHTML;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function updateNodesGUI()
|
||||
{
|
||||
|
||||
nodes = getNodes()
|
||||
if(nodes != null){
|
||||
var innerHTML = "";
|
||||
for (var i = 0; i < nodes.length; i++ )
|
||||
{
|
||||
innerHTML = innerHTML.concat(nodes[i]);
|
||||
innerHTML = innerHTML.concat("<br>");
|
||||
}
|
||||
document.getElementById("ROSNodes").innerHTML = innerHTML;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
window.setInterval(function(){
|
||||
updateTopicsGUI()
|
||||
updateNodesGUI()
|
||||
}, 500);
|
||||
|
||||
function validateForm()
|
||||
{
|
||||
ros.attemptConnection();
|
||||
return false;
|
||||
};
|
||||
|
||||
function addInputsForConnection()
|
||||
{
|
||||
|
||||
var innerHTML = "";
|
||||
|
||||
for (var i = 0; i < ros.connectioninfo.length; i ++)
|
||||
{
|
||||
|
||||
console.log(ros.connectioninfo[i])
|
||||
el = document.getElementById("ConnectionInformation")
|
||||
|
||||
innerHTML = innerHTML.concat("<span class=\"col-sm-1\">");
|
||||
innerHTML = innerHTML.concat("<input type=\"text\" class=\"form-control\" value=\"");
|
||||
innerHTML = innerHTML.concat(ros.connectioninfo[i])
|
||||
innerHTML = innerHTML.concat("\"/>")
|
||||
innerHTML = innerHTML.concat("</span>")
|
||||
if(i >0 && i < 4)
|
||||
{
|
||||
innerHTML = innerHTML.concat("<span class=\"col-sxm-1\">.</span>")
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
el.innerHTML = innerHTML;
|
||||
|
||||
console.log(innerHTML)
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user