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

erp5_officejs_drone_simulator: fix timeout

See merge request nexedi/erp5!1903
parents a12d43f0 23c9f1b0
Pipeline #34541 failed with stage
in 0 seconds
......@@ -56,7 +56,7 @@ var EnemyDroneAPI = /** @class */ (function () {
/*
** Function called on every drone update, right before onUpdate AI script
*/
EnemyDroneAPI.prototype.internal_update = function (context, delta_time) {
EnemyDroneAPI.prototype.internal_position_update = function (context, delta_time) {
context._speed += context._acceleration * delta_time / 1000;
if (context._speed > context._maxSpeed) {
context._speed = context._maxSpeed;
......@@ -81,7 +81,7 @@ var EnemyDroneAPI = /** @class */ (function () {
/*
** Function called on every drone update, right after onUpdate AI script
*/
EnemyDroneAPI.prototype.internal_post_update = function (drone) {
EnemyDroneAPI.prototype.internal_info_update = function (drone) {
var _this = this, drone_position = drone.getCurrentPosition(), drone_info;
if (drone_position) {
drone_info = {
......@@ -307,6 +307,9 @@ var EnemyDroneAPI = /** @class */ (function () {
EnemyDroneAPI.prototype.getMaxHeight = function () {
return 800;
};
EnemyDroneAPI.prototype.getOnUpdateInterval = function () {
return 0;
};
EnemyDroneAPI.prototype.getFlightParameters = function () {
return this._flight_parameters;
};
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1014.60631.26636.59528</string> </value>
<value> <string>1015.63148.58654.57634</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1709288499.16</float>
<float>1713426942.44</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -6,6 +6,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
"use strict";
var DEFAULT_SPEED = 16,
PARACHUTE_SPEED = 8,
EARTH_GRAVITY = 9.81,
LOITER_LIMIT = 30,
MAX_ACCELERATION = 6,
......@@ -48,7 +49,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
throw new Error('max acceleration must be superior to 0');
}
drone._minSpeed = this.getMinSpeed();
if (drone._minSpeed <= 0) {
if (drone._minSpeed < 0) {
throw new Error('min speed must be superior to 0');
}
drone._maxSpeed = this.getMaxSpeed();
......@@ -97,9 +98,13 @@ var FixedWingDroneAPI = /** @class */ (function () {
/*
** Function called on every drone update, right before onUpdate AI script
*/
FixedWingDroneAPI.prototype.internal_update = function (context, delta_time) {
FixedWingDroneAPI.prototype.internal_position_update = function (context, delta_time) {
if (context.position.z > 0) {
this._updateSpeed(context, delta_time);
this._updatePosition(context, delta_time);
} else {
context.setDirection(0, 0, 0);
}
context._controlMesh.computeWorldMatrix(true);
context._mesh.computeWorldMatrix(true);
......@@ -107,7 +112,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
/*
** Function called on every drone update, right after onUpdate AI script
*/
FixedWingDroneAPI.prototype.internal_post_update = function (drone) {
FixedWingDroneAPI.prototype.internal_info_update = function (drone) {
var _this = this, drone_position = drone.getCurrentPosition(), drone_info;
/*if (_this._start_altitude > 0) { //TODO move start_altitude here
_this.reachAltitude(drone);
......@@ -486,8 +491,8 @@ var FixedWingDroneAPI = /** @class */ (function () {
function (altitude_diff, max_climb_rate, speed, max_pitch) {
var maxVerticalSpeed =
Math.min(altitude_diff, Math.min(max_climb_rate, speed));
return (this._toDeg(Math.asin(maxVerticalSpeed / speed)) > max_pitch) ?
speed * Math.sin(this._toRad(max_pitch))
return (this._toDeg(Math.asin(maxVerticalSpeed / speed)) > max_pitch)
? speed * Math.sin(this._toRad(max_pitch))
: maxVerticalSpeed;
};
FixedWingDroneAPI.prototype._toRad = function (angle) {
......@@ -511,11 +516,16 @@ var FixedWingDroneAPI = /** @class */ (function () {
};
FixedWingDroneAPI.prototype.land = function (drone) {
var drone_pos = drone.getCurrentPosition();
drone.setTargetCoordinates(
this._flight_parameters.drone.minSpeed = 0;
drone._speed = 0;
drone._acceleration = EARTH_GRAVITY;
this._flight_parameters.drone.maxSinkRate = PARACHUTE_SPEED;
this._flight_parameters.drone.minPitchAngle = -90;
drone._internal_setTargetCoordinates(
drone_pos.latitude,
drone_pos.longitude,
0,
drone.get3DSpeed()
-PARACHUTE_SPEED,
PARACHUTE_SPEED
);
this._is_ready_to_fly = false;
this._is_landing = true;
......@@ -538,6 +548,9 @@ var FixedWingDroneAPI = /** @class */ (function () {
FixedWingDroneAPI.prototype.getMaxHeight = function () {
return 800;
};
FixedWingDroneAPI.prototype.getOnUpdateInterval = function () {
return this._flight_parameters.drone.onUpdateInterval;
};
FixedWingDroneAPI.prototype.getFlightParameters = function () {
return this._flight_parameters;
};
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1014.60733.7318.44953</string> </value>
<value> <string>1015.64140.4755.42274</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1709564488.61</float>
<float>1713430403.75</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1014.65026.25145.27272</string> </value>
<value> <string>1016.21978.22579.46609</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1709560433.33</float>
<float>1714742387.62</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -381,6 +381,19 @@
<div class="line"></div>
<!-- getMaxCommandFrequency -->
<h4 class="item-name" id="getMaxCommandFrequency"><span>getMaxCommandFrequency</span><span>: void</span></h4>
<p class="item-descr">Get maximum frequency in hertz at which direction commands (setTargetCoordinates and loiter) can be called.</p>
<div>
<h5 class="item-param-1">Example</h5>
</div>
<p class="item-param-1">me.getMaxCommandFrequency();<br>
</p>
<div class="line"></div>
<!-- takeOff -->
<h4 class="item-name" id="takeOff"><span>takeOff</span><span>: void</span></h4>
<p class="item-descr">Trigger drone's takeoff (has only effect on multicopters as fixed wings drones need to take off manually).</p>
......
......@@ -244,7 +244,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1014.65292.62763.3464</string> </value>
<value> <string>1015.13928.44848.25668</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,7 +264,7 @@
</tuple>
<state>
<tuple>
<float>1709564153.67</float>
<float>1710867839.5</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -185,6 +185,7 @@ var OperatorAPI = /** @class */ (function () {
DRAW = true,
LOG = true,
LOG_TIME = 1662.7915426540285,
ONUPDATE_INTERVAL = 100,
LOGIC_FILE_LIST = [
'gadget_erp5_page_drone_capture_flag_logic.js',
'gadget_erp5_page_drone_capture_map_utils.js',
......@@ -566,6 +567,17 @@ var OperatorAPI = /** @class */ (function () {
"hidden": 0,
"type": "IntegerField"
},
"my_onupdate_interval": {
"description": "Minimum interval (in milliseconds) between 2 executions of onUpdate function as well as periodicity to send telemetry to the swarm",
"title": "OnUpdate interval",
"default": gadget.state.onupdate_interval,
"css_class": "",
"required": 1,
"editable": 1,
"key": "onupdate_interval",
"hidden": 0,
"type": "IntegerField"
},
"my_drone_min_speed": {
"description": "",
"title": "Drone min speed",
......@@ -708,7 +720,7 @@ var OperatorAPI = /** @class */ (function () {
form_definition: {
group_list: [[
"left",
[["my_simulation_speed"], ["my_simulation_time"],
[["my_simulation_speed"], ["my_simulation_time"], ["my_onupdate_interval"],
["my_number_of_drones"], ["my_map_seed"]]
], [
"right",
......@@ -845,6 +857,7 @@ var OperatorAPI = /** @class */ (function () {
"maxSinkRate": parseFloat(gadget.state.drone_max_sink_rate),
"maxClimbRate": parseFloat(gadget.state.drone_max_climb_rate),
"maxCommandFrequency": parseFloat(gadget.state.drone_max_command_frequency),
"onUpdateInterval": parseInt(gadget.state.onupdate_interval, 10),
"list": drone_list
},
"gameTime": parseInt(gadget.state.simulation_time, 10),
......@@ -970,6 +983,7 @@ var OperatorAPI = /** @class */ (function () {
drone_max_speed: MAX_SPEED,
drone_speed: DEFAULT_SPEED,
drone_min_speed: MIN_SPEED,
onupdate_interval: ONUPDATE_INTERVAL,
simulation_time: SIMULATION_TIME,
simulation_speed: SIMULATION_SPEED,
operator_init_msg: {},
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1014.48194.32365.65399</string> </value>
<value> <string>1016.21921.52144.47906</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1708709921.07</float>
<float>1714738877.83</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -3,8 +3,10 @@
(function (window, rJS, domsugar, document) {
"use strict";
var SIMULATION_SPEED = 10,
SIMULATION_TIME = 270,
var SIMULATION_SPEED = 1,
LOOP_INTERVAL = 1000 / 60,
ON_UPDATE_INTERVAL = LOOP_INTERVAL,
SIMULATION_TIME = LOOP_INTERVAL / 1000,
MIN_LAT = 45.6364,
MAX_LAT = 45.65,
MIN_LON = 14.2521,
......@@ -74,9 +76,10 @@
' me.getCurrentPosition().longitude\n' +
' ).toFixed(8),\n' +
' time_interval = timestamp - me.start_time,\n' +
' expected_interval = 1000 / 60,\n' +
' expected_interval = ' + LOOP_INTERVAL + ',\n' +
' expectedDistance = (me.getSpeed() * expected_interval / 1000).toFixed(8);\n' +
' assert(time_interval, Math.floor(expected_interval), "Timestamp");\n' +
' assert(time_interval.toFixed(4), expected_interval.toFixed(4), "Timestamp");\n' +
' assert(Date.now(), timestamp, "Date");\n' +
' assert(realDistance, expectedDistance, "Distance");\n' +
' current_position.latitude = current_position.latitude.toFixed(7);\n' +
' compare(current_position, {\n' +
......@@ -84,7 +87,6 @@
' longitude: me.initialPosition.longitude,\n' +
' altitude: me.initialPosition.altitude\n' +
' });\n' +
' me.exit(me.land());\n' +
'};',
DRAW = true,
LOG = true,
......@@ -120,19 +122,19 @@
"script_content": DEFAULT_SCRIPT_CONTENT};
}
map_json = {
"height": parseInt(map_height, 10),
"start_AMSL": parseFloat(start_AMSL),
"min_lat": parseFloat(MIN_LAT),
"max_lat": parseFloat(MAX_LAT),
"min_lon": parseFloat(MIN_LON),
"max_lon": parseFloat(MAX_LON),
"height": map_height,
"start_AMSL": start_AMSL,
"min_lat": MIN_LAT,
"max_lat": MAX_LAT,
"min_lon": MIN_LON,
"max_lon": MAX_LON,
"flag_list": [],
"obstacle_list" : [],
"enemy_list" : [],
"initial_position": {
"longitude": parseFloat(INIT_LON),
"latitude": parseFloat(INIT_LAT),
"altitude": parseFloat(INIT_ALT)
"longitude": INIT_LON,
"latitude": INIT_LAT,
"altitude": INIT_ALT
}
};
operator_init_msg = {
......@@ -142,20 +144,21 @@
game_parameters_json = {
"debug_test_mode": true,
"drone": {
"maxAcceleration": parseInt(MAX_ACCELERATION, 10),
"maxDeceleration": parseInt(MAX_DECELERATION, 10),
"minSpeed": parseInt(MIN_SPEED, 10),
"speed": parseFloat(DEFAULT_SPEED),
"maxSpeed": parseInt(MAX_SPEED, 10),
"maxRoll": parseFloat(MAX_ROLL),
"minPitchAngle": parseFloat(MIN_PITCH),
"maxPitchAngle": parseFloat(MAX_PITCH),
"maxSinkRate": parseFloat(MAX_SINK_RATE),
"maxClimbRate": parseFloat(MAX_CLIMB_RATE),
"maxAcceleration": MAX_ACCELERATION,
"maxDeceleration": MAX_DECELERATION,
"minSpeed": MIN_SPEED,
"speed": DEFAULT_SPEED,
"maxSpeed": MAX_SPEED,
"maxRoll": MAX_ROLL,
"minPitchAngle": MIN_PITCH,
"maxPitchAngle": MAX_PITCH,
"maxSinkRate": MAX_SINK_RATE,
"maxClimbRate": MAX_CLIMB_RATE,
"onUpdateInterval": ON_UPDATE_INTERVAL,
"list": DRONE_LIST
},
"gameTime": parseInt(SIMULATION_TIME, 10),
"simulation_speed": parseInt(SIMULATION_SPEED, 10),
"gameTime": SIMULATION_TIME,
"simulation_speed": SIMULATION_SPEED,
"latency": {
"information": 0,
"communication": 0
......@@ -214,19 +217,24 @@
})
.push(function (result) {
var div = domsugar('div', { text: "CONSOLE LOG ENTRIES:" }), lines,
l, node;
l, test_log_node = document.querySelector('.test_log');
document.querySelector('.container').parentNode.appendChild(div);
function createLogNode(message) {
function appendToTestLog(test_log_node, message) {
var log_node = document.createElement("div"),
textNode = document.createTextNode(message);
log_node.appendChild(textNode);
return log_node;
test_log_node.appendChild(log_node);
}
lines = result.console_log.split('\n');
for (l = 0; l < lines.length; l += 1) {
node = createLogNode(lines[l]);
document.querySelector('.test_log').appendChild(node);
if (lines[l] !== 'TIMEOUT!') {
appendToTestLog(test_log_node, lines[l]);
} else {
appendToTestLog(test_log_node, 'Timeout: OK');
return;
}
}
appendToTestLog(test_log_node, 'Timeout: FAILED');
}, function (error) {
return gadget.notifySubmitted({message: "Error: " + error.message,
status: 'error'});
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1014.60680.20078.34286</string> </value>
<value> <string>1015.64187.34381.50346</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1709286290.59</float>
<float>1713428877.4</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -80,7 +80,7 @@ var DroneLogAPI = /** @class */ (function () {
/*
** Function called on every drone update, right before onUpdate AI script
*/
DroneLogAPI.prototype.internal_update = function (context, delta_time) {
DroneLogAPI.prototype.internal_position_update = function (context, delta_time) {
var updateSpeed;
context._speed += context._acceleration * delta_time / 1000;
if (context._speed > context._maxSpeed) {
......@@ -104,7 +104,7 @@ var DroneLogAPI = /** @class */ (function () {
/*
** Function called on every drone update, right after onUpdate AI script
*/
DroneLogAPI.prototype.internal_post_update = function (drone) {
DroneLogAPI.prototype.internal_info_update = function (drone) {
return;
};
DroneLogAPI.prototype.internal_setTargetCoordinates =
......@@ -213,6 +213,9 @@ var DroneLogAPI = /** @class */ (function () {
DroneLogAPI.prototype.getMaxCommandFrequency = function () {
return Infinity;
};
DroneLogAPI.prototype.getOnUpdateInterval = function () {
return 0;
};
return DroneLogAPI;
}());
\ No newline at end of file
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1014.60631.26636.59528</string> </value>
<value> <string>1015.64101.28159.26163</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1709288518.39</float>
<float>1713425784.77</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -7,6 +7,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
// var TAKEOFF_RADIUS = 60,
var DEFAULT_SPEED = 16,
PARACHUTE_SPEED = 8,
EARTH_GRAVITY = 9.81,
LOITER_LIMIT = 30,
MAX_ACCELERATION = 6,
......@@ -52,7 +53,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
throw new Error('max acceleration must be superior to 0');
}
drone._minSpeed = this.getMinSpeed();
if (drone._minSpeed <= 0) {
if (drone._minSpeed < 0) {
throw new Error('min speed must be superior to 0');
}
drone._maxSpeed = this.getMaxSpeed();
......@@ -101,7 +102,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
/*
** Function called on every drone update, right before onUpdate AI script
*/
FixedWingDroneAPI.prototype.internal_update = function (context, delta_time) {
FixedWingDroneAPI.prototype.internal_position_update = function (context, delta_time) {
this._updateSpeed(context, delta_time);
this._updatePosition(context, delta_time);
......@@ -111,7 +112,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
/*
** Function called on every drone update, right after onUpdate AI script
*/
FixedWingDroneAPI.prototype.internal_post_update = function (drone) {
FixedWingDroneAPI.prototype.internal_info_update = function (drone) {
var _this = this, drone_position = drone.getCurrentPosition(), drone_info;
/*if (_this._start_altitude > 0) { //TODO move start_altitude here
_this.reachAltitude(drone);
......@@ -373,8 +374,6 @@ var FixedWingDroneAPI = /** @class */ (function () {
var processed_coordinates =
this._mapManager.convertToLocalCoordinates(lat, lon, z);
processed_coordinates.z -= this._map_dict.start_AMSL;
//this._last_altitude_point_reached = -1;
//this.takeoff_path = [];
return processed_coordinates;
};
FixedWingDroneAPI.prototype.getCurrentPosition = function (x, y, z) {
......@@ -470,11 +469,16 @@ var FixedWingDroneAPI = /** @class */ (function () {
};
FixedWingDroneAPI.prototype.land = function (drone) {
var drone_pos = drone.getCurrentPosition();
drone.setTargetCoordinates(
this._flight_parameters.drone.minSpeed = 0;
drone._speed = 0;
drone._acceleration = EARTH_GRAVITY;
this._flight_parameters.drone.maxSinkRate = PARACHUTE_SPEED;
this._flight_parameters.drone.minPitchAngle = -90;
drone._internal_setTargetCoordinates(
drone_pos.latitude,
drone_pos.longitude,
0,
drone.get3DSpeed()
PARACHUTE_SPEED
);
this._is_ready_to_fly = false;
this._is_landing = true;
......@@ -497,6 +501,9 @@ var FixedWingDroneAPI = /** @class */ (function () {
FixedWingDroneAPI.prototype.getMaxHeight = function () {
return 800;
};
FixedWingDroneAPI.prototype.getOnUpdateInterval = function () {
return this._flight_parameters.drone.onUpdateInterval;
};
FixedWingDroneAPI.prototype.getFlightParameters = function () {
return this._flight_parameters;
};
......
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1014.60733.7318.44953</string> </value>
<value> <string>1015.64203.48820.61559</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1709562449.93</float>
<float>1713429850.09</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1014.65027.38618.31573</string> </value>
<value> <string>1016.21987.28184.16844</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1709560536.57</float>
<float>1714742619.34</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -122,11 +122,13 @@
' }\n' +
' return;\n' +
' }\n' +
' me.exit(0);\n' +
' if (!me.isLanding()) { me.land() };\n' +
' if (me.getCurrentPosition().altitude <= 0) { me.exit(0) };\n' +
'};',
DRAW = true,
LOG = true,
LOG_TIME = 1662.7915426540285,
ONUPDATE_INTERVAL = 100,
DRONE_LIST = [],
WIDTH = 680,
HEIGHT = 340,
......@@ -191,6 +193,17 @@
"hidden": 0,
"type": "IntegerField"
},
"my_onupdate_interval": {
"description": "Minimum interval (in milliseconds) between 2 executions of onUpdate function as well as periodicity to send telemetry to the swarm",
"title": "OnUpdate interval",
"default": ONUPDATE_INTERVAL,
"css_class": "",
"required": 1,
"editable": 1,
"key": "onupdate_interval",
"hidden": 0,
"type": "IntegerField"
},
"my_drone_min_speed": {
"description": "",
"title": "Drone min speed",
......@@ -444,8 +457,8 @@
form_definition: {
group_list: [[
"left",
[["my_simulation_speed"], ["my_simulation_time"], ["my_number_of_drones"],
["my_minimum_latitud"], ["my_maximum_latitud"],
[["my_simulation_speed"], ["my_simulation_time"], ["my_onupdate_interval"],
["my_number_of_drones"], ["my_minimum_latitud"], ["my_maximum_latitud"],
["my_minimum_longitud"], ["my_maximum_longitud"],
["my_init_pos_lat"], ["my_init_pos_lon"], ["my_init_pos_alt"],
["my_map_height"]]
......@@ -494,7 +507,8 @@
"maxPitchAngle": parseFloat(options.drone_max_pitch),
"maxSinkRate": parseFloat(options.drone_max_sink_rate),
"maxClimbRate": parseFloat(options.drone_max_climb_rate),
"maxCommandFrequency": parseFloat(options.drone_max_command_frequency)
"maxCommandFrequency": parseFloat(options.drone_max_command_frequency),
"onUpdateInterval": parseInt(options.onupdate_interval, 10)
},
"gameTime": parseInt(options.simulation_time, 10),
"simulation_speed": parseInt(options.simulation_speed, 10),
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1014.60725.60577.24917</string> </value>
<value> <string>1015.64120.46679.6946</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1709289017.41</float>
<float>1713425712.2</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -3,11 +3,10 @@
(function (window, rJS, domsugar, document, URLSearchParams, Blob) {
"use strict";
var SIMULATION_SPEED = 10,
SIMULATION_TIME = 270,
MAP_SIZE = 600,
map_height = 700,
start_AMSL = 595,
var SIMULATION_SPEED = 1,
LOOP_INTERVAL = 1000 / 60,
ON_UPDATE_INTERVAL = LOOP_INTERVAL,
SIMULATION_TIME = LOOP_INTERVAL / 1000,
DEFAULT_SPEED = 16,
MAX_ACCELERATION = 6,
MAX_DECELERATION = 1,
......@@ -19,7 +18,6 @@
MAX_CLIMB_RATE = 8,
MAX_SINK_RATE = 3,
NUMBER_OF_DRONES = 1,
FLAG_WEIGHT = 5,
MIN_LAT = 45.6364,
MAX_LAT = 45.65,
MIN_LON = 14.2521,
......@@ -78,9 +76,10 @@
' me.getCurrentPosition().longitude\n' +
' ).toFixed(8),\n' +
' time_interval = timestamp - me.start_time,\n' +
' expected_interval = 1000 / 60,\n' +
' expected_interval = ' + LOOP_INTERVAL + ',\n' +
' expectedDistance = (me.getSpeed() * expected_interval / 1000).toFixed(8);\n' +
' assert(time_interval.toFixed(4), expected_interval.toFixed(4), "Timestamp");\n' +
' assert(Date.now(), timestamp, "Date");\n' +
' assert(realDistance, expectedDistance, "Distance");\n' +
' current_position.latitude = current_position.latitude.toFixed(7);\n' +
' compare(current_position, {\n' +
......@@ -88,7 +87,6 @@
' longitude: me.initialPosition.longitude,\n' +
' altitude: me.initialPosition.altitude\n' +
' });\n' +
' me.exit(me.land());\n' +
'};',
DRAW = true,
LOG = true,
......@@ -175,35 +173,36 @@
game_parameters_json = {
"debug_test_mode": true,
"drone": {
"maxAcceleration": parseInt(MAX_ACCELERATION, 10),
"maxDeceleration": parseInt(MAX_DECELERATION, 10),
"minSpeed": parseInt(MIN_SPEED, 10),
"speed": parseFloat(DEFAULT_SPEED),
"maxSpeed": parseInt(MAX_SPEED, 10),
"maxRoll": parseFloat(MAX_ROLL),
"minPitchAngle": parseFloat(MIN_PITCH),
"maxPitchAngle": parseFloat(MAX_PITCH),
"maxSinkRate": parseFloat(MAX_SINK_RATE),
"maxClimbRate": parseFloat(MAX_CLIMB_RATE)
"maxAcceleration": MAX_ACCELERATION,
"maxDeceleration": MAX_DECELERATION,
"minSpeed": MIN_SPEED,
"speed": DEFAULT_SPEED,
"maxSpeed": MAX_SPEED,
"maxRoll": MAX_ROLL,
"minPitchAngle": MIN_PITCH,
"maxPitchAngle": MAX_PITCH,
"maxSinkRate": MAX_SINK_RATE,
"maxClimbRate": MAX_CLIMB_RATE,
"onUpdateInterval": ON_UPDATE_INTERVAL
},
"gameTime": parseInt(SIMULATION_TIME, 10),
"simulation_speed": parseInt(SIMULATION_SPEED, 10),
"gameTime": SIMULATION_TIME,
"simulation_speed": SIMULATION_SPEED,
"latency": {
"information": 0,
"communication": 0
},
"map": {
"min_lat": parseFloat(MIN_LAT),
"max_lat": parseFloat(MAX_LAT),
"min_lon": parseFloat(MIN_LON),
"max_lon": parseFloat(MAX_LON),
"height": parseInt(HEIGHT),
"start_AMSL": parseFloat(start_AMSL)
"min_lat": MIN_LAT,
"max_lat": MAX_LAT,
"min_lon": MIN_LON,
"max_lon": MAX_LON,
"height": HEIGHT,
"start_AMSL": start_AMSL
},
"initialPosition": {
"longitude": parseFloat(INIT_LON),
"latitude": parseFloat(INIT_LAT),
"altitude": parseFloat(INIT_ALT)
"longitude": INIT_LON,
"latitude": INIT_LAT,
"altitude": INIT_ALT
},
"draw_flight_path": DRAW,
"temp_flight_path": true,
......@@ -257,19 +256,27 @@
return form_gadget.getContent();
})
.push(function (result) {
var div = domsugar('div', { text: "CONSOLE LOG ENTRIES:" });
var div = domsugar('div', { text: "CONSOLE LOG ENTRIES:" }),
lines = result.console_log.split('\n'),
line_nb,
node,
test_log_node = document.querySelector('.test_log');;
document.querySelector('.container').parentNode.appendChild(div);
function createLogNode(message) {
var node = document.createElement("div");
var textNode = document.createTextNode(message);
node.appendChild(textNode);
return node;
function appendToTestLog(test_log_node, message) {
var log_node = document.createElement("div"),
textNode = document.createTextNode(message);
log_node.appendChild(textNode);
test_log_node.appendChild(log_node);
}
for (line_nb = 0; line_nb < lines.length; line_nb += 1) {
if (lines[line_nb] !== 'TIMEOUT!') {
appendToTestLog(test_log_node, lines[line_nb]);
} else {
appendToTestLog(test_log_node, 'Timeout: OK');
return;
}
var lines = result.console_log.split('\n');
for (var i = 0;i < lines.length;i++) {
var node = createLogNode(lines[i]);
document.querySelector('.test_log').appendChild(node);
}
appendToTestLog(test_log_node, 'Timeout: FAILED');
}, function (error) {
return gadget.notifySubmitted({message: "Error: " + error.message,
status: 'error'});
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1014.60681.20667.37171</string> </value>
<value> <string>1015.64176.45813.63488</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1709286436.53</float>
<float>1713428376.53</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