Skip to content
Snippets Groups Projects
Commit 3a9d6bc2 authored by Fernando Herrero's avatar Fernando Herrero
Browse files

Manage error when loading yaml file

parent 2c3523fe
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,8 @@
<script src="./js-yaml/dist/js-yaml.min.js"></script>
<link rel="stylesheet" href="style.css">
<script>
document.title="ADC GUI";
......@@ -91,7 +93,7 @@
action_goal.send();
document.getElementById("action_info").innerHTML = "Goal sent. Expecting feedback...";
document.getElementById("action_info").style.backgroundColor = 'white' ;
document.getElementById("action_info").style.backgroundColor = 'yellow' ;
feedback_watchdog_timer();
//action_running=true; //true when received feedback?
......@@ -286,28 +288,43 @@
}
},2000);
}
function load_goals_from_yaml()
{
goals_file = document.getElementById("goals_file").value;
var goals_from_yaml;
document.getElementById("goals_info").innerHTML = "Loading file";
document.getElementById("goals_info").style.backgroundColor = 'yellow' ;
goals_file = document.getElementById("goals_file").value;
var goals_from_yaml;
$.get(goals_file).done(function (data)
//$.get( goals_file, function( data )
{
goals_from_yaml = jsyaml.load( data );
//TODO: check if loaded succesfully or not
//console.log("Loaded goals");
goal_array_msg = new ROSLIB.Message(
$.ajax(
{
goals: goals_from_yaml
});
url: goals_file,
success:
function(result)
{
goals_from_yaml = jsyaml.load( result );
goals_loaded=true;
goal_array_msg = new ROSLIB.Message(
{
goals: goals_from_yaml
});
});
goals_loaded=true;
document.getElementById("goals_info").innerHTML = "Loaded";
document.getElementById("goals_info").style.backgroundColor = 'green' ;
document.getElementById('startStop').disabled=false;
},
error:
function (xhr, ajaxOptions, thrownError)
{
//alert(xhr.status);
//alert(thrownError);
document.getElementById("goals_info").innerHTML = "Error loading file";
document.getElementById("goals_info").style.backgroundColor = 'red' ;
document.getElementById('startStop').disabled=true;
}
}
);
}
$(document).ready
......@@ -382,6 +399,8 @@
<input type="text" id="goals_file" value="./data/goals0.yaml" onchange="load_goals_from_yaml()"/>
<br>
<span id="goals_info" >&nbsp</span>
<br>
<!--<button class="btn btn-primary" id = "load_goals_button" onclick = "load_goals_from_yaml()">Load goals</button>-->
<hr>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment