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

erp5_officejs_drone_simulator: use multicopter API

parent 1631641c
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1015.64140.4755.42274</string> </value>
<value> <string>1020.30340.52915.63897</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1713430403.75</float>
<float>1730817258.54</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -426,7 +426,7 @@ var DroneManager = /** @class */ (function () {
return;
};
DroneManager.prototype.takeOff = function () {
return this._API.takeOff();
return this._API.takeOff(this);
};
DroneManager.prototype.land = function () {
if (!this.isLanding()) {
......@@ -773,6 +773,7 @@ var GameManager = /** @class */ (function () {
}
this.APIs_dict = {
FixedWingDroneAPI: FixedWingDroneAPI,
MulticopterDroneAPI: MulticopterDroneAPI,
EnemyDroneAPI: EnemyDroneAPI
};
if (this._game_parameters_json.debug_test_mode) {
......@@ -895,21 +896,13 @@ var GameManager = /** @class */ (function () {
if (drone.team === TEAM_ENEMY) {
return;
}
function distance(a, b) {
return Math.sqrt(Math.pow((a.x - b.x), 2) + Math.pow((a.y - b.y), 2) +
Math.pow((a.z - b.z), 2));
}
if (drone.position) {
//TODO epsilon distance is 15 because of fixed wing loiter flights
//there is not a proper collision
if (distance(drone.position, flag.location) <=
this._mapManager.getMapInfo().flag_distance_epsilon) {
drone._internal_crash(new Error('Drone ' + drone.id +
' touched flag ' + flag.id), false);
if (flag.weight > 0) {
flag.weight -= 1;
drone.score += flag.score; // move score to a global place? GM, MM?
}
if (drone.colliderMesh &&
drone.colliderMesh.intersectsMesh(flag, true)) {
drone._internal_crash(new Error('Drone ' + drone.id +
' touched flag ' + flag.id), false);
if (flag.weight > 0) {
flag.weight -= 1;
drone.score += flag.score; // move score to a global place? GM, MM?
}
}
};
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1017.23888.64540.55859</string> </value>
<value> <string>1020.30714.54302.56558</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1730211399.63</float>
<float>1730822107.38</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -5,7 +5,7 @@
var MapUtils = /** @class */ (function () {
"use strict";
var FLAG_EPSILON = 15, R = 6371e3, FLAG_WEIGHT = 5, FLAG_SCORE = 5;
var R = 6371e3, FLAG_WEIGHT = 5, FLAG_SCORE = 5;
//** CONSTRUCTOR
function MapUtils(map_param) {
......@@ -27,8 +27,7 @@ var MapUtils = /** @class */ (function () {
);
_this.map_info = {
"depth": _this.map_param.depth,
"width": _this.map_param.width,
"flag_distance_epsilon": map_param.flag_distance_epsilon || FLAG_EPSILON
"width": _this.map_param.width
};
_this.map_info.height = _this.map_param.height;
_this.map_info.start_AMSL = _this.map_param.start_AMSL;
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1017.22488.12960.6280</string> </value>
<value> <string>1020.30710.25287.37376</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>1718708011.02</float>
<float>1730822161.12</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -146,7 +146,7 @@
<div class="line"></div>
<h1>Fixed Wings Drone API</h1>
<h1>Drone API</h1>
<h3>API functions</h3>
......@@ -454,7 +454,7 @@
<!-- loiter -->
<h4 class="item-name" id="loiter"><span>loiter</span><span>: void</span></h4>
<p class="item-descr">Set the drone to loiter mode, it will loiter around the target coordinates. If the given radius is inferior to LOITER_LIMIT (30), then the chosen radius will be the last accepted value when calling loiter function (100 by default).</p>
<p class="item-descr">Set the drone to loiter mode (only exists for fixed-wings drones), it will loiter around the target coordinates. If the given radius is inferior to LOITER_LIMIT (30), then the chosen radius will be the last accepted value when calling loiter function (100 by default).</p>
<div>
<h5 class="item-param-1">Param</h5>
......
......@@ -244,7 +244,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1015.13928.44848.25668</string> </value>
<value> <string>1017.23884.35535.62190</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,7 +264,7 @@
</tuple>
<state>
<tuple>
<float>1710867839.5</float>
<float>1731938073.03</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -19,6 +19,10 @@
<script type="text/javascript" src="./libraries/seedrandom.min.js"></script>
<script src="gadget_erp5_page_drone_capture_map_utils.js" type="text/javascript"></script>
<!-- API scripts -->
<script src="gadget_erp5_page_drone_capture_flag_fixedwingdrone.js" type="text/javascript"></script>
<script src="gadget_erp5_page_drone_capture_flag_multicopterdrone.js" type="text/javascript"></script>
<script src="gadget_erp5_page_drone_capture_flag_script_page.js" type="text/javascript"></script>
</head>
......
......@@ -244,7 +244,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1010.65526.46361.27613</string> </value>
<value> <string>1017.23884.35535.62190</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,7 +264,7 @@
</tuple>
<state>
<tuple>
<float>1694194019.23</float>
<float>1730801080.42</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1020.20542.569.24900</string> </value>
<value> <string>1020.51982.55228.2918</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1730211735.44</float>
<float>1732098322.73</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -6,6 +6,8 @@
var DroneLogAPI = /** @class */ (function () {
"use strict";
var TOP_SPEED = 250; //so fast that it virtually "teleports" to target
DroneLogAPI.SCRIPT_NAME =
"gadget_erp5_page_drone_simulator_dronelogfollower.js";
//** CONSTRUCTOR
function DroneLogAPI(gameManager, drone_info, flight_parameters, id) {
this._gameManager = gameManager;
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1015.64101.28159.26163</string> </value>
<value> <string>1017.23884.35535.62190</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1713425784.77</float>
<float>1730898672.15</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -85,7 +85,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>drone_simulator_fixedwingdrone_js</string> </value>
<value> <string>drone_simulator_fixed_wing_drone_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1015.64203.48820.61559</string> </value>
<value> <string>1020.30338.10759.37171</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1713429850.09</float>
<float>1730799505.92</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -376,7 +376,7 @@ var DroneManager = /** @class */ (function () {
return this._API.getClimbRate(this);
};
DroneManager.prototype.takeOff = function () {
return this._API.takeOff();
return this._API.takeOff(this);
};
DroneManager.prototype.land = function () {
if (!this.isLanding()) {
......@@ -649,7 +649,7 @@ var GameManager = /** @class */ (function () {
header_list = ["timestamp (ms)", "latitude (°)", "longitude (°)",
"AMSL (m)", "rel altitude (m)", "yaw (°)",
"ground speed (m/s)", "climb rate (m/s)"];
for (drone = 0; drone < GAMEPARAMETERS.droneList.length; drone += 1) {
for (drone = 0; drone < GAMEPARAMETERS.drone.list.length; drone += 1) {
this._flight_log[drone] = [];
this._flight_log[drone].push(header_list);
this._log_count[drone] = 0;
......@@ -671,6 +671,7 @@ var GameManager = /** @class */ (function () {
}
this.APIs_dict = {
FixedWingDroneAPI: FixedWingDroneAPI,
MulticopterDroneAPI: MulticopterDroneAPI,
DroneLogAPI: DroneLogAPI
};
if (this._game_parameters_json.debug_test_mode) {
......@@ -990,7 +991,7 @@ var GameManager = /** @class */ (function () {
_this._mapManager = new MapManager(ctx._scene, GAMEPARAMETERS.map,
GAMEPARAMETERS.initialPosition);
ctx._spawnDrones(_this._mapManager.getMapInfo().initial_position,
GAMEPARAMETERS.droneList, ctx);
GAMEPARAMETERS.drone.list, ctx);
// Hide the drone prefab
DroneManager.Prefab.isVisible = false;
//Hack to make advanced texture work
......@@ -1003,7 +1004,7 @@ var GameManager = /** @class */ (function () {
ctx._scene
);
document = documentTmp;
for (count = 0; count < GAMEPARAMETERS.droneList.length; count += 1) {
for (count = 0; count < GAMEPARAMETERS.drone.list.length; count += 1) {
controlMesh = ctx._droneList[count].infosMesh;
rect = new BABYLON.GUI.Rectangle();
rect.width = "10px";
......
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1017.23929.56045.37085</string> </value>
<value> <string>1020.23547.6727.25736</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1719320607.48</float>
<float>1730712553.54</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -19,6 +19,11 @@
<script src="gadget_global.js" type="text/javascript"></script>
<script src="domsugar.js" type="text/javascript"></script>
<!-- API scripts -->
<script src="gadget_erp5_page_drone_simulator_fixedwingdrone.js" type="text/javascript"></script>
<script src="gadget_erp5_page_drone_simulator_multicopterdrone.js" type="text/javascript"></script>
<script src="gadget_erp5_page_drone_simulator_dronelogfollower.js" type="text/javascript"></script>
<script src="gadget_erp5_page_drone_simulator_log_page.js" type="text/javascript"></script>
</head>
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <unicode>zope</unicode> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -244,7 +244,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1004.22391.16038.6980</string> </value>
<value> <string>1017.23884.35535.62190</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,7 +264,7 @@
</tuple>
<state>
<tuple>
<float>1671109341.4</float>
<float>1730898722.9</float>
<string>UTC</string>
</tuple>
</state>
......
/*jslint indent: 2, maxlen: 100*/
/*global window, rJS, domsugar, document*/
(function (window, rJS, domsugar, document) {
/*global window, rJS, domsugar, document, DroneLogAPI, FixedWingDroneAPI, MulticopterDroneAPI*/
(function (window, rJS, domsugar, document, API_LIST) {
"use strict";
var SIMULATION_SPEED = 200,
......@@ -8,16 +8,16 @@
DRAW = true,
LOG = false,
DRONE_LIST = [
{"id": 0, "type": "DroneLogAPI", "log_content": ""},
{"id": 1, "type": "DroneLogAPI", "log_content": ""}
{"id": 0, "type": API_LIST[0].name, "log_content": ""},
{"id": 1, "type": API_LIST[0].name, "log_content": ""}
],
WIDTH = 680,
HEIGHT = 340,
LOGIC_FILE_LIST = [
'gadget_erp5_page_drone_simulator_logic.js',
'gadget_erp5_page_drone_simulator_fixedwingdrone.js',
'gadget_erp5_page_drone_simulator_dronelogfollower.js'
];
'gadget_erp5_page_drone_simulator_logic.js'
].concat(API_LIST.map(function (api) {
return api.SCRIPT_NAME;
}));
rJS(window)
/////////////////////////////////////////////////////////////////
......@@ -221,7 +221,8 @@
game_parameters_json = {
"drone": {
"maxAcceleration": 1,
"maxSpeed": 1
"maxSpeed": 1,
"list": DRONE_LIST
},
"gameTime": SIMULATION_TIME,
"simulation_speed": parseFloat(options.simulation_speed),
......@@ -244,8 +245,7 @@
},
"draw_flight_path": DRAW,
"log_drone_flight": LOG,
"temp_flight_path": false,
"droneList": DRONE_LIST
"temp_flight_path": false
};
return gadget.declareGadget("babylonjs.gadget.html",
{element: fragment, scope: 'simulator'})
......@@ -295,4 +295,4 @@
});
});
}(window, rJS, domsugar, document));
\ No newline at end of file
}(window, rJS, domsugar, document, [DroneLogAPI, FixedWingDroneAPI, MulticopterDroneAPI]));
\ No newline at end of file
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1011.48769.44767.36898</string> </value>
<value> <string>1020.32016.49807.50141</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1697034365.81</float>
<float>1730900244.98</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -19,6 +19,10 @@
<script src="gadget_global.js" type="text/javascript"></script>
<script src="domsugar.js" type="text/javascript"></script>
<!-- API scripts -->
<script src="gadget_erp5_page_drone_simulator_fixedwingdrone.js" type="text/javascript"></script>
<script src="gadget_erp5_page_drone_simulator_multicopterdrone.js" type="text/javascript"></script>
<script src="gadget_erp5_page_drone_simulator_script_page.js" type="text/javascript"></script>
</head>
......@@ -35,6 +39,6 @@
data-gadget-scope="form_view_babylonjs"
data-gadget-sandbox="public">
</div>
</form>
</form>
</body>
</html>
\ No newline at end of file
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <unicode>zope</unicode> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -244,7 +244,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1004.65523.1234.17</string> </value>
<value> <string>1020.30362.56361.22715</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,7 +264,7 @@
</tuple>
<state>
<tuple>
<float>1671032907.71</float>
<float>1730800996.91</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1020.29234.48115.42939</string> </value>
<value> <string>1020.49358.42946.36915</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1730734363.63</float>
<float>1731940826.8</float>
<string>UTC</string>
</tuple>
</state>
......
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