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
1
Issues
1
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
Roque
erp5
Commits
a410eb63
Commit
a410eb63
authored
Sep 29, 2022
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[WEB-WORKER] [WIP] simplify json game parameters
parent
7f92886e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
96 deletions
+24
-96
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_logic_js.js
...TemplateItem/web_page_module/drone_web_worker_logic_js.js
+22
-94
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_logic_js.xml
...emplateItem/web_page_module/drone_web_worker_logic_js.xml
+2
-2
No files found.
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_logic_js.js
View file @
a410eb63
...
...
@@ -14,86 +14,16 @@ var runGame, updateGame, eventGame, game_manager_instance;
runGame
=
function
(
canvas
,
script
,
log
)
{
var
game_parameters_json
=
{
"
distances
"
:
{
"
communication
"
:
99999
,
"
control
"
:
1500
,
"
information
"
:
5
},
"
drone
"
:
{
"
maxAcceleration
"
:
1
,
"
maxSpeed
"
:
16.666667
,
"
collisionSector
"
:
0.25
,
"
broadcastingTime
"
:
1000
,
"
viewAngle
"
:
60
},
"
meteo
"
:
0.5
,
"
derive
"
:
{
"
speed
"
:
0.1
,
"
direction
"
:
{
"
x
"
:
1
,
"
y
"
:
0.5
}
"
maxSpeed
"
:
16.666667
},
"
gameTime
"
:
1800
,
"
goalDiameter
"
:
7
,
"
goalPositionLeftTeam
"
:
{
"
x
"
:
0
,
"
y
"
:
0
,
"
z
"
:
0.6
},
"
goalPositionRightTeam
"
:
{
"
x
"
:
0
,
"
y
"
:
0
,
"
z
"
:
0.6
},
"
latency
"
:
{
"
information
"
:
0
,
"
communication
"
:
0
},
"
mapSize
"
:
{
"
depth
"
:
1000
,
"
height
"
:
100
,
"
width
"
:
1000
},
"
obstacles
"
:
[],
"
initialHumanAreaPosition
"
:
{
"
x
"
:
-
400
,
"
y
"
:
400
,
"
z
"
:
0
},
"
randomSpawn
"
:
{
"
leftTeam
"
:
{
"
position
"
:
{
"
x
"
:
0
,
"
y
"
:
0
,
"
z
"
:
20
},
"
dispertion
"
:
{
"
x
"
:
8
,
"
y
"
:
8
,
"
z
"
:
6
},
"
types
"
:
[
"
DroneAaileFixeAPI
"
,
"
DroneLogAPI
"
,
"
DroneAPI
"
]
},
"
rightTeam
"
:
{
"
position
"
:
{
"
x
"
:
-
400
,
"
y
"
:
400
,
"
z
"
:
0
},
"
dispertion
"
:
{
"
x
"
:
100
,
"
y
"
:
100
,
"
z
"
:
0.1
}
}
},
"
teamSize
"
:
2
,
"
dronesPosition
"
:
{
"
initialPosition
"
:
{
"
x
"
:
0
,
"
y
"
:
0
,
"
z
"
:
20
...
...
@@ -102,7 +32,7 @@ var runGame, updateGame, eventGame, game_manager_instance;
};
function
processLog
(
game_parameters_json
,
log
)
{
var
MAP_SIZE
=
1000
,
var
MAP_SIZE
,
MIN_HEIGHT
=
15
,
MIN_X
,
MAX_X
,
...
...
@@ -144,8 +74,7 @@ var runGame, updateGame, eventGame, game_manager_instance;
lat
,
lon
,
x
,
y
,
position
,
min_lon
=
99999
,
min_lat
=
99999
,
max_lon
=
0
,
max_lat
=
0
,
previous
,
start_position
,
dist
=
0
,
path_point
,
average_speed
=
0
,
flight_time
,
log_interval_time
,
previous_log_time
,
height
,
timestamp
,
destination_lon
,
destination_lat
,
log_header_found
,
time_offset
=
1
,
previous_log_time
,
height
,
timestamp
,
log_header_found
,
time_offset
=
1
,
flight_dist
=
0
,
start_AMSL
=
0
;
for
(
i
=
0
;
i
<
line_list
.
length
;
i
+=
1
)
{
if
(
!
log_header_found
&&
!
line_list
[
i
].
includes
(
"
timestamp;
"
))
{
...
...
@@ -210,8 +139,6 @@ var runGame, updateGame, eventGame, game_manager_instance;
lat
=
parseFloat
(
splitted_log_entry
[
1
]);
lon
=
parseFloat
(
splitted_log_entry
[
2
]);
if
(
i
===
log_entry_list
.
length
-
1
)
{
destination_lon
=
lon
;
destination_lat
=
lat
;
end_time
=
timestamp
;
}
height
=
parseFloat
(
splitted_log_entry
[
4
]);
...
...
@@ -264,6 +191,7 @@ var runGame, updateGame, eventGame, game_manager_instance;
average_speed
=
average_speed
/
log_entry_list
.
length
;
log_interval_time
=
log_interval_time
/
log_entry_list
.
length
/
time_offset
;
flight_time
=
(
end_time
-
start_time
)
/
1000
/
time_offset
;
//TODO refactor this
game_parameters_json
.
compareFlights
=
{
log
:
true
,
draw
:
true
,
...
...
@@ -284,19 +212,19 @@ var runGame, updateGame, eventGame, game_manager_instance;
};
game_parameters_json
.
drone
.
maxSpeed
=
(
flight_dist
/
flight_time
)
*
SPEED_FACTOR
;
game_parameters_json
.
flight_path_point_list
=
path_point_list
;
game_parameters_json
.
drones
Position
.
x
=
start_position
[
0
];
game_parameters_json
.
drones
Position
.
y
=
start_position
[
1
];
game_parameters_json
.
drones
Position
.
z
=
start_position
[
2
];
game_parameters_json
.
initial
Position
.
x
=
start_position
[
0
];
game_parameters_json
.
initial
Position
.
y
=
start_position
[
1
];
game_parameters_json
.
initial
Position
.
z
=
start_position
[
2
];
game_parameters_json
.
gameTime
=
flight_time
;
//give map some margin from
the flight
game_parameters_json
.
mapSize
.
width
=
MAP_SIZE
*
1.10
;
game_parameters_json
.
mapSize
.
depth
=
MAP_SIZE
*
1.10
;
//flight destination
var
destination_x
=
longitudToX
(
destination_lon
)
,
destination_y
=
latitudeToY
(
destination_lat
),
destination
=
normalizeToMap
(
destination_x
,
destination_y
);
game_parameters_json
.
randomSpawn
.
rightTeam
.
position
.
x
=
destination
[
0
]
;
game_parameters_json
.
randomSpawn
.
rightTeam
.
position
.
y
=
destination
[
1
];
//give map some margin from
flight limits
MAP_SIZE
*=
1.10
;
game_parameters_json
.
mapSize
=
{
"
depth
"
:
MAP_SIZE
,
"
height
"
:
100
,
"
width
"
:
MAP_SIZE
}
/*game_parameters_json.mapSize.width = MAP_SIZE * 1.10
;
game_parameters_json.
mapSize.depth = MAP_SIZE * 1.10;*/
return
game_parameters_json
;
}
...
...
@@ -584,7 +512,7 @@ var GameManager = /** @class */ (function () {
// Init the map
_this
.
_mapManager
=
new
MapManager
(
ctx
.
_scene
);
console
.
log
(
"
Map manager instantiated
"
);
ctx
.
_spawnDrones
(
GAMEPARAMETERS
.
drones
Position
,
ctx
.
_spawnDrones
(
GAMEPARAMETERS
.
initial
Position
,
GAMEPARAMETERS
.
droneList
,
ctx
.
_script
);
// Hide the drone prefab
DroneManager
.
Prefab
.
isVisible
=
false
;
...
...
@@ -828,7 +756,7 @@ var DroneLogAPI = /** @class */ (function () {
console
.
log
(
"
API say :
"
+
msg
);
};
DroneLogAPI
.
prototype
.
getGameParameter
=
function
(
name
)
{
if
([
"
gameTime
"
,
"
mapSize
"
,
"
teamSize
"
,
"
derive
"
,
"
meteo
"
].
includes
(
name
))
if
([
"
gameTime
"
,
"
mapSize
"
].
includes
(
name
))
return
this
.
_gameManager
.
gameParameter
[
name
];
};
DroneLogAPI
.
prototype
.
processCoordinates
=
function
(
x
,
y
,
z
)
{
...
...
@@ -957,11 +885,11 @@ var DroneAaileFixeAPI = /** @class */ (function () {
},
GAMEPARAMETERS
.
latency
.
communication
);
};
DroneAaileFixeAPI
.
prototype
.
log
=
function
(
msg
)
{
console
.
log
(
"
API say :
"
+
msg
);
console
.
log
(
"
API say :
"
+
msg
);
};
DroneAaileFixeAPI
.
prototype
.
getGameParameter
=
function
(
name
)
{
if
([
"
gameTime
"
,
"
mapSize
"
,
"
teamSize
"
,
"
derive
"
,
"
meteo
"
].
includes
(
name
))
return
this
.
_gameManager
.
gameParameter
[
name
];
if
([
"
gameTime
"
,
"
mapSize
"
].
includes
(
name
))
return
this
.
_gameManager
.
gameParameter
[
name
];
};
DroneAaileFixeAPI
.
prototype
.
processCoordinates
=
function
(
lat
,
lon
,
z
,
r
)
{
if
(
isNaN
(
lat
)
||
isNaN
(
lon
)
||
isNaN
(
z
)){
...
...
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_logic_js.xml
View file @
a410eb63
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1003.18
677.8071.57617
</string>
</value>
<value>
<string>
1003.18
711.10168.13175
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
16644
62737.31
</float>
<float>
16644
70272.38
</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