Move to subdirectory
This commit is contained in:
3
lab_ui/client/app/utilities/Node.js
Normal file
3
lab_ui/client/app/utilities/Node.js
Normal file
@@ -0,0 +1,3 @@
|
||||
function Node (name) {
|
||||
this.name = name;
|
||||
}
|
||||
12
lab_ui/client/app/utilities/Topic.js
Normal file
12
lab_ui/client/app/utilities/Topic.js
Normal file
@@ -0,0 +1,12 @@
|
||||
function Topic (name) {
|
||||
this.name = name;
|
||||
this.bag = true;
|
||||
this.type = "";
|
||||
}
|
||||
|
||||
Array.prototype.indexOfTopic = function(name) {
|
||||
for (var i = 0; i < this.length; i++)
|
||||
if (this[i].name == name)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
31
lab_ui/client/app/utilities/config.js
Normal file
31
lab_ui/client/app/utilities/config.js
Normal file
@@ -0,0 +1,31 @@
|
||||
commonControls = [{
|
||||
title : "EEF Configuration",
|
||||
buttons : [
|
||||
{
|
||||
name : "Recording",
|
||||
clickAction : "/aescape/hardware/setTrainingEEF",
|
||||
clickAttributes : {
|
||||
includeArm : true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name : "Recording",
|
||||
clickAction : "/aescape/hardware/setTrainingEEF",
|
||||
clickAttributes : {
|
||||
includeArm : true,
|
||||
},
|
||||
}
|
||||
]
|
||||
}]
|
||||
|
||||
sharedControls = {
|
||||
|
||||
}
|
||||
|
||||
leftArmControls = {
|
||||
|
||||
}
|
||||
|
||||
rightArmControls = {
|
||||
|
||||
}
|
||||
251
lab_ui/client/app/utilities/ros_scripts.js
Normal file
251
lab_ui/client/app/utilities/ros_scripts.js
Normal file
@@ -0,0 +1,251 @@
|
||||
var ros = new ROSLIB.Ros();
|
||||
|
||||
|
||||
ros.topics = Array();
|
||||
ros.nodes = Array();
|
||||
ros.recording = false;
|
||||
ros.connected = false;
|
||||
|
||||
// ros.connectionName = 'ws://192.168.1.105:9090';
|
||||
|
||||
function getQueryVariable(variable)
|
||||
{
|
||||
var query = window.location.search.substring(1);
|
||||
var vars = query.split("&");
|
||||
for (var i=0;i<vars.length;i++) {
|
||||
var pair = vars[i].split("=");
|
||||
if(pair[0] == variable){
|
||||
return pair[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var master = "localhost"
|
||||
master = getQueryVariable("master")
|
||||
if(master == null)
|
||||
{
|
||||
master = window.location.hostname
|
||||
//"localhost"
|
||||
}
|
||||
console.log('Master = ' + master);
|
||||
|
||||
ros.connectionName = 'ws://' + master + ':9090';
|
||||
// ros.connectionName = 'ws://localhost:9090';
|
||||
// ros.connectionName = 'ws://titan.aescape.co:9090';
|
||||
console.log('ros.connectionName = ' + ros.connectionName);
|
||||
|
||||
function enableUI() {
|
||||
try {
|
||||
var buttons = document.getElementById("coordinator").getElementsByTagName("button");
|
||||
for(var i = 0; i < buttons.length; i++)
|
||||
{
|
||||
buttons.item(i).classList.remove("disabled");
|
||||
}
|
||||
var checkBoxes = document.getElementById("coordinator").querySelectorAll(".pretty .state");
|
||||
for(var i = 0; i < checkBoxes.length; i++)
|
||||
{
|
||||
checkBoxes.item(i).classList.add("p-success-o");
|
||||
}
|
||||
document.querySelector('.dropdown').classList.remove("disabled");
|
||||
} catch(err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
|
||||
function disableUI() {
|
||||
try {
|
||||
var buttons = document.getElementById("coordinator").getElementsByTagName("button");
|
||||
for(var i = 0; i < buttons.length; i++)
|
||||
{
|
||||
buttons.item(i).classList.add("disabled");
|
||||
}
|
||||
var checkBoxes = document.getElementById("coordinator").querySelectorAll(".pretty .state");
|
||||
for(var i = 0; i < checkBoxes.length; i++)
|
||||
{
|
||||
checkBoxes.item(i).classList.remove("p-success-o");
|
||||
}
|
||||
document.querySelector('.dropdown').classList.add("disabled");
|
||||
|
||||
|
||||
|
||||
} catch(err) {
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
setTimeout(function(){
|
||||
disableUI();
|
||||
})
|
||||
|
||||
|
||||
// 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';
|
||||
document.getElementById("ROSNodes").innerHTML = "No Nodes Detected";
|
||||
*/
|
||||
/*
|
||||
$(document).ready(function(){
|
||||
$.notify({
|
||||
message: "Something went wrong in the connection: "+ ros.connectionName
|
||||
}, {
|
||||
"placement" : {
|
||||
from: "bottom",
|
||||
align: "right"
|
||||
},
|
||||
type: 'danger',
|
||||
delay: 1000
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
document.getElementById("ConnectionButton").innerHTML = "Connect";
|
||||
document.getElementById("ConnectionIPInput").value = ros.connectionName;
|
||||
document.getElementById("task-connection-message").innerHTML = "Disconnected"
|
||||
disableUI();
|
||||
//rosbridgeconnection_badge
|
||||
console.log(error);
|
||||
});
|
||||
// Find out exactly when we made a connection.
|
||||
ros.on('connection', function() {
|
||||
ros.connected = true;
|
||||
console.log('Connection made!');
|
||||
document.getElementById("ConnectionButton").innerHTML = "Disconnect";
|
||||
document.getElementById("ConnectionIPInput").value = ros.connectionName;
|
||||
/*
|
||||
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";
|
||||
*/
|
||||
|
||||
$(document).ready(function(){
|
||||
$.notify({
|
||||
message: "Connected to: "+ ros.connectionName
|
||||
}, {
|
||||
"placement" : {
|
||||
from: "bottom",
|
||||
align: "right"
|
||||
},
|
||||
type: 'success',
|
||||
delay: 1000
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
enableUI();
|
||||
document.getElementById("task-connection-message").innerHTML = "Connected to: " + ros.connectionName;
|
||||
getMasterName();
|
||||
|
||||
ros.nodes = Array();
|
||||
ros.topics = Array();
|
||||
|
||||
});
|
||||
|
||||
ros.on('close', function() {
|
||||
console.log('Connection closed.');
|
||||
ros.connected = false;
|
||||
|
||||
/*
|
||||
document.getElementById("ConnectionIPForm").className = "form-group has-warning has-feedback";
|
||||
document.getElementById("ConnectionIPLabel").innerHTML = 'Connection closed';
|
||||
document.getElementById("ConnectionButton").className = "btn btn-warning"
|
||||
document.getElementById("rosbridgeconnection_badge").innerHTML = 'Connection closed';
|
||||
*/
|
||||
/*
|
||||
$(document).ready(function(){
|
||||
$.notify({
|
||||
message: "Disconnected from "+ ros.connectionName
|
||||
}, {
|
||||
"placement" : {
|
||||
from: "bottom",
|
||||
align: "right"
|
||||
},
|
||||
type: 'danger',
|
||||
delay: 1000
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
document.getElementById("ConnectionButton").innerHTML = "Connect";
|
||||
document.getElementById("ConnectionIPInput").value = ros.connectionName;
|
||||
document.getElementById("task-connection-message").innerHTML = "Disconnected"
|
||||
|
||||
disableUI();
|
||||
|
||||
ros.nodes = Array();
|
||||
ros.topics = Array();
|
||||
});
|
||||
// Create a connection to the rosbridge WebSocket server.
|
||||
//ros.connect(ros.connectionName);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Functions
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// attept to connect to the ros master from the IP given orgrab it from the form
|
||||
ros.attemptConnection = function(ipAddress)
|
||||
{
|
||||
ros.close();
|
||||
if( typeof ipAddress !== "undefined")
|
||||
{
|
||||
ros.connectionName = ipAddress;
|
||||
}
|
||||
else
|
||||
{
|
||||
ros.connectionName = document.getElementById("ConnectionIPInput").value
|
||||
}
|
||||
console.log('Connection = ' + ros.connectionName);
|
||||
ros.connect(ros.connectionName);
|
||||
}
|
||||
|
||||
function toggleRecording()
|
||||
{
|
||||
if(ros.connected)
|
||||
{
|
||||
document.getElementById("recordButtonText").innerHTML = "Wait"
|
||||
document.getElementById("recordButton").className = "btn btn-warning"
|
||||
|
||||
if (!ros.recording) {
|
||||
ros.recording = true
|
||||
topicstobag = " "
|
||||
for (i = 0; i < ros.topics.length; i ++)
|
||||
{
|
||||
if (ros.topics[i].bag == true)
|
||||
{
|
||||
topicstobag = topicstobag.concat(ros.topics[i].name + " ")
|
||||
}
|
||||
}
|
||||
publishBagMessage(document.getElementById("recordText").value + topicstobag)
|
||||
} else {
|
||||
ros.recording = false
|
||||
publishBagMessage("STOP")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getMasterName()
|
||||
{
|
||||
var service = new ROSLIB.Service({
|
||||
ros : ros,
|
||||
name : '/rosapi/service_host',
|
||||
serviceType : 'rosapi/ServiceHost'
|
||||
});
|
||||
|
||||
var request = new ROSLIB.ServiceRequest({
|
||||
service: '/rosout/get_loggers' // Only the master hosts this service.
|
||||
});
|
||||
|
||||
service.callService(request, function(result) {
|
||||
document.getElementById("task-connection-message").innerHTML = "Connected to: " + result.host;
|
||||
});
|
||||
}
|
||||
101
lab_ui/client/app/utilities/update_guis.js
Normal file
101
lab_ui/client/app/utilities/update_guis.js
Normal file
@@ -0,0 +1,101 @@
|
||||
|
||||
|
||||
function updateTopicsGUI()
|
||||
{
|
||||
|
||||
ros.getTopics(function(result)
|
||||
{
|
||||
ros.topics = result;
|
||||
});
|
||||
|
||||
var topics = ros.topics;
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
ros.getNodes(function(result)
|
||||
{
|
||||
ros.nodes = result;
|
||||
});
|
||||
|
||||
var nodes = ros.nodes;
|
||||
|
||||
nodes.sort()
|
||||
|
||||
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();
|
||||
|
||||
// }, 5000);
|
||||
|
||||
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)
|
||||
|
||||
|
||||
}
|
||||
|
||||
function mylog(input)
|
||||
{
|
||||
console.log(input)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user