Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
139
Merge Requests
139
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
1631641c
Commit
1631641c
authored
Jun 20, 2024
by
Léo-Paul Géneau
👾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_officejs_drone_simulator: update script to not depend on initial coordinates
parent
65fe6abf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
146 additions
and
93 deletions
+146
-93
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/ojs_drone_capture_flag_script_page_js.js
.../web_page_module/ojs_drone_capture_flag_script_page_js.js
+2
-2
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/ojs_drone_capture_flag_script_page_js.xml
...web_page_module/ojs_drone_capture_flag_script_page_js.xml
+2
-2
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/ojs_drone_simulator_script_page_js.js
...tem/web_page_module/ojs_drone_simulator_script_page_js.js
+140
-87
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/ojs_drone_simulator_script_page_js.xml
...em/web_page_module/ojs_drone_simulator_script_page_js.xml
+2
-2
No files found.
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/ojs_drone_capture_flag_script_page_js.js
View file @
1631641c
...
...
@@ -620,7 +620,7 @@ var OperatorAPI = /** @class */ (function () {
"
editable
"
:
1
,
"
key
"
:
"
drone_max_acceleration
"
,
"
hidden
"
:
0
,
"
type
"
:
"
Integer
Field
"
"
type
"
:
"
Float
Field
"
},
"
my_drone_max_deceleration
"
:
{
"
description
"
:
""
,
...
...
@@ -846,7 +846,7 @@ var OperatorAPI = /** @class */ (function () {
}
game_parameters_json
=
{
"
drone
"
:
{
"
maxAcceleration
"
:
parse
Int
(
gadget
.
state
.
drone_max_acceleration
,
10
),
"
maxAcceleration
"
:
parse
Float
(
gadget
.
state
.
drone_max_acceleration
),
"
maxDeceleration
"
:
parseInt
(
gadget
.
state
.
drone_max_deceleration
,
10
),
"
minSpeed
"
:
parseInt
(
gadget
.
state
.
drone_min_speed
,
10
),
"
speed
"
:
parseFloat
(
gadget
.
state
.
drone_speed
),
...
...
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/ojs_drone_capture_flag_script_page_js.xml
View file @
1631641c
...
...
@@ -246,7 +246,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
10
16.21921.52144.47906
</string>
</value>
<value>
<string>
10
20.20542.569.24900
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>
17
14738877.83
</float>
<float>
17
30211735.44
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/ojs_drone_simulator_script_page_js.js
View file @
1631641c
...
...
@@ -31,100 +31,153 @@
NUMBER_OF_DRONES
=
2
,
// Non-inputs parameters
DEFAULT_SCRIPT_CONTENT
=
'
var ALTITUDE = 100,
\n
'
+
'
EPSILON = 9,
\n
'
+
'
CHECKPOINT_LIST = [
\n
'
+
'
{
\n
'
+
'
altitude: 585.1806861589965,
\n
'
+
'
latitude: 45.64492790560583,
\n
'
+
'
longitude: 14.25334942966329
\n
'
+
'
},
\n
'
+
'
{
\n
'
+
'
altitude: 589.8802607573035,
\n
'
+
'
latitude: 45.64316335436476,
\n
'
+
'
longitude: 14.26332880184475
\n
'
+
'
},
\n
'
+
'
{
\n
'
+
'
altitude: 608.6648153348965,
\n
'
+
'
latitude: 45.64911917196595,
\n
'
+
'
longitude: 14.26214792790128
\n
'
+
'
},
\n
'
+
'
{
\n
'
+
'
altitude: 606.1448368129072,
\n
'
+
'
latitude: 45.64122685351364,
\n
'
+
'
longitude: 14.26590493128597
\n
'
+
'
},
\n
'
+
'
{
\n
'
+
'
altitude: 630.0829598206344,
\n
'
+
'
latitude: 45.64543355564817,
\n
'
+
'
longitude: 14.27242391207985
\n
'
+
'
},
\n
'
+
'
{
\n
'
+
'
altitude: 616.1839898415284,
\n
'
+
'
latitude: 45.6372792927328,
\n
'
+
'
longitude: 14.27533492411138
\n
'
+
'
},
\n
'
+
'
{
\n
'
+
'
altitude: 598.0603137354178,
\n
'
+
'
latitude: 45.64061299543953,
\n
'
+
'
longitude: 14.26161958465814
\n
'
+
'
},
\n
'
+
'
{
\n
'
+
'
altitude: 607.1243119862851,
\n
'
+
'
latitude: 45.64032340702919,
\n
'
+
'
longitude: 14.2682896662383
\n
'
+
'
/*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80 */
\n
'
+
'
/*global console, me*/
\n
'
+
'
\n
'
+
'
(function (console, me) {
\n
'
+
'
"use strict";
\n
'
+
'
\n
'
+
'
var ALTITUDE = 100,
\n
'
+
'
EPSILON = 9,
\n
'
+
'
CHECKPOINT_LIST = [],
\n
'
+
'
DIRECTION_LIST = [
\n
'
+
'
{
\n
'
+
'
distance: 1053,
\n
'
+
'
bearing: 293
\n
'
+
'
},
\n
'
+
'
{
\n
'
+
'
distance: 800,
\n
'
+
'
bearing: 104
\n
'
+
'
},
\n
'
+
'
{
\n
'
+
'
distance: 669,
\n
'
+
'
bearing: 352
\n
'
+
'
},
\n
'
+
'
{
\n
'
+
'
distance: 925,
\n
'
+
'
bearing: 162
\n
'
+
'
},
\n
'
+
'
{
\n
'
+
'
distance: 690,
\n
'
+
'
bearing: 47
\n
'
+
'
},
\n
'
+
'
{
\n
'
+
'
distance: 935,
\n
'
+
'
bearing: 166
\n
'
+
'
},
\n
'
+
'
{
\n
'
+
'
distance: 1129,
\n
'
+
'
bearing: 289
\n
'
+
'
},
\n
'
+
'
{
\n
'
+
'
distance: 520,
\n
'
+
'
bearing: 94
\n
'
+
'
}
\n
'
+
'
],
\n
'
+
'
R = 6371e3 // meters;
\n
'
+
'
\n
'
+
'
function to_deg(rad) {
\n
'
+
'
return rad * 180 / Math.PI;
\n
'
+
'
}
\n
'
+
'
\n
'
+
'
function to_rad(deg) {
\n
'
+
'
return deg * Math.PI / 180;
\n
'
+
'
}
\n
'
+
'
\n
'
+
'
function set_checkpoints(lat, lon) {
\n
'
+
'
var bearing_rad,
\n
'
+
'
lat_end,
\n
'
+
'
lon_end,
\n
'
+
'
lat_start = to_rad(lat),
\n
'
+
'
lon_start = to_rad(lon),
\n
'
+
'
relative_d;
\n
'
+
'
\n
'
+
'
DIRECTION_LIST.forEach(function (e) {
\n
'
+
'
bearing_rad = to_rad(e.bearing);
\n
'
+
'
relative_d = e.distance / R;
\n
'
+
'
\n
'
+
'
lat_end = Math.asin(Math.sin(lat_start) * Math.cos(relative_d)
\n
'
+
'
+ Math.cos(lat_start) * Math.sin(relative_d) * Math.cos(bearing_rad));
\n
'
+
'
lon_end = lon_start + Math.atan2(
\n
'
+
'
Math.sin(bearing_rad) * Math.sin(relative_d) * Math.cos(lat_start),
\n
'
+
'
Math.cos(relative_d) - Math.sin(lat_start) * Math.sin(lon_start));
\n
'
+
'
\n
'
+
'
CHECKPOINT_LIST.push({
'
+
'
latitude: to_deg(lat_end),
\n
'
+
'
longitude: to_deg(lon_end)
\n
'
+
'
});
\n
'
+
'
\n
'
+
'
lat_start = lat_end;
\n
'
+
'
lon_start = lon_end;
\n
'
+
'
});
\n
'
+
'
}
\n
'
+
'
\n
'
+
'
function distance(lat1, lon1, lat2, lon2) {
\n
'
+
'
var la1 = lat1 * Math.PI / 180, // lat, lon in radians
\n
'
+
'
la2 = lat2 * Math.PI / 180,
\n
'
+
'
lo1 = lon1 * Math.PI / 180,
\n
'
+
'
lo2 = lon2 * Math.PI / 180,
\n
'
+
'
haversine_phi = Math.pow(Math.sin((la2 - la1) / 2), 2),
\n
'
+
'
sin_lon = Math.sin((lo2 - lo1) / 2),
\n
'
+
'
h = haversine_phi + Math.cos(la1) * Math.cos(la2) * sin_lon * sin_lon;
\n
'
+
'
return 2 * R * Math.asin(Math.sqrt(h));
\n
'
+
'
}
\n
'
+
'
\n
'
+
'
me.onStart = function (timestamp) {
\n
'
+
'
me.direction_set = false;
\n
'
+
'
me.next_checkpoint = 0;
\n
'
+
'
me.takeOff();
\n
'
+
'
};
\n
'
+
'
\n
'
+
'
me.onUpdate = function (timestamp) {
\n
'
+
'
if (!me.isReadyToFly()) {
\n
'
+
'
return;
\n
'
+
'
}
\n
'
+
'
];
\n
'
+
'
\n
'
+
'
function distance(lat1, lon1, lat2, lon2) {
\n
'
+
'
var R = 6371e3, // meters
\n
'
+
'
la1 = lat1 * Math.PI / 180, // lat, lon in radians
\n
'
+
'
la2 = lat2 * Math.PI / 180,
\n
'
+
'
lo1 = lon1 * Math.PI / 180,
\n
'
+
'
lo2 = lon2 * Math.PI / 180,
\n
'
+
'
haversine_phi = Math.pow(Math.sin((la2 - la1) / 2), 2),
\n
'
+
'
sin_lon = Math.sin((lo2 - lo1) / 2),
\n
'
+
'
h = haversine_phi + Math.cos(la1) * Math.cos(la2) * sin_lon * sin_lon;
\n
'
+
'
return 2 * R * Math.asin(Math.sqrt(h));
\n
'
+
'
}
\n
'
+
'
me.current_position = me.getCurrentPosition();
\n
'
+
'
if (CHECKPOINT_LIST.length === 0) {
\n
'
+
'
set_checkpoints(me.current_position.latitude,
\n
'
+
'
me.current_position.longitude);
\n
'
+
'
}
\n
'
+
'
\n
'
+
'
me.onStart = function (timestamp) {
\n
'
+
'
me.direction_set = false;
\n
'
+
'
me.next_checkpoint = 0;
\n
'
+
'
};
\n
'
+
'
if (!me.direction_set) {
\n
'
+
'
if (me.next_checkpoint < CHECKPOINT_LIST.length) {
\n
'
+
'
me.setTargetCoordinates(
\n
'
+
'
CHECKPOINT_LIST[me.next_checkpoint].latitude,
\n
'
+
'
CHECKPOINT_LIST[me.next_checkpoint].longitude,
\n
'
+
'
ALTITUDE + ALTITUDE * me.id,
\n
'
+
'
'
+
DEFAULT_SPEED
+
'
\n
'
+
'
);
\n
'
+
'
console.log("[DEMO] Going to Checkpoint", me.next_checkpoint);
\n
'
+
'
}
\n
'
+
'
me.direction_set = true;
\n
'
+
'
return;
\n
'
+
'
}
\n
'
+
'
\n
'
+
'
me.onUpdate = function (timestamp) {
\n
'
+
'
if (!me.direction_set) {
\n
'
+
'
if (me.next_checkpoint < CHECKPOINT_LIST.length) {
\n
'
+
'
me.setTargetCoordinates(
\n
'
+
'
me.current_position = me.getCurrentPosition();
\n
'
+
'
me.distance = distance(
\n
'
+
'
me.current_position.latitude,
\n
'
+
'
me.current_position.longitude,
\n
'
+
'
CHECKPOINT_LIST[me.next_checkpoint].latitude,
\n
'
+
'
CHECKPOINT_LIST[me.next_checkpoint].longitude,
\n
'
+
'
CHECKPOINT_LIST[me.next_checkpoint].altitude + ALTITUDE + ALTITUDE * me.id,
\n
'
+
'
'
+
DEFAULT_SPEED
+
'
\n
'
+
'
CHECKPOINT_LIST[me.next_checkpoint].longitude
\n
'
+
'
);
\n
'
+
'
console.log("[DEMO] Going to Checkpoint %d", me.next_checkpoint);
\n
'
+
'
if (me.distance <= EPSILON) {
\n
'
+
'
console.log("[DEMO] Reached Checkpoint", me.next_checkpoint);
\n
'
+
'
me.next_checkpoint += 1;
\n
'
+
'
me.direction_set = false;
\n
'
+
'
}
\n
'
+
'
return;
\n
'
+
'
}
\n
'
+
'
me.direction_set = true;
\n
'
+
'
return;
\n
'
+
'
}
\n
'
+
'
if (me.next_checkpoint < CHECKPOINT_LIST.length) {
\n
'
+
'
me.current_position = me.getCurrentPosition();
\n
'
+
'
me.distance = distance(
\n
'
+
'
me.current_position.latitude,
\n
'
+
'
me.current_position.longitude,
\n
'
+
'
CHECKPOINT_LIST[me.next_checkpoint].latitude,
\n
'
+
'
CHECKPOINT_LIST[me.next_checkpoint].longitude
\n
'
+
'
);
\n
'
+
'
if (me.distance <= EPSILON) {
\n
'
+
'
console.log("[DEMO] Reached Checkpoint %d", me.next_checkpoint);
\n
'
+
'
me.next_checkpoint += 1;
\n
'
+
'
me.direction_set = false;
\n
'
+
'
\n
'
+
'
if (!me.isLanding()) {
\n
'
+
'
me.land();
\n
'
+
'
}
\n
'
+
'
return;
\n
'
+
'
}
\n
'
+
'
if (!me.isLanding()) { me.land() };
\n
'
+
'
if (me.getCurrentPosition().altitude <= 0) { me.exit(0)
};
\n
'
+
'
}
;
'
,
'
if (me.getCurrentPosition().altitude <= 0) {
\n
'
+
'
me.exit(0);
\n
'
+
'
}
\n
'
+
'
};
\n
'
+
'
}
(console, me));
\n
'
,
DRAW
=
true
,
LOG
=
true
,
LOG_TIME
=
1662.7915426540285
,
...
...
@@ -246,7 +299,7 @@
"
editable
"
:
1
,
"
key
"
:
"
drone_max_acceleration
"
,
"
hidden
"
:
0
,
"
type
"
:
"
Integer
Field
"
"
type
"
:
"
Float
Field
"
},
"
my_drone_max_deceleration
"
:
{
"
description
"
:
""
,
...
...
@@ -497,7 +550,7 @@
}
game_parameters_json
=
{
"
drone
"
:
{
"
maxAcceleration
"
:
parse
Int
(
options
.
drone_max_acceleration
,
10
),
"
maxAcceleration
"
:
parse
Float
(
options
.
drone_max_acceleration
),
"
maxDeceleration
"
:
parseInt
(
options
.
drone_max_deceleration
,
10
),
"
minSpeed
"
:
parseInt
(
options
.
drone_min_speed
,
10
),
"
speed
"
:
parseFloat
(
options
.
drone_speed
),
...
...
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/ojs_drone_simulator_script_page_js.xml
View file @
1631641c
...
...
@@ -246,7 +246,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
10
15.64120.46679.6946
</string>
</value>
<value>
<string>
10
20.29234.48115.42939
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>
17
13425712.2
</float>
<float>
17
30734363.63
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment