Commit 34dd6d36 authored by Roque's avatar Roque

erp5_officejs_drone_simulator: parameters improvements

- improve log result filename
- make all drone parameter mandatory
- drop API defaults
- parameters conditions
parent b0013fa3
...@@ -41,8 +41,17 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -41,8 +41,17 @@ var FixedWingDroneAPI = /** @class */ (function () {
*/ */
FixedWingDroneAPI.prototype.internal_start = function (drone) { FixedWingDroneAPI.prototype.internal_start = function (drone) {
drone._maxDeceleration = this.getMaxDeceleration(); drone._maxDeceleration = this.getMaxDeceleration();
if (drone._maxDeceleration <= 0) {
throw new Error('max deceleration must be superior to 0');
}
drone._maxAcceleration = this.getMaxAcceleration(); drone._maxAcceleration = this.getMaxAcceleration();
if (drone._maxAcceleration <= 0) {
throw new Error('max acceleration must be superior to 0');
}
drone._minSpeed = this.getMinSpeed(); drone._minSpeed = this.getMinSpeed();
if (drone._minSpeed <= 0) {
throw new Error('min speed must be superior to 0');
}
drone._maxSpeed = this.getMaxSpeed(); drone._maxSpeed = this.getMaxSpeed();
if (drone._minSpeed > drone._maxSpeed) { if (drone._minSpeed > drone._maxSpeed) {
throw new Error('min speed cannot be superior to max speed'); throw new Error('min speed cannot be superior to max speed');
...@@ -52,16 +61,31 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -52,16 +61,31 @@ var FixedWingDroneAPI = /** @class */ (function () {
throw new Error('Drone speed must be between min speed and max speed'); throw new Error('Drone speed must be between min speed and max speed');
} }
drone._minPitchAngle = this.getMinPitchAngle(); drone._minPitchAngle = this.getMinPitchAngle();
if (drone._minPitchAngle >= 0) {
throw new Error('min pitch angle must be inferior to 0');
}
drone._maxPitchAngle = this.getMaxPitchAngle(); drone._maxPitchAngle = this.getMaxPitchAngle();
if (drone._maxPitchAngle <= 0) {
throw new Error('max pitch angle must be superior to 0');
}
if (drone._minPitchAngle > drone._maxPitchAngle) { if (drone._minPitchAngle > drone._maxPitchAngle) {
throw new Error('min pitch angle cannot be superior to max pitch angle'); throw new Error('min pitch angle cannot be superior to max pitch angle');
} }
drone._maxRollAngle = this.getMaxRollAngle(); drone._maxRollAngle = this.getMaxRollAngle();
if (drone._maxRollAngle <= 0) {
throw new Error('max roll angle must be superior to 0');
}
drone._maxSinkRate = this.getMaxSinkRate(); drone._maxSinkRate = this.getMaxSinkRate();
if (drone._maxSinkRate <= 0) {
throw new Error('max sink rate must be superior to 0');
}
if (drone._maxSinkRate > drone._maxSpeed) { if (drone._maxSinkRate > drone._maxSpeed) {
throw new Error('max sink rate cannot be superior to max speed'); throw new Error('max sink rate cannot be superior to max speed');
} }
drone._maxClimbRate = this.getMaxClimbRate(); drone._maxClimbRate = this.getMaxClimbRate();
if (drone._maxClimbRate <= 0) {
throw new Error('max climb rate must be superior to 0');
}
if (drone._maxClimbRate > drone._maxSpeed) { if (drone._maxClimbRate > drone._maxSpeed) {
throw new Error('max climb rate cannot be superior to max speed'); throw new Error('max climb rate cannot be superior to max speed');
} }
...@@ -417,34 +441,34 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -417,34 +441,34 @@ var FixedWingDroneAPI = /** @class */ (function () {
return null; return null;
}; };
FixedWingDroneAPI.prototype.getMinSpeed = function () { FixedWingDroneAPI.prototype.getMinSpeed = function () {
return this._flight_parameters.drone.minSpeed || MIN_SPEED; return this._flight_parameters.drone.minSpeed;
}; };
FixedWingDroneAPI.prototype.getMaxSpeed = function () { FixedWingDroneAPI.prototype.getMaxSpeed = function () {
return this._flight_parameters.drone.maxSpeed || MAX_SPEED; return this._flight_parameters.drone.maxSpeed;
}; };
FixedWingDroneAPI.prototype.getInitialSpeed = function () { FixedWingDroneAPI.prototype.getInitialSpeed = function () {
return this._flight_parameters.drone.speed || DEFAULT_SPEED; return this._flight_parameters.drone.speed;
}; };
FixedWingDroneAPI.prototype.getMaxDeceleration = function () { FixedWingDroneAPI.prototype.getMaxDeceleration = function () {
return this._flight_parameters.drone.maxDeceleration || MAX_DECELERATION; return this._flight_parameters.drone.maxDeceleration;
}; };
FixedWingDroneAPI.prototype.getMaxAcceleration = function () { FixedWingDroneAPI.prototype.getMaxAcceleration = function () {
return this._flight_parameters.drone.maxAcceleration || MAX_ACCELERATION; return this._flight_parameters.drone.maxAcceleration;
}; };
FixedWingDroneAPI.prototype.getMinPitchAngle = function () { FixedWingDroneAPI.prototype.getMinPitchAngle = function () {
return this._flight_parameters.drone.minPitchAngle || MIN_PITCH; return this._flight_parameters.drone.minPitchAngle;
}; };
FixedWingDroneAPI.prototype.getMaxPitchAngle = function () { FixedWingDroneAPI.prototype.getMaxPitchAngle = function () {
return this._flight_parameters.drone.maxPitchAngle || MAX_PITCH; return this._flight_parameters.drone.maxPitchAngle;
}; };
FixedWingDroneAPI.prototype.getMaxRollAngle = function () { FixedWingDroneAPI.prototype.getMaxRollAngle = function () {
return this._flight_parameters.drone.maxRoll || MAX_ROLL; return this._flight_parameters.drone.maxRoll;
}; };
FixedWingDroneAPI.prototype.getMaxSinkRate = function () { FixedWingDroneAPI.prototype.getMaxSinkRate = function () {
return this._flight_parameters.drone.maxSinkRate || MAX_SINK_RATE; return this._flight_parameters.drone.maxSinkRate;
}; };
FixedWingDroneAPI.prototype.getMaxClimbRate = function () { FixedWingDroneAPI.prototype.getMaxClimbRate = function () {
return this._flight_parameters.drone.maxClimbRate || MAX_CLIMB_RATE; return this._flight_parameters.drone.maxClimbRate;
}; };
FixedWingDroneAPI.prototype.getMaxOrientation = function () { FixedWingDroneAPI.prototype.getMaxOrientation = function () {
//TODO should be a game parameter (but how to force value to PI quarters?) //TODO should be a game parameter (but how to force value to PI quarters?)
......
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1006.17822.27350.61713</string> </value> <value> <string>1006.23750.47435.55654</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1676035583.95</float> <float>1676554628.54</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -194,7 +194,7 @@ ...@@ -194,7 +194,7 @@
"title": "Drone min speed", "title": "Drone min speed",
"default": MIN_SPEED, "default": MIN_SPEED,
"css_class": "", "css_class": "",
"required": 0, "required": 1,
"editable": 1, "editable": 1,
"key": "drone_min_speed", "key": "drone_min_speed",
"hidden": 0, "hidden": 0,
...@@ -205,7 +205,7 @@ ...@@ -205,7 +205,7 @@
"title": "Drone speed", "title": "Drone speed",
"default": DEFAULT_SPEED, "default": DEFAULT_SPEED,
"css_class": "", "css_class": "",
"required": 0, "required": 1,
"editable": 1, "editable": 1,
"key": "drone_speed", "key": "drone_speed",
"hidden": 0, "hidden": 0,
...@@ -216,7 +216,7 @@ ...@@ -216,7 +216,7 @@
"title": "Drone max speed", "title": "Drone max speed",
"default": MAX_SPEED, "default": MAX_SPEED,
"css_class": "", "css_class": "",
"required": 0, "required": 1,
"editable": 1, "editable": 1,
"key": "drone_max_speed", "key": "drone_max_speed",
"hidden": 0, "hidden": 0,
...@@ -227,7 +227,7 @@ ...@@ -227,7 +227,7 @@
"title": "Drone max Acceleration", "title": "Drone max Acceleration",
"default": MAX_ACCELERATION, "default": MAX_ACCELERATION,
"css_class": "", "css_class": "",
"required": 0, "required": 1,
"editable": 1, "editable": 1,
"key": "drone_max_acceleration", "key": "drone_max_acceleration",
"hidden": 0, "hidden": 0,
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
"title": "Drone max Deceleration", "title": "Drone max Deceleration",
"default": MAX_DECELERATION, "default": MAX_DECELERATION,
"css_class": "", "css_class": "",
"required": 0, "required": 1,
"editable": 1, "editable": 1,
"key": "drone_max_deceleration", "key": "drone_max_deceleration",
"hidden": 0, "hidden": 0,
...@@ -249,7 +249,7 @@ ...@@ -249,7 +249,7 @@
"title": "Drone max roll", "title": "Drone max roll",
"default": MAX_ROLL, "default": MAX_ROLL,
"css_class": "", "css_class": "",
"required": 0, "required": 1,
"editable": 1, "editable": 1,
"key": "drone_max_roll", "key": "drone_max_roll",
"hidden": 0, "hidden": 0,
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
"title": "Drone min pitch", "title": "Drone min pitch",
"default": MIN_PITCH, "default": MIN_PITCH,
"css_class": "", "css_class": "",
"required": 0, "required": 1,
"editable": 1, "editable": 1,
"key": "drone_min_pitch", "key": "drone_min_pitch",
"hidden": 0, "hidden": 0,
...@@ -271,7 +271,7 @@ ...@@ -271,7 +271,7 @@
"title": "Drone max pitch", "title": "Drone max pitch",
"default": MAX_PITCH, "default": MAX_PITCH,
"css_class": "", "css_class": "",
"required": 0, "required": 1,
"editable": 1, "editable": 1,
"key": "drone_max_pitch", "key": "drone_max_pitch",
"hidden": 0, "hidden": 0,
...@@ -282,7 +282,7 @@ ...@@ -282,7 +282,7 @@
"title": "Drone max sink rate", "title": "Drone max sink rate",
"default": MAX_SINK_RATE, "default": MAX_SINK_RATE,
"css_class": "", "css_class": "",
"required": 0, "required": 1,
"editable": 1, "editable": 1,
"key": "drone_max_sink_rate", "key": "drone_max_sink_rate",
"hidden": 0, "hidden": 0,
...@@ -293,7 +293,7 @@ ...@@ -293,7 +293,7 @@
"title": "Drone max climb rate", "title": "Drone max climb rate",
"default": MAX_CLIMB_RATE, "default": MAX_CLIMB_RATE,
"css_class": "", "css_class": "",
"required": 0, "required": 1,
"editable": 1, "editable": 1,
"key": "drone_max_climb_rate", "key": "drone_max_climb_rate",
"hidden": 0, "hidden": 0,
...@@ -563,9 +563,15 @@ ...@@ -563,9 +563,15 @@
text: 'Download Simulation LOG ' + i, text: 'Download Simulation LOG ' + i,
download: 'simulation_log_' + i download: 'simulation_log_' + i
+ '_speed_' + game_parameters_json.drone.speed + '_speed_' + game_parameters_json.drone.speed
+ '_min-speed_' + game_parameters_json.drone.minSpeed
+ '_max-speed_' + game_parameters_json.drone.maxSpeed
+ '_max-accel_' + game_parameters_json.drone.maxAcceleration
+ '_max-decel_' + game_parameters_json.drone.maxDeceleration
+ '_max-roll_' + game_parameters_json.drone.maxRoll + '_max-roll_' + game_parameters_json.drone.maxRoll
+ '_min-pitch_' + game_parameters_json.drone.minPitchAngle + '_min-pitch_' + game_parameters_json.drone.minPitchAngle
+ '_max-pitch_' + game_parameters_json.drone.maxPitchAngle + '_max-pitch_' + game_parameters_json.drone.maxPitchAngle
+ '_max-sink_' + game_parameters_json.drone.maxSinkRate
+ '_max-climb_' + game_parameters_json.drone.maxClimbRate
+ '.txt', + '.txt',
href: window.URL.createObjectURL(blob) href: window.URL.createObjectURL(blob)
}); });
......
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1006.17791.59880.25668</string> </value> <value> <string>1006.22396.42884.34816</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -262,7 +262,7 @@ ...@@ -262,7 +262,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1676033282.59</float> <float>1676390684.63</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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