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 @@ ...@@ -19,6 +19,8 @@
<script src="./js-yaml/dist/js-yaml.min.js"></script> <script src="./js-yaml/dist/js-yaml.min.js"></script>
<link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="style.css">
<script> <script>
document.title="ADC GUI"; document.title="ADC GUI";
...@@ -91,7 +93,7 @@ ...@@ -91,7 +93,7 @@
action_goal.send(); action_goal.send();
document.getElementById("action_info").innerHTML = "Goal sent. Expecting feedback..."; 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(); feedback_watchdog_timer();
//action_running=true; //true when received feedback? //action_running=true; //true when received feedback?
...@@ -286,28 +288,43 @@ ...@@ -286,28 +288,43 @@
} }
},2000); },2000);
} }
function load_goals_from_yaml() function load_goals_from_yaml()
{ {
goals_file = document.getElementById("goals_file").value; document.getElementById("goals_info").innerHTML = "Loading file";
var goals_from_yaml; document.getElementById("goals_info").style.backgroundColor = 'yellow' ;
goals_file = document.getElementById("goals_file").value;
var goals_from_yaml;
$.get(goals_file).done(function (data) $.ajax(
//$.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(
{ {
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 $(document).ready
...@@ -382,6 +399,8 @@ ...@@ -382,6 +399,8 @@
<input type="text" id="goals_file" value="./data/goals0.yaml" onchange="load_goals_from_yaml()"/> <input type="text" id="goals_file" value="./data/goals0.yaml" onchange="load_goals_from_yaml()"/>
<br> <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>--> <!--<button class="btn btn-primary" id = "load_goals_button" onclick = "load_goals_from_yaml()">Load goals</button>-->
<hr> <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