Commit d82afa4f authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

Add default operator script

Add operator script as well as the used map.
parent e566cfb6
{
"height": 700,
"start_AMSL": 595,
"min_lat": 45.6419,
"max_lat": 45.65,
"min_lon": 14.265,
"max_lon": 14.2766,
"flag_list": [
{
"position": {
"latitude": 45.6464947316632,
"longitude": 14.270747186236491,
"altitude": 10
},
"score": 1,
"weight": 1
}
],
"obstacle_list": [
{
"type": "box",
"position": {
"latitude": 45.6456815316444,
"longitude": 14.274667031215898,
"altitude": 15
},
"scale": {
"x": 132,
"y": 56,
"z": 10
},
"rotation": {
"x": 0,
"y": 0,
"z": 0
}
}
],
"enemy_list": [
{
"type": "EnemyDroneAPI",
"position": {
"latitude": 45.6455531,
"longitude": 14.270747186236491,
"altitude": 15
}
}
],
"initial_position": {
"latitude": 45.642813275,
"longitude": 14.270231599999988,
"altitude": 15
}
}
\ No newline at end of file
...@@ -273,20 +273,20 @@ ...@@ -273,20 +273,20 @@
}; };
me.onGetMsg = function (msg) { me.onGetMsg = function (msg) {
if (msg.hasOwnProperty("path_planning")) {
me.started = true;
console.log("running");
me.takeOff();
return me.sendMsg(JSON.stringify(
{id: me.id, inAir: true, state: "Flying", type: "state"}
));
}
var msgDict = JSON.parse(msg); var msgDict = JSON.parse(msg);
if (msgDict.hasOwnProperty("status")) { if (msgDict.hasOwnProperty("status")) {
switch (msgDict.status) { switch (msgDict.status) {
case "running":
me.started = true;
console.log("running");
me.takeOff();
me.sendMsg(JSON.stringify(
{id: me.id, inAir: true, state: "Flying", type: "state"}
));
break;
case "stopped": case "stopped":
me.stopped = true; me.stopped = true;
if (me.id === me.id_list[0]) { if (me.id === me.id_list[0]) {
...@@ -306,7 +306,7 @@ ...@@ -306,7 +306,7 @@
break; break;
default: default:
console.log("Unknown status:", me.msgDict.status); console.log("Unknown status:", msgDict.status);
} }
return; return;
} }
......
/*
* This is the default operator script. It is run by a subcriber when the
* start button of its GUI is pressed.
*/
var map = operator.getMapJSON();
operator.sendMsg({flag_positions: map.flag_list, path_planning: ""});
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
me.exit(0); me.exit(0);
break; break;
case "start": case "start":
me.sendMsg(JSON.stringify({status: "running"})); me.execOperatorScript();
break; break;
case "stop": case "stop":
me.sendMsg(JSON.stringify({status: "stopped"})); me.sendMsg(JSON.stringify({status: "stopped"}));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment