Commit cbf008fa authored by Roque's avatar Roque

erp5_officejs_drone_capture_flag: new script operator feature and more

- add a new operator script editor
- update finish rules and scoring system
- refactor map parameters
- map randomization is done now by new class map utils
- update init flag info msg
- import/export script feature
- update web site CSP
- ui: activate js syntax in user script editor
- ui: styles, section titles, etc - doc api update
- fixes/refactoring
-- fix default target coordinates bug
-- control empty/invalid user scripts
-- raise an error on user script syntax error
-- fix onUpdate timestamp parameter (to integer milliseconds)
-- fix drone loiter (based on !1817/)
parent 41270486
...@@ -36,7 +36,6 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -36,7 +36,6 @@ var FixedWingDroneAPI = /** @class */ (function () {
** Function called on start phase of the drone, just before onStart AI script ** Function called on start phase of the drone, just before onStart AI script
*/ */
FixedWingDroneAPI.prototype.internal_start = function (drone) { FixedWingDroneAPI.prototype.internal_start = function (drone) {
drone._targetCoordinates = drone.getCurrentPosition();
drone._maxDeceleration = this.getMaxDeceleration(); drone._maxDeceleration = this.getMaxDeceleration();
if (drone._maxDeceleration <= 0) { if (drone._maxDeceleration <= 0) {
throw new Error('max deceleration must be superior to 0'); throw new Error('max deceleration must be superior to 0');
...@@ -194,6 +193,7 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -194,6 +193,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
distance, distance,
distanceCos, distanceCos,
distanceSin, distanceSin,
distanceToTarget,
currentSinLat, currentSinLat,
currentLonRad, currentLonRad,
groundSpeed, groundSpeed,
...@@ -205,11 +205,19 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -205,11 +205,19 @@ var FixedWingDroneAPI = /** @class */ (function () {
verticalSpeed, verticalSpeed,
yawToDirection; yawToDirection;
if (this._loiter_mode && Math.sqrt( if (this._loiter_mode) {
Math.pow(drone._targetCoordinates.x - drone.position.x, 2) + distanceToTarget = Math.sqrt(
Math.pow(drone._targetCoordinates.y - drone.position.y, 2) Math.pow(drone._targetCoordinates.x - drone.position.x, 2)
) <= this._loiter_radius) { + Math.pow(drone._targetCoordinates.y - drone.position.y, 2)
newYaw = bearing - 90; );
if (Math.abs(distanceToTarget - this._loiter_radius) <= 1) {
newYaw = bearing - 90;
} else if (distanceToTarget < this._loiter_radius) {
newYaw = bearing - 135;
} else {
newYaw = this._getNewYaw(drone, bearing, delta_time);
}
} else { } else {
newYaw = this._getNewYaw(drone, bearing, delta_time); newYaw = this._getNewYaw(drone, bearing, delta_time);
} }
......
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1010.35063.25322.10700</string> </value> <value> <string>1010.45437.13560.55142</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1692366624.83</float> <float>1692989145.27</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1010.23697.26501.43008</string> </value> <value> <string>1010.55458.31149.16742</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1691684378.73</float> <float>1693590015.02</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -10,6 +10,67 @@ ...@@ -10,6 +10,67 @@
<div class="documentation"> <div class="documentation">
<h1>Game specifications</h1>
<h3>Start message with information about the flags</h3>
<!-- Flag message -->
<h4 class="item-name" id="flag_msg"><span>msg.flag_positions</span><span>: list</span></h4>
<p class="item-descr">List containing an information dictionary for each flag in the map</p>
<div>
<h5 class="item-param-1">Flag info dictionary:</h5>
<p class="item-descr"></p>
</div>
<div>
<h5 class="item-param-1">Param</h5>
<h5 class="item-param-2">Description</h5>
</div>
<div>
<p class="item-param-1">id: Integer</p>
<p class="item-param-2">Flag id</p>
</div>
<div>
<p class="item-param-1">score: Integer</p>
<p class="item-param-2">Flag score for hit</p>
</div>
<div>
<p class="item-param-1">weight: Integer</p>
<p class="item-param-2">Flag weight, number of hits to be captured</p>
</div>
<div>
<p class="item-param-1">position: dictionary</p>
<p class="item-param-2">
{<br>
&nbsp;&nbsp;x: number, //latitude (in degrees)<br>
&nbsp;&nbsp;y: number, //longitude (in degrees)<br>
&nbsp;&nbsp;z: number //altitude (in meters)<br>
}<br>
</p>
</div>
<div class="line"></div>
<h3>Game scoring</h3>
<!-- Scoring -->
<h4 class="item-name" id="scoring"><span>Score</span></h4>
<p class="item-descr">Every flag has a score, every drone hit on the flag will give it that score value.</p>
<p class="item-descr">The number of hits on a flag is determined by its weight.</p>
<p class="item-descr">Once the number of hits is equal to the flag weight, no more score will be given on following hits.</p>
<p class="item-descr">Total score is the sum of all drones score when the game finishes.</p>
<h5 class="item-param-1">Example</h5>
<p class="item-example">A flag with score=3 and weight=2 will grant 3 score points on every drone hit, up to 2 hits.</p>
<div class="line"></div>
<h1>Fixed Wings Drone API</h1> <h1>Fixed Wings Drone API</h1>
<h3>API functions</h3> <h3>API functions</h3>
...@@ -442,7 +503,7 @@ ...@@ -442,7 +503,7 @@
<!-- id --> <!-- id -->
<h4 class="item-name" id="id"><span>id</span><span>: number</span></h4> <h4 class="item-name" id="id"><span>id</span><span>: number</span></h4>
<p class="item-descr">Drone unique numeric identifier: from 0 to 9.</p> <p class="item-descr">Drone unique numeric identifier.</p>
<h5 class="item-param-1">Example</h5> <h5 class="item-param-1">Example</h5>
......
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1010.23624.18144.48810</string> </value> <value> <string>1010.51249.55554.52258</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -264,7 +264,7 @@ ...@@ -264,7 +264,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1691679891.23</float> <float>1693418554.45</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
.import-export {
white-space: nowrap;
}
.import-export input {
display: none;
}
.import-export label {
border: 1px solid #ccc;
display: inline-block;
padding: 6px 12px;
cursor: pointer;
}
.item-label {
background-color: #F8F8F8;
padding: 8px;
margin: 8px 0;
font-size: 1.2em;
font-weight: bold;
}
.run-game {
margin-top: 0 !important;
}
\ No newline at end of file
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width" />
<title>Drone Capture Flag Script Page</title> <title>Drone Capture Flag Script Page</title>
<link rel="http://www.renderjs.org/rel/interface" href="interface_page.html"> <link rel="http://www.renderjs.org/rel/interface" href="interface_page.html">
<link rel="stylesheet" type="text/css" href="gadget_erp5_page_drone_capture_flag_script_page.css">
<!-- renderjs --> <!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script> <script src="rsvp.js" type="text/javascript"></script>
...@@ -19,23 +20,51 @@ ...@@ -19,23 +20,51 @@
<script src="gadget_global.js" type="text/javascript"></script> <script src="gadget_global.js" type="text/javascript"></script>
<script src="domsugar.js" type="text/javascript"></script> <script src="domsugar.js" type="text/javascript"></script>
<script type="text/javascript" src="./libraries/seedrandom.min.js"></script> <script type="text/javascript" src="./libraries/seedrandom.min.js"></script>
<script type="text/javascript" src="./libraries/require.js"></script>
<script src="gadget_erp5_page_drone_capture_flag_script_page.js" type="text/javascript"></script> <script src="gadget_erp5_page_drone_capture_flag_script_page.js" type="text/javascript"></script>
</head> </head>
<body> <body>
<form> <form>
<!-- parameters input form -->
<label class="item-label">Game parameters</label>
<div data-gadget-url="gadget_erp5_form.html" <div data-gadget-url="gadget_erp5_form.html"
data-gadget-scope="form_view" data-gadget-scope="form_view"
data-gadget-sandbox="public"> data-gadget-sandbox="public">
</div> </div>
<input name="action_run" class="dialogconfirm" type="submit" value="Run" style="margin-bottom: 20pt;margin-top: 20pt;"> <!-- operator script editor -->
<a data-i18n="Storages"></a> <!-- for zelenium test common macro --> <label class="item-label">Operator script</label>
<div data-gadget-url="gadget_editor.html"
data-gadget-scope="operator-editor"
data-gadget-sandbox="">
</div>
<div class="import-export">
<label class="import">
<input type="file" id="import" >
Import
</label>
<label class="export">
<input type="button" id="export" >
Export
</label>
</div>
<!-- AI script editor -->
<label class="item-label">AI script</label>
<div data-gadget-url="gadget_editor.html"
data-gadget-scope="script-editor"
data-gadget-sandbox="">
</div>
<!-- Game -->
<label class="item-label">Game</label>
<input name="action_run" class="run-game" type="submit" value="Run">
<div class="simulator_div"></div> <div class="simulator_div"></div>
<div data-gadget-url="gadget_erp5_form.html" <div data-gadget-url="gadget_erp5_form.html"
data-gadget-scope="form_view_babylonjs" data-gadget-scope="form_view_babylonjs"
data-gadget-sandbox="public"> data-gadget-sandbox="public">
</div> </div>
<a data-i18n="Storages"></a> <!-- for zelenium test common macro -->
</form> </form>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1008.22253.2281.60074</string> </value> <value> <string>1010.62539.25351.39680</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -264,7 +264,7 @@ ...@@ -264,7 +264,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1683820259.6</float> <float>1694014905.34</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1010.23654.50890.20360</string> </value> <value> <string>1010.62683.28686.10205</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1691681704.91</float> <float>1694023525.57</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -277,7 +277,7 @@ ...@@ -277,7 +277,7 @@
</item> </item>
<item> <item>
<key> <string>configuration_content_security_policy</string> </key> <key> <string>configuration_content_security_policy</string> </key>
<value> <string>default-src \'self\'; img-src \'self\' data:; media-src \'self\' blob:; connect-src \'self\' https://content.dropboxapi.com https://api.dropboxapi.com mail.tiolive.com data: *.host.vifib.net *.node.vifib.com *.erp5.net *.nexedi.net https://netdna.bootstrapcdn.com; script-src \'self\' \'unsafe-eval\' \'unsafe-inline\'; font-src \'self\' netdna.bootstrapcdn.com; style-src \'self\' netdna.bootstrapcdn.com \'unsafe-inline\' data:; frame-src \'self\' data:</string> </value> <value> <string>default-src \'self\'; img-src \'self\' data:; media-src \'self\' blob:; script-src \'self\' \'unsafe-eval\';</string> </value>
</item> </item>
<item> <item>
<key> <string>configuration_latest_document_version</string> </key> <key> <string>configuration_latest_document_version</string> </key>
...@@ -538,7 +538,7 @@ ...@@ -538,7 +538,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1007.63243.40091.31010</string> </value> <value> <string>1010.35278.59853.35635</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -558,7 +558,7 @@ ...@@ -558,7 +558,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1682433351.46</float> <float>1692976685.9</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>configuration_content_security_policy</string> </key> <key> <string>configuration_content_security_policy</string> </key>
<value> <string>default-src \'self\'; img-src \'self\' data:; media-src \'self\' blob:; connect-src \'self\' https://content.dropboxapi.com https://api.dropboxapi.com mail.tiolive.com data: *.host.vifib.net *.node.vifib.com *.erp5.net *.nexedi.net https://netdna.bootstrapcdn.com; script-src \'self\' \'unsafe-eval\' \'unsafe-inline\'; font-src \'self\' netdna.bootstrapcdn.com; style-src \'self\' netdna.bootstrapcdn.com \'unsafe-inline\' data:; frame-src \'self\' data:</string> </value> <value> <string>default-src \'self\'; img-src \'self\' data:; media-src \'self\' blob:; script-src \'self\' \'unsafe-eval\';</string> </value>
</item> </item>
<item> <item>
<key> <string>configuration_default_view_action_reference</string> </key> <key> <string>configuration_default_view_action_reference</string> </key>
...@@ -502,7 +502,7 @@ WebSection_getDroneCaptureFlagPrecacheManifestList</string> </value> ...@@ -502,7 +502,7 @@ WebSection_getDroneCaptureFlagPrecacheManifestList</string> </value>
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1007.63247.30934.52258</string> </value> <value> <string>1010.35278.59853.35635</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -522,7 +522,7 @@ WebSection_getDroneCaptureFlagPrecacheManifestList</string> </value> ...@@ -522,7 +522,7 @@ WebSection_getDroneCaptureFlagPrecacheManifestList</string> </value>
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1682433685.5</float> <float>1692976699.18</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string>require.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/javascript</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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