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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
erp5
Commits
24eb80cd
Commit
24eb80cd
authored
Feb 27, 2024
by
Roque
Browse files
Options
Browse Files
Download
Plain Diff
Update capture the flag tests
See merge request
nexedi/erp5!1885
parents
3d7d6d5e
862d6a35
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
45 deletions
+57
-45
bt5/erp5_officejs_drone_capture_flag_test/PathTemplateItem/web_page_module/test_capture_drone_flight_js.js
...plateItem/web_page_module/test_capture_drone_flight_js.js
+55
-43
bt5/erp5_officejs_drone_capture_flag_test/PathTemplateItem/web_page_module/test_capture_drone_flight_js.xml
...lateItem/web_page_module/test_capture_drone_flight_js.xml
+2
-2
No files found.
bt5/erp5_officejs_drone_capture_flag_test/PathTemplateItem/web_page_module/test_capture_drone_flight_js.js
View file @
24eb80cd
...
@@ -5,13 +5,15 @@
...
@@ -5,13 +5,15 @@
var
SIMULATION_SPEED
=
10
,
var
SIMULATION_SPEED
=
10
,
SIMULATION_TIME
=
270
,
SIMULATION_TIME
=
270
,
MAP_SIZE
=
1905
,
MIN_LAT
=
45.6364
,
min_lat
=
45.6364
,
MAX_LAT
=
45.65
,
max_lat
=
45.65
,
MIN_LON
=
14.2521
,
min_lon
=
14.2521
,
MAX_LON
=
14.2766
,
max_lon
=
14.2766
,
map_height
=
700
,
map_height
=
700
,
start_AMSL
=
595
,
start_AMSL
=
595
,
INIT_LON
=
14.2658
,
INIT_LAT
=
45.6412
,
INIT_ALT
=
15
,
DEFAULT_SPEED
=
16
,
DEFAULT_SPEED
=
16
,
MAX_ACCELERATION
=
6
,
MAX_ACCELERATION
=
6
,
MAX_DECELERATION
=
1
,
MAX_DECELERATION
=
1
,
...
@@ -31,6 +33,7 @@
...
@@ -31,6 +33,7 @@
'
else
\n
'
+
'
else
\n
'
+
'
console.log(msg + ": FAIL");
\n
'
+
'
console.log(msg + ": FAIL");
\n
'
+
'
}
\n
'
+
'
}
\n
'
+
'
\n
'
+
'
function distance(lat1, lon1, lat2, lon2) {
\n
'
+
'
function distance(lat1, lon1, lat2, lon2) {
\n
'
+
'
var R = 6371e3, // meters
\n
'
+
'
var R = 6371e3, // meters
\n
'
+
'
la1 = lat1 * Math.PI / 180, // lat, lon in radians
\n
'
+
'
la1 = lat1 * Math.PI / 180, // lat, lon in radians
\n
'
+
...
@@ -42,39 +45,46 @@
...
@@ -42,39 +45,46 @@
'
h = haversine_phi + Math.cos(la1) * Math.cos(la2) * sin_lon * sin_lon;
\n
'
+
'
h = haversine_phi + Math.cos(la1) * Math.cos(la2) * sin_lon * sin_lon;
\n
'
+
'
return 2 * R * Math.asin(Math.sqrt(h));
\n
'
+
'
return 2 * R * Math.asin(Math.sqrt(h));
\n
'
+
'
}
\n
'
+
'
}
\n
'
+
'
\n
'
+
'
function compare(coord1, coord2) {
\n
'
+
'
function compare(coord1, coord2) {
\n
'
+
'
assert(coord1.
x, coord2.x
, "Latitude")
\n
'
+
'
assert(coord1.
latitude, coord2.latitude
, "Latitude")
\n
'
+
'
assert(coord1.
y, coord2.y
, "Longitude")
\n
'
+
'
assert(coord1.
longitude, coord2.longitude
, "Longitude")
\n
'
+
'
assert(coord1.
z, coord2.z
, "Altitude")
\n
'
+
'
assert(coord1.
altitude, coord2.altitude
, "Altitude")
\n
'
+
'
}
\n
'
+
'
}
\n
'
+
'
\n
'
+
'
me.onStart = function () {
\n
'
+
'
me.onStart = function () {
\n
'
+
'
assert(me.getAirSpeed(), 16, "Initial speed");
\n
'
+
'
assert(me.getAirSpeed(), 16, "Initial speed");
\n
'
+
'
assert(me.getYaw(), 0, "Yaw angle")
\n
'
+
'
assert(me.getYaw(), 0, "Yaw angle")
\n
'
+
'
me.initialPosition = me.getCurrentPosition();
\n
'
+
'
me.initialPosition = me.getCurrentPosition();
\n
'
+
'
me.setTargetCoordinates(
\n
'
+
'
me.setTargetCoordinates(
\n
'
+
'
me.initialPosition.
x
+ 0.01,
\n
'
+
'
me.initialPosition.
latitude
+ 0.01,
\n
'
+
'
me.initialPosition.
y
,
\n
'
+
'
me.initialPosition.
longitude
,
\n
'
+
'
me.
initialPosition.z
\n
'
+
'
me.
getAltitudeAbs()
\n
'
+
'
);
\n
'
+
'
);
\n
'
+
'
};
\n
'
+
'
};
\n
'
+
'
\n
'
+
'
me.onUpdate = function (timestamp) {
\n
'
+
'
me.onUpdate = function (timestamp) {
\n
'
+
'
var current_position = me.getCurrentPosition(),
\n
'
+
'
var current_position = me.getCurrentPosition(),
\n
'
+
'
realDistance = distance(
\n
'
+
'
realDistance = distance(
\n
'
+
'
me.initialPosition.x
,
\n
'
+
'
me.initialPosition.latitude
,
\n
'
+
'
me.initialPosition.y
,
\n
'
+
'
me.initialPosition.longitude
,
\n
'
+
'
me.getCurrentPosition().x
,
\n
'
+
'
me.getCurrentPosition().latitude
,
\n
'
+
'
me.getCurrentPosition().y
\n
'
+
'
me.getCurrentPosition().longitude
\n
'
+
'
).toFixed(8),
\n
'
+
'
).toFixed(8),
\n
'
+
'
expectedDistance = (me.getAirSpeed() * timestamp / 1000).toFixed(8);
\n
'
+
'
expectedDistance = (me.getAirSpeed() * timestamp / 1000).toFixed(8);
\n
'
+
'
console.log("timestamp", timestamp);
\n
'
+
'
console.log("1000 / 60", 1000/60);
\n
'
+
'
console.log("expectedDistance", expectedDistance);
\n
'
+
'
console.log("realDistance", realDistance);
\n
'
+
'
assert(timestamp, 1000 / 60, "Timestamp");
\n
'
+
'
assert(timestamp, 1000 / 60, "Timestamp");
\n
'
+
'
assert(realDistance, expectedDistance, "Distance");
\n
'
+
'
assert(realDistance, expectedDistance, "Distance");
\n
'
+
'
current_position.
x = current_position.x
.toFixed(7);
\n
'
+
'
current_position.
latitude = current_position.latitude
.toFixed(7);
\n
'
+
'
compare(current_position, {
\n
'
+
'
compare(current_position, {
\n
'
+
'
x: (me.initialPosition.x
+ 2.3992831666911723e-06).toFixed(7),
\n
'
+
'
latitude: (me.initialPosition.latitude
+ 2.3992831666911723e-06).toFixed(7),
\n
'
+
'
y: me.initialPosition.y
,
\n
'
+
'
longitude: me.initialPosition.longitude
,
\n
'
+
'
z: me.initialPosition.z
\n
'
+
'
altitude: me.initialPosition.altitude
\n
'
+
'
});
\n
'
+
'
});
\n
'
+
'
me.exit(me.triggerParachute());
\n
'
+
'
me.exit(me.triggerParachute());
\n
'
+
'
};
'
,
'
};
'
,
DRAW
=
true
,
DRAW
=
true
,
LOG
=
true
,
LOG
=
true
,
...
@@ -82,6 +92,7 @@
...
@@ -82,6 +92,7 @@
DRONE_LIST
=
[],
DRONE_LIST
=
[],
LOGIC_FILE_LIST
=
[
LOGIC_FILE_LIST
=
[
'
gadget_erp5_page_drone_capture_flag_logic.js
'
,
'
gadget_erp5_page_drone_capture_flag_logic.js
'
,
'
gadget_erp5_page_drone_capture_map_utils.js
'
,
'
gadget_erp5_page_drone_capture_flag_fixedwingdrone.js
'
,
'
gadget_erp5_page_drone_capture_flag_fixedwingdrone.js
'
,
'
gadget_erp5_page_drone_capture_flag_enemydrone.js
'
'
gadget_erp5_page_drone_capture_flag_enemydrone.js
'
];
];
...
@@ -100,7 +111,7 @@
...
@@ -100,7 +111,7 @@
.
declareJob
(
'
runGame
'
,
function
runGame
()
{
.
declareJob
(
'
runGame
'
,
function
runGame
()
{
var
gadget
=
this
,
i
,
var
gadget
=
this
,
i
,
fragment
=
gadget
.
element
.
querySelector
(
'
.simulator_div
'
),
fragment
=
gadget
.
element
.
querySelector
(
'
.simulator_div
'
),
game_parameters_json
,
map_json
;
game_parameters_json
,
map_json
,
operator_init_msg
;
DRONE_LIST
=
[];
DRONE_LIST
=
[];
fragment
=
domsugar
(
gadget
.
element
.
querySelector
(
'
.simulator_div
'
),
fragment
=
domsugar
(
gadget
.
element
.
querySelector
(
'
.simulator_div
'
),
[
domsugar
(
'
div
'
)]).
firstElementChild
;
[
domsugar
(
'
div
'
)]).
firstElementChild
;
...
@@ -109,26 +120,25 @@
...
@@ -109,26 +120,25 @@
"
script_content
"
:
DEFAULT_SCRIPT_CONTENT
};
"
script_content
"
:
DEFAULT_SCRIPT_CONTENT
};
}
}
map_json
=
{
map_json
=
{
"
map_size
"
:
parseFloat
(
MAP_SIZE
),
"
height
"
:
parseInt
(
map_height
,
10
),
"
height
"
:
parseInt
(
map_height
,
10
),
"
start_AMSL
"
:
parseFloat
(
start_AMSL
),
"
start_AMSL
"
:
parseFloat
(
start_AMSL
),
"
min_lat
"
:
parseFloat
(
min_lat
),
"
min_lat
"
:
parseFloat
(
MIN_LAT
),
"
max_lat
"
:
parseFloat
(
max_lat
),
"
max_lat
"
:
parseFloat
(
MAX_LAT
),
"
min_lon
"
:
parseFloat
(
min_lon
),
"
min_lon
"
:
parseFloat
(
MIN_LON
),
"
max_lon
"
:
parseFloat
(
max_lon
),
"
max_lon
"
:
parseFloat
(
MAX_LON
),
"
flag_list
"
:
[{
"
flag_list
"
:
[],
"
position
"
:
{
"
x
"
:
-
27
,
"
y
"
:
72
,
"
z
"
:
10
}
}],
"
obstacle_list
"
:
[],
"
obstacle_list
"
:
[],
"
drones
"
:
{
"
enemy_list
"
:
[],
"
user
"
:
DRONE_LIST
,
"
initial_position
"
:
{
"
enemy
"
:
[]
"
longitude
"
:
parseFloat
(
INIT_LON
),
"
latitude
"
:
parseFloat
(
INIT_LAT
),
"
altitude
"
:
parseFloat
(
INIT_ALT
)
}
}
};
};
operator_init_msg
=
{
"
flag_positions
"
:
[]
};
/*jslint evil: false*/
game_parameters_json
=
{
game_parameters_json
=
{
"
debug_test_mode
"
:
true
,
"
debug_test_mode
"
:
true
,
"
drone
"
:
{
"
drone
"
:
{
...
@@ -141,7 +151,8 @@
...
@@ -141,7 +151,8 @@
"
minPitchAngle
"
:
parseFloat
(
MIN_PITCH
),
"
minPitchAngle
"
:
parseFloat
(
MIN_PITCH
),
"
maxPitchAngle
"
:
parseFloat
(
MAX_PITCH
),
"
maxPitchAngle
"
:
parseFloat
(
MAX_PITCH
),
"
maxSinkRate
"
:
parseFloat
(
MAX_SINK_RATE
),
"
maxSinkRate
"
:
parseFloat
(
MAX_SINK_RATE
),
"
maxClimbRate
"
:
parseFloat
(
MAX_CLIMB_RATE
)
"
maxClimbRate
"
:
parseFloat
(
MAX_CLIMB_RATE
),
"
list
"
:
DRONE_LIST
},
},
"
gameTime
"
:
parseInt
(
SIMULATION_TIME
,
10
),
"
gameTime
"
:
parseInt
(
SIMULATION_TIME
,
10
),
"
simulation_speed
"
:
parseInt
(
SIMULATION_SPEED
,
10
),
"
simulation_speed
"
:
parseInt
(
SIMULATION_SPEED
,
10
),
...
@@ -150,6 +161,7 @@
...
@@ -150,6 +161,7 @@
"
communication
"
:
0
"
communication
"
:
0
},
},
"
map
"
:
map_json
,
"
map
"
:
map_json
,
"
operator_init_msg
"
:
operator_init_msg
,
"
draw_flight_path
"
:
DRAW
,
"
draw_flight_path
"
:
DRAW
,
"
temp_flight_path
"
:
true
,
"
temp_flight_path
"
:
true
,
"
log_drone_flight
"
:
LOG
,
"
log_drone_flight
"
:
LOG
,
...
...
bt5/erp5_officejs_drone_capture_flag_test/PathTemplateItem/web_page_module/test_capture_drone_flight_js.xml
View file @
24eb80cd
...
@@ -246,7 +246,7 @@
...
@@ -246,7 +246,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
101
0.33861.49321.40789
</string>
</value>
<value>
<string>
101
4.53878.23823.32290
</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>
1
692294109.04
</float>
<float>
1
709050966.57
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</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