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
Titouan Soulard
erp5
Commits
2d2050eb
Commit
2d2050eb
authored
May 14, 2024
by
Léo-Paul Géneau
👾
Browse files
Options
Browse Files
Download
Plain Diff
erp5_officejs_drone_simulator: fix timeout
See merge request
nexedi/erp5!1903
parents
a12d43f0
23c9f1b0
Changes
22
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
412 additions
and
263 deletions
+412
-263
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/drone_capture_flag_enemydrone_js.js
...eItem/web_page_module/drone_capture_flag_enemydrone_js.js
+5
-2
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/drone_capture_flag_enemydrone_js.xml
...Item/web_page_module/drone_capture_flag_enemydrone_js.xml
+2
-2
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/drone_capture_flag_fixedwingdrone_js.js
...m/web_page_module/drone_capture_flag_fixedwingdrone_js.js
+23
-10
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/drone_capture_flag_fixedwingdrone_js.xml
.../web_page_module/drone_capture_flag_fixedwingdrone_js.xml
+2
-2
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/drone_capture_flag_logic_js.js
...mplateItem/web_page_module/drone_capture_flag_logic_js.js
+110
-75
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/drone_capture_flag_logic_js.xml
...plateItem/web_page_module/drone_capture_flag_logic_js.xml
+2
-2
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/ojs_drone_capture_flag_API_page_html.html
...web_page_module/ojs_drone_capture_flag_API_page_html.html
+13
-0
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/ojs_drone_capture_flag_API_page_html.xml
.../web_page_module/ojs_drone_capture_flag_API_page_html.xml
+2
-2
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
+15
-1
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_capture_flag_test/PathTemplateItem/web_page_module/test_capture_drone_flight_js.js
...plateItem/web_page_module/test_capture_drone_flight_js.js
+39
-31
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
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_dronelogfollower_js.js
...em/web_page_module/drone_simulator_dronelogfollower_js.js
+5
-2
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_dronelogfollower_js.xml
...m/web_page_module/drone_simulator_dronelogfollower_js.xml
+2
-2
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_fixedwingdrone_js.js
...Item/web_page_module/drone_simulator_fixedwingdrone_js.js
+14
-7
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_fixedwingdrone_js.xml
...tem/web_page_module/drone_simulator_fixedwingdrone_js.xml
+2
-2
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_logic_js.js
...hTemplateItem/web_page_module/drone_simulator_logic_js.js
+102
-70
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_logic_js.xml
...TemplateItem/web_page_module/drone_simulator_logic_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
+18
-4
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
bt5/erp5_officejs_drone_simulator_test/PathTemplateItem/web_page_module/test_drone_simulator_flight_js.js
...ateItem/web_page_module/test_drone_simulator_flight_js.js
+46
-39
bt5/erp5_officejs_drone_simulator_test/PathTemplateItem/web_page_module/test_drone_simulator_flight_js.xml
...teItem/web_page_module/test_drone_simulator_flight_js.xml
+2
-2
No files found.
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/drone_capture_flag_enemydrone_js.js
View file @
2d2050eb
...
...
@@ -56,7 +56,7 @@ var EnemyDroneAPI = /** @class */ (function () {
/*
** Function called on every drone update, right before onUpdate AI script
*/
EnemyDroneAPI
.
prototype
.
internal_update
=
function
(
context
,
delta_time
)
{
EnemyDroneAPI
.
prototype
.
internal_
position_
update
=
function
(
context
,
delta_time
)
{
context
.
_speed
+=
context
.
_acceleration
*
delta_time
/
1000
;
if
(
context
.
_speed
>
context
.
_maxSpeed
)
{
context
.
_speed
=
context
.
_maxSpeed
;
...
...
@@ -81,7 +81,7 @@ var EnemyDroneAPI = /** @class */ (function () {
/*
** Function called on every drone update, right after onUpdate AI script
*/
EnemyDroneAPI
.
prototype
.
internal_
post
_update
=
function
(
drone
)
{
EnemyDroneAPI
.
prototype
.
internal_
info
_update
=
function
(
drone
)
{
var
_this
=
this
,
drone_position
=
drone
.
getCurrentPosition
(),
drone_info
;
if
(
drone_position
)
{
drone_info
=
{
...
...
@@ -307,6 +307,9 @@ var EnemyDroneAPI = /** @class */ (function () {
EnemyDroneAPI
.
prototype
.
getMaxHeight
=
function
()
{
return
800
;
};
EnemyDroneAPI
.
prototype
.
getOnUpdateInterval
=
function
()
{
return
0
;
};
EnemyDroneAPI
.
prototype
.
getFlightParameters
=
function
()
{
return
this
.
_flight_parameters
;
};
...
...
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/drone_capture_flag_enemydrone_js.xml
View file @
2d2050eb
...
...
@@ -246,7 +246,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
101
4.60631.26636.59528
</string>
</value>
<value>
<string>
101
5.63148.58654.57634
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>
17
09288499.16
</float>
<float>
17
13426942.44
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/drone_capture_flag_fixedwingdrone_js.js
View file @
2d2050eb
...
...
@@ -6,6 +6,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
"
use strict
"
;
var
DEFAULT_SPEED
=
16
,
PARACHUTE_SPEED
=
8
,
EARTH_GRAVITY
=
9.81
,
LOITER_LIMIT
=
30
,
MAX_ACCELERATION
=
6
,
...
...
@@ -48,7 +49,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
throw
new
Error
(
'
max acceleration must be superior to 0
'
);
}
drone
.
_minSpeed
=
this
.
getMinSpeed
();
if
(
drone
.
_minSpeed
<
=
0
)
{
if
(
drone
.
_minSpeed
<
0
)
{
throw
new
Error
(
'
min speed must be superior to 0
'
);
}
drone
.
_maxSpeed
=
this
.
getMaxSpeed
();
...
...
@@ -97,9 +98,13 @@ var FixedWingDroneAPI = /** @class */ (function () {
/*
** Function called on every drone update, right before onUpdate AI script
*/
FixedWingDroneAPI
.
prototype
.
internal_update
=
function
(
context
,
delta_time
)
{
FixedWingDroneAPI
.
prototype
.
internal_position_update
=
function
(
context
,
delta_time
)
{
if
(
context
.
position
.
z
>
0
)
{
this
.
_updateSpeed
(
context
,
delta_time
);
this
.
_updatePosition
(
context
,
delta_time
);
}
else
{
context
.
setDirection
(
0
,
0
,
0
);
}
context
.
_controlMesh
.
computeWorldMatrix
(
true
);
context
.
_mesh
.
computeWorldMatrix
(
true
);
...
...
@@ -107,7 +112,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
/*
** Function called on every drone update, right after onUpdate AI script
*/
FixedWingDroneAPI
.
prototype
.
internal_
post
_update
=
function
(
drone
)
{
FixedWingDroneAPI
.
prototype
.
internal_
info
_update
=
function
(
drone
)
{
var
_this
=
this
,
drone_position
=
drone
.
getCurrentPosition
(),
drone_info
;
/*if (_this._start_altitude > 0) { //TODO move start_altitude here
_this.reachAltitude(drone);
...
...
@@ -486,8 +491,8 @@ var FixedWingDroneAPI = /** @class */ (function () {
function
(
altitude_diff
,
max_climb_rate
,
speed
,
max_pitch
)
{
var
maxVerticalSpeed
=
Math
.
min
(
altitude_diff
,
Math
.
min
(
max_climb_rate
,
speed
));
return
(
this
.
_toDeg
(
Math
.
asin
(
maxVerticalSpeed
/
speed
))
>
max_pitch
)
?
speed
*
Math
.
sin
(
this
.
_toRad
(
max_pitch
))
return
(
this
.
_toDeg
(
Math
.
asin
(
maxVerticalSpeed
/
speed
))
>
max_pitch
)
?
speed
*
Math
.
sin
(
this
.
_toRad
(
max_pitch
))
:
maxVerticalSpeed
;
};
FixedWingDroneAPI
.
prototype
.
_toRad
=
function
(
angle
)
{
...
...
@@ -511,11 +516,16 @@ var FixedWingDroneAPI = /** @class */ (function () {
};
FixedWingDroneAPI
.
prototype
.
land
=
function
(
drone
)
{
var
drone_pos
=
drone
.
getCurrentPosition
();
drone
.
setTargetCoordinates
(
this
.
_flight_parameters
.
drone
.
minSpeed
=
0
;
drone
.
_speed
=
0
;
drone
.
_acceleration
=
EARTH_GRAVITY
;
this
.
_flight_parameters
.
drone
.
maxSinkRate
=
PARACHUTE_SPEED
;
this
.
_flight_parameters
.
drone
.
minPitchAngle
=
-
90
;
drone
.
_internal_setTargetCoordinates
(
drone_pos
.
latitude
,
drone_pos
.
longitude
,
0
,
drone
.
get3DSpeed
()
-
PARACHUTE_SPEED
,
PARACHUTE_SPEED
);
this
.
_is_ready_to_fly
=
false
;
this
.
_is_landing
=
true
;
...
...
@@ -538,6 +548,9 @@ var FixedWingDroneAPI = /** @class */ (function () {
FixedWingDroneAPI
.
prototype
.
getMaxHeight
=
function
()
{
return
800
;
};
FixedWingDroneAPI
.
prototype
.
getOnUpdateInterval
=
function
()
{
return
this
.
_flight_parameters
.
drone
.
onUpdateInterval
;
};
FixedWingDroneAPI
.
prototype
.
getFlightParameters
=
function
()
{
return
this
.
_flight_parameters
;
};
...
...
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/drone_capture_flag_fixedwingdrone_js.xml
View file @
2d2050eb
...
...
@@ -246,7 +246,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
101
4.60733.7318.44953
</string>
</value>
<value>
<string>
101
5.64140.4755.42274
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>
17
09564488.61
</float>
<float>
17
13430403.75
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/drone_capture_flag_logic_js.js
View file @
2d2050eb
...
...
@@ -6,6 +6,56 @@ var GAMEPARAMETERS = {}, TEAM_USER = "user", TEAM_ENEMY = "enemy";
//for DEBUG/TEST mode
var
baseLogFunction
=
console
.
log
,
console_log
=
""
;
function
spawnDrone
(
spawnDrone_x
,
spawnDrone_y
,
spawnDrone_z
,
spawnDrone_index
,
spawnDrone_drone_info
,
spawnDrone_api
,
spawnDrone_team
,
spawnDrone_scene
,
spawnDrone_droneList_user
,
spawnDrone_droneList_enemy
)
{
"
use strict
"
;
var
default_drone_AI
=
spawnDrone_api
.
getDroneAI
(),
spawnDrone_code
,
code_eval
;
if
(
default_drone_AI
)
{
spawnDrone_code
=
default_drone_AI
;
}
else
{
spawnDrone_code
=
spawnDrone_drone_info
.
script_content
;
}
if
(
!
spawnDrone_code
.
includes
(
"
me.onStart
"
))
{
spawnDrone_code
=
"
me.onStart = function () { me.exit(); };
"
;
}
code_eval
=
"
let spawnDrone_drone = new DroneManager(spawnDrone_scene,
"
+
spawnDrone_index
+
'
, spawnDrone_api, spawnDrone_team);
'
+
"
let droneMe = function(NativeDate, me, Math, window, DroneManager,
"
+
"
GameManager, FixedWingDroneAPI, EnemyDroneAPI, BABYLON,
"
+
"
GAMEPARAMETERS) {
"
+
"
Date.now = function () {
"
+
"
return me._API._gameManager.getCurrentTime();};
"
+
"
function Date() {if (!(this instanceof Date))
"
+
"
{throw new Error('Missing new operator');}
"
+
"
if (arguments.length === 0) {return new NativeDate(Date.now());}
"
+
"
else {return new NativeDate(...arguments);}}
"
;
// Simple desactivation of direct access of all globals
// It is still accessible in reality, but it will me more visible
// if people really access them
if
(
spawnDrone_x
!==
null
&&
spawnDrone_y
!==
null
&&
spawnDrone_z
!==
null
)
{
code_eval
+=
"
me.setStartingPosition(
"
+
spawnDrone_x
+
"
,
"
+
spawnDrone_y
+
"
,
"
+
spawnDrone_z
+
"
);
"
;
}
//base = code_eval;
code_eval
+=
spawnDrone_code
+
"
}; droneMe(Date, spawnDrone_drone, Math, {});
"
;
//base +=
// "};spawnDrone_droneList_" + spawnDrone_team + ".push(spawnDrone_drone)";
code_eval
+=
"
spawnDrone_droneList_
"
+
spawnDrone_team
+
"
.push(spawnDrone_drone)
"
;
/*jslint evil: true*/
eval
(
code_eval
);
/*jslint evil: false*/
/*try {
eval(code_eval);
} catch (error) {
eval(base);
}*/
}
/******************************* DRONE MANAGER ********************************/
var
DroneManager
=
/** @class */
(
function
()
{
"
use strict
"
;
...
...
@@ -27,6 +77,7 @@ var DroneManager = /** @class */ (function () {
this
.
_maxClimbRate
=
0
;
this
.
_maxCommandFrequency
=
0
;
this
.
_last_command_timestamp
=
0
;
this
.
_last_onUpdate_timestamp
=
0
;
this
.
_speed
=
0
;
this
.
_acceleration
=
0
;
this
.
_direction
=
new
BABYLON
.
Vector3
(
0
,
0
,
1
);
// North
...
...
@@ -135,29 +186,39 @@ var DroneManager = /** @class */ (function () {
this
.
_canPlay
=
true
;
this
.
_canCommunicate
=
true
;
try
{
return
this
.
onStart
(
this
.
_API
.
_gameManager
.
_
game_duration
);
return
this
.
onStart
(
this
.
_API
.
_gameManager
.
_
start_time
);
}
catch
(
error
)
{
console
.
warn
(
'
Drone crashed on start due to error:
'
,
error
);
this
.
_internal_crash
(
error
);
}
};
DroneManager
.
prototype
.
_callSetTargetCommand
=
function
(
latitude
,
longitude
,
altitude
,
speed
,
radius
)
{
var
current_time
=
this
.
_API
.
_gameManager
.
getCurrentTime
();
if
(
!
this
.
isReadyToFly
())
{
return
;
}
if
(
current_time
-
this
.
_last_command_timestamp
<
1000
/
this
.
_API
.
getMaxCommandFrequency
())
{
this
.
_internal_crash
(
new
Error
(
'
Minimum interval between commands is
'
+
1000
/
this
.
_API
.
getMaxCommandFrequency
()
+
'
milliseconds
'
));
}
this
.
_internal_setTargetCoordinates
(
latitude
,
longitude
,
altitude
,
speed
,
radius
);
this
.
_last_command_timestamp
=
current_time
;
};
/**
* Set a target point to move
*/
DroneManager
.
prototype
.
setTargetCoordinates
=
function
(
latitude
,
longitude
,
altitude
,
speed
)
{
this
.
_
internal_setTargetCoordinates
(
latitude
,
longitude
,
altitude
,
speed
);
this
.
_
callSetTargetCommand
(
latitude
,
longitude
,
altitude
,
speed
);
};
DroneManager
.
prototype
.
_internal_setTargetCoordinates
=
function
(
latitude
,
longitude
,
altitude
,
speed
,
radius
)
{
if
(
!
this
.
_canPlay
||
!
this
.
isReadyToFly
()
)
{
if
(
!
this
.
_canPlay
)
{
return
;
}
if
(
this
.
_API
.
_gameManager
.
_game_duration
-
this
.
_last_command_timestamp
<
1000
/
this
.
_API
.
getMaxCommandFrequency
())
{
this
.
_internal_crash
(
new
Error
(
'
Minimum interval between commands is
'
+
1000
/
this
.
_API
.
getMaxCommandFrequency
()
+
'
milliseconds
'
));
}
//each drone API process coordinates on its needs
//e.g. fixedwing drone converts real geo-coordinates to virtual x-y
this
.
_targetCoordinates
=
...
...
@@ -168,7 +229,6 @@ var DroneManager = /** @class */ (function () {
speed
,
radius
);
this
.
_last_command_timestamp
=
this
.
_API
.
_gameManager
.
_game_duration
;
};
DroneManager
.
prototype
.
getDroneDict
=
function
()
{
return
this
.
_API
.
_drone_dict_list
;
...
...
@@ -184,15 +244,29 @@ var DroneManager = /** @class */ (function () {
return
;
};
DroneManager
.
prototype
.
internal_update
=
function
(
delta_time
)
{
var
context
=
this
,
milliseconds
;
var
context
=
this
,
current_time
=
this
.
_API
.
_gameManager
.
getCurrentTime
(),
onUpdate_interval
=
this
.
_API
.
getOnUpdateInterval
(),
onUpdate_start
;
if
(
this
.
_controlMesh
)
{
context
.
_API
.
internal_update
(
context
,
delta_time
);
if
(
context
.
_canUpdate
)
{
context
.
_API
.
internal_position_update
(
context
,
delta_time
);
if
(
context
.
_canUpdate
&&
current_time
-
this
.
_last_onUpdate_timestamp
>=
onUpdate_interval
)
{
context
.
_canUpdate
=
false
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
milliseconds
=
Math
.
floor
(
context
.
_API
.
_gameManager
.
_game_duration
);
return
context
.
onUpdate
(
milliseconds
);
onUpdate_start
=
Date
.
now
();
context
.
_last_onUpdate_timestamp
=
current_time
;
context
.
onUpdate
(
current_time
);
if
(
onUpdate_interval
>
0
&&
Date
.
now
()
-
onUpdate_start
>
onUpdate_interval
)
{
throw
new
Error
(
'
onUpdate execution took
'
+
(
Date
.
now
()
-
onUpdate_start
)
+
'
milliseconds but loop interval is only
'
+
onUpdate_interval
+
'
milliseconds
'
);
}
return
;
})
.
push
(
function
()
{
context
.
_canUpdate
=
true
;
...
...
@@ -201,7 +275,7 @@ var DroneManager = /** @class */ (function () {
context
.
_internal_crash
(
error
);
})
.
push
(
function
()
{
context
.
_API
.
internal_
post
_update
(
context
);
context
.
_API
.
internal_
info
_update
(
context
);
})
.
push
(
undefined
,
function
(
error
)
{
console
.
warn
(
'
Drone crashed on update due to error:
'
,
error
);
...
...
@@ -305,7 +379,7 @@ var DroneManager = /** @class */ (function () {
this
.
_controlMesh
.
position
.
z
,
this
.
_controlMesh
.
position
.
y
);
position
.
timestamp
=
this
.
_API
.
_gameManager
.
_game_duration
;
position
.
timestamp
=
this
.
_API
.
_gameManager
.
getCurrentTime
()
;
//Backward compatibility sanitation
position
.
x
=
position
.
latitude
;
position
.
y
=
position
.
longitude
;
...
...
@@ -319,13 +393,7 @@ var DroneManager = /** @class */ (function () {
*/
DroneManager
.
prototype
.
loiter
=
function
(
latitude
,
longitude
,
altitude
,
radius
,
speed
)
{
this
.
_internal_setTargetCoordinates
(
latitude
,
longitude
,
altitude
,
speed
,
radius
);
this
.
_callSetTargetCommand
(
latitude
,
longitude
,
altitude
,
speed
,
radius
);
};
DroneManager
.
prototype
.
getFlightParameters
=
function
()
{
if
(
this
.
_API
.
getFlightParameters
)
{
...
...
@@ -333,6 +401,9 @@ var DroneManager = /** @class */ (function () {
}
return
null
;
};
DroneManager
.
prototype
.
getMaxCommandFrequency
=
function
()
{
return
this
.
_API
.
getMaxCommandFrequency
();
};
DroneManager
.
prototype
.
getYaw
=
function
()
{
if
(
this
.
_API
.
getYaw
!==
undefined
)
{
return
this
.
_API
.
getYaw
(
this
);
...
...
@@ -358,7 +429,9 @@ var DroneManager = /** @class */ (function () {
return
this
.
_API
.
takeOff
();
};
DroneManager
.
prototype
.
land
=
function
()
{
if
(
!
this
.
isLanding
())
{
return
this
.
_API
.
land
(
this
);
}
};
DroneManager
.
prototype
.
exit
=
function
()
{
return
this
.
_internal_crash
();
...
...
@@ -916,7 +989,6 @@ var GameManager = /** @class */ (function () {
this
.
_droneList
.
forEach
(
function
(
drone
)
{
queue
.
push
(
function
()
{
drone
.
_tick
+=
1
;
if
(
drone
.
can_play
)
{
if
(
drone
.
getCurrentPosition
().
altitude
<=
0
)
{
if
(
!
drone
.
isLanding
())
{
...
...
@@ -976,7 +1048,8 @@ var GameManager = /** @class */ (function () {
this
.
_game_duration
+=
delta_time
;
var
color
,
drone_position
,
game_manager
=
this
,
geo_coordinates
,
log_count
,
map_info
,
map_manager
,
material
,
position_obj
,
seconds
=
Math
.
floor
(
this
.
_game_duration
/
1000
),
trace_objects
;
current_time
=
this
.
getCurrentTime
(),
seconds
=
Math
.
floor
(
current_time
/
1000
),
trace_objects
;
if
(
GAMEPARAMETERS
.
log_drone_flight
||
GAMEPARAMETERS
.
draw_flight_path
)
{
this
.
_droneList_user
.
forEach
(
function
(
drone
,
index
)
{
...
...
@@ -995,7 +1068,7 @@ var GameManager = /** @class */ (function () {
drone_position
.
z
);
game_manager
.
_flight_log
[
index
].
push
([
game_manager
.
_game_duration
,
geo_coordinates
.
latitude
,
current_time
,
geo_coordinates
.
latitude
,
geo_coordinates
.
longitude
,
map_info
.
start_AMSL
+
drone_position
.
z
,
drone_position
.
z
,
drone
.
getYaw
(),
drone
.
getSpeed
(),
...
...
@@ -1043,8 +1116,7 @@ var GameManager = /** @class */ (function () {
};
GameManager
.
prototype
.
_timeOut
=
function
()
{
var
seconds
=
Math
.
floor
(
this
.
_game_duration
/
1000
);
return
this
.
_totalTime
-
seconds
<=
0
;
return
this
.
_totalTime
-
this
.
_game_duration
<=
0
;
};
GameManager
.
prototype
.
_allDronesFinished
=
function
()
{
...
...
@@ -1226,20 +1298,19 @@ var GameManager = /** @class */ (function () {
_this
.
ongoing_update_promise
=
null
;
_this
.
finish_deferred
=
RSVP
.
defer
();
console
.
log
(
"
Simulation started.
"
);
this
.
_game_duration
=
Date
.
now
();
this
.
_totalTime
=
GAMEPARAMETERS
.
gameTime
+
this
.
_game_duration
;
this
.
_start_time
=
Date
.
now
();
this
.
_game_duration
=
0
;
this
.
_totalTime
=
GAMEPARAMETERS
.
gameTime
*
1000
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
promise_list
=
[];
_this
.
_droneList_user
.
forEach
(
function
(
drone
)
{
drone
.
_tick
=
0
;
promise_list
.
push
(
drone
.
internal_start
());
});
start_msg
=
GAMEPARAMETERS
.
operator_init_msg
;
promise_list
.
push
(
_this
.
_droneList_user
[
0
].
sendMsg
(
start_msg
));
_this
.
_droneList_enemy
.
forEach
(
function
(
drone
)
{
drone
.
_tick
=
0
;
promise_list
.
push
(
drone
.
internal_start
());
});
return
RSVP
.
all
(
promise_list
);
...
...
@@ -1310,47 +1381,6 @@ var GameManager = /** @class */ (function () {
}
return
false
;
}
function
spawnDrone
(
x
,
y
,
z
,
index
,
drone_info
,
api
,
team
)
{
var
default_drone_AI
=
api
.
getDroneAI
(),
code
,
code_eval
;
if
(
default_drone_AI
)
{
code
=
default_drone_AI
;
}
else
{
code
=
drone_info
.
script_content
;
}
if
(
!
code
.
includes
(
"
me.onStart
"
))
{
code
=
"
me.onStart = function () { me.exit(); };
"
;
}
code_eval
=
"
let drone = new DroneManager(ctx._scene,
"
+
index
+
'
, api, team);
'
+
"
let droneMe = function(NativeDate, me, Math, window, DroneManager,
"
+
"
GameManager, FixedWingDroneAPI, EnemyDroneAPI, BABYLON,
"
+
"
GAMEPARAMETERS) {
"
+
"
var start_time = (new Date(2070, 0, 0, 0, 0, 0, 0)).getTime();
"
+
"
Date.now = function () {
"
+
"
return start_time + drone._tick * 1000/60;};
"
+
"
function Date() {if (!(this instanceof Date))
"
+
"
{throw new Error('Missing new operator');}
"
+
"
if (arguments.length === 0) {return new NativeDate(Date.now());}
"
+
"
else {return new NativeDate(...arguments);}}
"
;
// Simple desactivation of direct access of all globals
// It is still accessible in reality, but it will me more visible
// if people really access them
if
(
x
!==
null
&&
y
!==
null
&&
z
!==
null
)
{
code_eval
+=
"
me.setStartingPosition(
"
+
x
+
"
,
"
+
y
+
"
,
"
+
z
+
"
);
"
;
}
//base = code_eval;
code_eval
+=
code
+
"
}; droneMe(Date, drone, Math, {});
"
;
//base += "};ctx._droneList_" + team + ".push(drone)";
code_eval
+=
"
ctx._droneList_
"
+
team
+
"
.push(drone)
"
;
/*jslint evil: true*/
eval
(
code_eval
);
/*jslint evil: false*/
/*try {
eval(code_eval);
} catch (error) {
eval(base);
}*/
}
function
randomSpherePoint
(
x0
,
y0
,
z0
,
rx0
,
ry0
,
rz0
)
{
var
u
=
Math
.
random
(),
v
=
Math
.
random
(),
rx
=
Math
.
random
()
*
rx0
,
ry
=
Math
.
random
()
*
ry0
,
...
...
@@ -1384,11 +1414,16 @@ var GameManager = /** @class */ (function () {
i
+
id_offset
);
spawnDrone
(
position
.
x
,
position
.
y
,
position
.
z
,
i
+
id_offset
,
drone_list
[
i
],
api
,
team
);
drone_list
[
i
],
api
,
team
,
ctx
.
_scene
,
ctx
.
_droneList_user
,
ctx
.
_droneList_enemy
);
}
}
};
GameManager
.
prototype
.
getCurrentTime
=
function
()
{
return
this
.
_start_time
+
this
.
_game_duration
;
};
return
GameManager
;
}());
...
...
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/drone_capture_flag_logic_js.xml
View file @
2d2050eb
...
...
@@ -246,7 +246,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
101
4.65026.25145.27272
</string>
</value>
<value>
<string>
101
6.21978.22579.46609
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>
17
09560433.33
</float>
<float>
17
14742387.62
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/ojs_drone_capture_flag_API_page_html.html
View file @
2d2050eb
...
...
@@ -381,6 +381,19 @@
<div
class=
"line"
></div>
<!-- getMaxCommandFrequency -->
<h4
class=
"item-name"
id=
"getMaxCommandFrequency"
><span>
getMaxCommandFrequency
</span><span>
: void
</span></h4>
<p
class=
"item-descr"
>
Get maximum frequency in hertz at which direction commands (setTargetCoordinates and loiter) can be called.
</p>
<div>
<h5
class=
"item-param-1"
>
Example
</h5>
</div>
<p
class=
"item-param-1"
>
me.getMaxCommandFrequency();
<br>
</p>
<div
class=
"line"
></div>
<!-- takeOff -->
<h4
class=
"item-name"
id=
"takeOff"
><span>
takeOff
</span><span>
: void
</span></h4>
<p
class=
"item-descr"
>
Trigger drone's takeoff (has only effect on multicopters as fixed wings drones need to take off manually).
</p>
...
...
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/ojs_drone_capture_flag_API_page_html.xml
View file @
2d2050eb
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
101
4.65292.62763.3464
</string>
</value>
<value>
<string>
101
5.13928.44848.25668
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -264,7 +264,7 @@
</tuple>
<state>
<tuple>
<float>
17
09564153.67
</float>
<float>
17
10867839.5
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/ojs_drone_capture_flag_script_page_js.js
View file @
2d2050eb
...
...
@@ -185,6 +185,7 @@ var OperatorAPI = /** @class */ (function () {
DRAW
=
true
,
LOG
=
true
,
LOG_TIME
=
1662.7915426540285
,
ONUPDATE_INTERVAL
=
100
,
LOGIC_FILE_LIST
=
[
'
gadget_erp5_page_drone_capture_flag_logic.js
'
,
'
gadget_erp5_page_drone_capture_map_utils.js
'
,
...
...
@@ -566,6 +567,17 @@ var OperatorAPI = /** @class */ (function () {
"
hidden
"
:
0
,
"
type
"
:
"
IntegerField
"
},
"
my_onupdate_interval
"
:
{
"
description
"
:
"
Minimum interval (in milliseconds) between 2 executions of onUpdate function as well as periodicity to send telemetry to the swarm
"
,
"
title
"
:
"
OnUpdate interval
"
,
"
default
"
:
gadget
.
state
.
onupdate_interval
,
"
css_class
"
:
""
,
"
required
"
:
1
,
"
editable
"
:
1
,
"
key
"
:
"
onupdate_interval
"
,
"
hidden
"
:
0
,
"
type
"
:
"
IntegerField
"
},
"
my_drone_min_speed
"
:
{
"
description
"
:
""
,
"
title
"
:
"
Drone min speed
"
,
...
...
@@ -708,7 +720,7 @@ var OperatorAPI = /** @class */ (function () {
form_definition
:
{
group_list
:
[[
"
left
"
,
[[
"
my_simulation_speed
"
],
[
"
my_simulation_time
"
],
[[
"
my_simulation_speed
"
],
[
"
my_simulation_time
"
],
[
"
my_onupdate_interval
"
],
[
"
my_number_of_drones
"
],
[
"
my_map_seed
"
]]
],
[
"
right
"
,
...
...
@@ -845,6 +857,7 @@ var OperatorAPI = /** @class */ (function () {
"
maxSinkRate
"
:
parseFloat
(
gadget
.
state
.
drone_max_sink_rate
),
"
maxClimbRate
"
:
parseFloat
(
gadget
.
state
.
drone_max_climb_rate
),
"
maxCommandFrequency
"
:
parseFloat
(
gadget
.
state
.
drone_max_command_frequency
),
"
onUpdateInterval
"
:
parseInt
(
gadget
.
state
.
onupdate_interval
,
10
),
"
list
"
:
drone_list
},
"
gameTime
"
:
parseInt
(
gadget
.
state
.
simulation_time
,
10
),
...
...
@@ -970,6 +983,7 @@ var OperatorAPI = /** @class */ (function () {
drone_max_speed
:
MAX_SPEED
,
drone_speed
:
DEFAULT_SPEED
,
drone_min_speed
:
MIN_SPEED
,
onupdate_interval
:
ONUPDATE_INTERVAL
,
simulation_time
:
SIMULATION_TIME
,
simulation_speed
:
SIMULATION_SPEED
,
operator_init_msg
:
{},
...
...
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/ojs_drone_capture_flag_script_page_js.xml
View file @
2d2050eb
...
...
@@ -246,7 +246,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
101
4.48194.32365.65399
</string>
</value>
<value>
<string>
101
6.21921.52144.47906
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>
17
08709921.07
</float>
<float>
17
14738877.83
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_capture_flag_test/PathTemplateItem/web_page_module/test_capture_drone_flight_js.js
View file @
2d2050eb
...
...
@@ -3,8 +3,10 @@
(
function
(
window
,
rJS
,
domsugar
,
document
)
{
"
use strict
"
;
var
SIMULATION_SPEED
=
10
,
SIMULATION_TIME
=
270
,
var
SIMULATION_SPEED
=
1
,
LOOP_INTERVAL
=
1000
/
60
,
ON_UPDATE_INTERVAL
=
LOOP_INTERVAL
,
SIMULATION_TIME
=
LOOP_INTERVAL
/
1000
,
MIN_LAT
=
45.6364
,
MAX_LAT
=
45.65
,
MIN_LON
=
14.2521
,
...
...
@@ -74,9 +76,10 @@
'
me.getCurrentPosition().longitude
\n
'
+
'
).toFixed(8),
\n
'
+
'
time_interval = timestamp - me.start_time,
\n
'
+
'
expected_interval =
1000 / 60
,
\n
'
+
'
expected_interval =
'
+
LOOP_INTERVAL
+
'
,
\n
'
+
'
expectedDistance = (me.getSpeed() * expected_interval / 1000).toFixed(8);
\n
'
+
'
assert(time_interval, Math.floor(expected_interval), "Timestamp");
\n
'
+
'
assert(time_interval.toFixed(4), expected_interval.toFixed(4), "Timestamp");
\n
'
+
'
assert(Date.now(), timestamp, "Date");
\n
'
+
'
assert(realDistance, expectedDistance, "Distance");
\n
'
+
'
current_position.latitude = current_position.latitude.toFixed(7);
\n
'
+
'
compare(current_position, {
\n
'
+
...
...
@@ -84,7 +87,6 @@
'
longitude: me.initialPosition.longitude,
\n
'
+
'
altitude: me.initialPosition.altitude
\n
'
+
'
});
\n
'
+
'
me.exit(me.land());
\n
'
+
'
};
'
,
DRAW
=
true
,
LOG
=
true
,
...
...
@@ -120,19 +122,19 @@
"
script_content
"
:
DEFAULT_SCRIPT_CONTENT
};
}
map_json
=
{
"
height
"
:
parseInt
(
map_height
,
10
)
,
"
start_AMSL
"
:
parseFloat
(
start_AMSL
)
,
"
min_lat
"
:
parseFloat
(
MIN_LAT
)
,
"
max_lat
"
:
parseFloat
(
MAX_LAT
)
,
"
min_lon
"
:
parseFloat
(
MIN_LON
)
,
"
max_lon
"
:
parseFloat
(
MAX_LON
)
,
"
height
"
:
map_height
,
"
start_AMSL
"
:
start_AMSL
,
"
min_lat
"
:
MIN_LAT
,
"
max_lat
"
:
MAX_LAT
,
"
min_lon
"
:
MIN_LON
,
"
max_lon
"
:
MAX_LON
,
"
flag_list
"
:
[],
"
obstacle_list
"
:
[],
"
enemy_list
"
:
[],
"
initial_position
"
:
{
"
longitude
"
:
parseFloat
(
INIT_LON
)
,
"
latitude
"
:
parseFloat
(
INIT_LAT
)
,
"
altitude
"
:
parseFloat
(
INIT_ALT
)
"
longitude
"
:
INIT_LON
,
"
latitude
"
:
INIT_LAT
,
"
altitude
"
:
INIT_ALT
}
};
operator_init_msg
=
{
...
...
@@ -142,20 +144,21 @@
game_parameters_json
=
{
"
debug_test_mode
"
:
true
,
"
drone
"
:
{
"
maxAcceleration
"
:
parseInt
(
MAX_ACCELERATION
,
10
),
"
maxDeceleration
"
:
parseInt
(
MAX_DECELERATION
,
10
),
"
minSpeed
"
:
parseInt
(
MIN_SPEED
,
10
),
"
speed
"
:
parseFloat
(
DEFAULT_SPEED
),
"
maxSpeed
"
:
parseInt
(
MAX_SPEED
,
10
),
"
maxRoll
"
:
parseFloat
(
MAX_ROLL
),
"
minPitchAngle
"
:
parseFloat
(
MIN_PITCH
),
"
maxPitchAngle
"
:
parseFloat
(
MAX_PITCH
),
"
maxSinkRate
"
:
parseFloat
(
MAX_SINK_RATE
),
"
maxClimbRate
"
:
parseFloat
(
MAX_CLIMB_RATE
),
"
maxAcceleration
"
:
MAX_ACCELERATION
,
"
maxDeceleration
"
:
MAX_DECELERATION
,
"
minSpeed
"
:
MIN_SPEED
,
"
speed
"
:
DEFAULT_SPEED
,
"
maxSpeed
"
:
MAX_SPEED
,
"
maxRoll
"
:
MAX_ROLL
,
"
minPitchAngle
"
:
MIN_PITCH
,
"
maxPitchAngle
"
:
MAX_PITCH
,
"
maxSinkRate
"
:
MAX_SINK_RATE
,
"
maxClimbRate
"
:
MAX_CLIMB_RATE
,
"
onUpdateInterval
"
:
ON_UPDATE_INTERVAL
,
"
list
"
:
DRONE_LIST
},
"
gameTime
"
:
parseInt
(
SIMULATION_TIME
,
10
)
,
"
simulation_speed
"
:
parseInt
(
SIMULATION_SPEED
,
10
)
,
"
gameTime
"
:
SIMULATION_TIME
,
"
simulation_speed
"
:
SIMULATION_SPEED
,
"
latency
"
:
{
"
information
"
:
0
,
"
communication
"
:
0
...
...
@@ -214,19 +217,24 @@
})
.
push
(
function
(
result
)
{
var
div
=
domsugar
(
'
div
'
,
{
text
:
"
CONSOLE LOG ENTRIES:
"
}),
lines
,
l
,
node
;
l
,
test_log_node
=
document
.
querySelector
(
'
.test_log
'
)
;
document
.
querySelector
(
'
.container
'
).
parentNode
.
appendChild
(
div
);
function
createLogNode
(
message
)
{
function
appendToTestLog
(
test_log_node
,
message
)
{
var
log_node
=
document
.
createElement
(
"
div
"
),
textNode
=
document
.
createTextNode
(
message
);
log_node
.
appendChild
(
textNode
);
return
log_node
;
test_log_node
.
appendChild
(
log_node
)
;
}
lines
=
result
.
console_log
.
split
(
'
\n
'
);
for
(
l
=
0
;
l
<
lines
.
length
;
l
+=
1
)
{
node
=
createLogNode
(
lines
[
l
]);
document
.
querySelector
(
'
.test_log
'
).
appendChild
(
node
);
if
(
lines
[
l
]
!==
'
TIMEOUT!
'
)
{
appendToTestLog
(
test_log_node
,
lines
[
l
]);
}
else
{
appendToTestLog
(
test_log_node
,
'
Timeout: OK
'
);
return
;
}
}
appendToTestLog
(
test_log_node
,
'
Timeout: FAILED
'
);
},
function
(
error
)
{
return
gadget
.
notifySubmitted
({
message
:
"
Error:
"
+
error
.
message
,
status
:
'
error
'
});
...
...
bt5/erp5_officejs_drone_capture_flag_test/PathTemplateItem/web_page_module/test_capture_drone_flight_js.xml
View file @
2d2050eb
...
...
@@ -246,7 +246,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
101
4.60680.20078.3428
6
</string>
</value>
<value>
<string>
101
5.64187.34381.5034
6
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>
17
09286290.59
</float>
<float>
17
13428877.4
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_dronelogfollower_js.js
View file @
2d2050eb
...
...
@@ -80,7 +80,7 @@ var DroneLogAPI = /** @class */ (function () {
/*
** Function called on every drone update, right before onUpdate AI script
*/
DroneLogAPI
.
prototype
.
internal_update
=
function
(
context
,
delta_time
)
{
DroneLogAPI
.
prototype
.
internal_
position_
update
=
function
(
context
,
delta_time
)
{
var
updateSpeed
;
context
.
_speed
+=
context
.
_acceleration
*
delta_time
/
1000
;
if
(
context
.
_speed
>
context
.
_maxSpeed
)
{
...
...
@@ -104,7 +104,7 @@ var DroneLogAPI = /** @class */ (function () {
/*
** Function called on every drone update, right after onUpdate AI script
*/
DroneLogAPI
.
prototype
.
internal_
post
_update
=
function
(
drone
)
{
DroneLogAPI
.
prototype
.
internal_
info
_update
=
function
(
drone
)
{
return
;
};
DroneLogAPI
.
prototype
.
internal_setTargetCoordinates
=
...
...
@@ -213,6 +213,9 @@ var DroneLogAPI = /** @class */ (function () {
DroneLogAPI
.
prototype
.
getMaxCommandFrequency
=
function
()
{
return
Infinity
;
};
DroneLogAPI
.
prototype
.
getOnUpdateInterval
=
function
()
{
return
0
;
};
return
DroneLogAPI
;
}());
\ No newline at end of file
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_dronelogfollower_js.xml
View file @
2d2050eb
...
...
@@ -246,7 +246,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
101
4.60631.26636.59528
</string>
</value>
<value>
<string>
101
5.64101.28159.26163
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>
17
09288518.39
</float>
<float>
17
13425784.77
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_fixedwingdrone_js.js
View file @
2d2050eb
...
...
@@ -7,6 +7,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
// var TAKEOFF_RADIUS = 60,
var
DEFAULT_SPEED
=
16
,
PARACHUTE_SPEED
=
8
,
EARTH_GRAVITY
=
9.81
,
LOITER_LIMIT
=
30
,
MAX_ACCELERATION
=
6
,
...
...
@@ -52,7 +53,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
throw
new
Error
(
'
max acceleration must be superior to 0
'
);
}
drone
.
_minSpeed
=
this
.
getMinSpeed
();
if
(
drone
.
_minSpeed
<
=
0
)
{
if
(
drone
.
_minSpeed
<
0
)
{
throw
new
Error
(
'
min speed must be superior to 0
'
);
}
drone
.
_maxSpeed
=
this
.
getMaxSpeed
();
...
...
@@ -101,7 +102,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
/*
** Function called on every drone update, right before onUpdate AI script
*/
FixedWingDroneAPI
.
prototype
.
internal_update
=
function
(
context
,
delta_time
)
{
FixedWingDroneAPI
.
prototype
.
internal_
position_
update
=
function
(
context
,
delta_time
)
{
this
.
_updateSpeed
(
context
,
delta_time
);
this
.
_updatePosition
(
context
,
delta_time
);
...
...
@@ -111,7 +112,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
/*
** Function called on every drone update, right after onUpdate AI script
*/
FixedWingDroneAPI
.
prototype
.
internal_
post
_update
=
function
(
drone
)
{
FixedWingDroneAPI
.
prototype
.
internal_
info
_update
=
function
(
drone
)
{
var
_this
=
this
,
drone_position
=
drone
.
getCurrentPosition
(),
drone_info
;
/*if (_this._start_altitude > 0) { //TODO move start_altitude here
_this.reachAltitude(drone);
...
...
@@ -373,8 +374,6 @@ var FixedWingDroneAPI = /** @class */ (function () {
var
processed_coordinates
=
this
.
_mapManager
.
convertToLocalCoordinates
(
lat
,
lon
,
z
);
processed_coordinates
.
z
-=
this
.
_map_dict
.
start_AMSL
;
//this._last_altitude_point_reached = -1;
//this.takeoff_path = [];
return
processed_coordinates
;
};
FixedWingDroneAPI
.
prototype
.
getCurrentPosition
=
function
(
x
,
y
,
z
)
{
...
...
@@ -470,11 +469,16 @@ var FixedWingDroneAPI = /** @class */ (function () {
};
FixedWingDroneAPI
.
prototype
.
land
=
function
(
drone
)
{
var
drone_pos
=
drone
.
getCurrentPosition
();
drone
.
setTargetCoordinates
(
this
.
_flight_parameters
.
drone
.
minSpeed
=
0
;
drone
.
_speed
=
0
;
drone
.
_acceleration
=
EARTH_GRAVITY
;
this
.
_flight_parameters
.
drone
.
maxSinkRate
=
PARACHUTE_SPEED
;
this
.
_flight_parameters
.
drone
.
minPitchAngle
=
-
90
;
drone
.
_internal_setTargetCoordinates
(
drone_pos
.
latitude
,
drone_pos
.
longitude
,
0
,
drone
.
get3DSpeed
()
PARACHUTE_SPEED
);
this
.
_is_ready_to_fly
=
false
;
this
.
_is_landing
=
true
;
...
...
@@ -497,6 +501,9 @@ var FixedWingDroneAPI = /** @class */ (function () {
FixedWingDroneAPI
.
prototype
.
getMaxHeight
=
function
()
{
return
800
;
};
FixedWingDroneAPI
.
prototype
.
getOnUpdateInterval
=
function
()
{
return
this
.
_flight_parameters
.
drone
.
onUpdateInterval
;
};
FixedWingDroneAPI
.
prototype
.
getFlightParameters
=
function
()
{
return
this
.
_flight_parameters
;
};
...
...
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_fixedwingdrone_js.xml
View file @
2d2050eb
...
...
@@ -240,7 +240,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
101
4.60733.7318.44953
</string>
</value>
<value>
<string>
101
5.64203.48820.61559
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>
17
09562449.93
</float>
<float>
17
13429850.09
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_logic_js.js
View file @
2d2050eb
...
...
@@ -6,6 +6,50 @@ var GAMEPARAMETERS = {};
//for DEBUG/TEST mode
var
baseLogFunction
=
console
.
log
,
console_log
=
""
;
function
spawnDrone
(
spawnDrone_x
,
spawnDrone_y
,
spawnDrone_z
,
spawnDrone_index
,
spawnDrone_drone_info
,
spawnDrone_api
,
spawnDrone_scene
,
spawnDrone_droneList
)
{
"
use strict
"
;
var
default_drone_AI
=
spawnDrone_api
.
getDroneAI
(),
spawnDrone_code
,
spawnDrone_base
,
code_eval
;
if
(
default_drone_AI
)
{
spawnDrone_code
=
default_drone_AI
;
}
else
{
spawnDrone_code
=
spawnDrone_drone_info
.
script_content
;
}
code_eval
=
"
let spawnDrone_drone = new DroneManager(spawnDrone_scene,
"
+
spawnDrone_index
+
'
, spawnDrone_api);
'
+
"
let droneMe = function(NativeDate, me, Math, window, DroneManager,
"
+
"
GameManager, DroneLogAPI, FixedWingDroneAPI, BABYLON,
"
+
"
GAMEPARAMETERS) {
"
+
"
Date.now = function () {
"
+
"
return me._API._gameManager.getCurrentTime();};
"
+
"
function Date() {if (!(this instanceof Date))
"
+
"
{throw new Error('Missing new operator');}
"
+
"
if (arguments.length === 0) {return new NativeDate(Date.now());}
"
+
"
else {return new NativeDate(...arguments);}}
"
;
// Simple desactivation of direct access of all globals
// It is still accessible in reality, but it will me more visible
// if people really access them
if
(
spawnDrone_x
!==
null
&&
spawnDrone_y
!==
null
&&
spawnDrone_z
!==
null
)
{
code_eval
+=
"
me.setStartingPosition(
"
+
spawnDrone_x
+
"
,
"
+
spawnDrone_y
+
"
,
"
+
spawnDrone_z
+
"
);
"
;
}
spawnDrone_base
=
code_eval
;
code_eval
+=
spawnDrone_code
+
"
}; droneMe(Date, spawnDrone_drone, Math, {});
"
;
spawnDrone_base
+=
"
};spawnDrone_droneList.push(spawnDrone_drone)
"
;
code_eval
+=
"
spawnDrone_droneList.push(spawnDrone_drone)
"
;
/*jslint evil: true*/
try
{
eval
(
code_eval
);
}
catch
(
error
)
{
console
.
error
(
error
);
eval
(
spawnDrone_base
);
}
/*jslint evil: false*/
}
/******************************* DRONE MANAGER ********************************/
var
DroneManager
=
/** @class */
(
function
()
{
"
use strict
"
;
...
...
@@ -27,6 +71,7 @@ var DroneManager = /** @class */ (function () {
this
.
_maxClimbRate
=
0
;
this
.
_maxCommandFrequency
=
0
;
this
.
_last_command_timestamp
=
0
;
this
.
_last_onUpdate_timestamp
=
0
;
this
.
_speed
=
0
;
this
.
_acceleration
=
0
;
this
.
_direction
=
new
BABYLON
.
Vector3
(
0
,
0
,
1
);
// North
...
...
@@ -124,29 +169,39 @@ var DroneManager = /** @class */ (function () {
this
.
_canCommunicate
=
true
;
this
.
_targetCoordinates
=
initial_position
;
try
{
return
this
.
onStart
(
this
.
_API
.
_gameManager
.
_
game_duration
);
return
this
.
onStart
(
this
.
_API
.
_gameManager
.
_
start_time
);
}
catch
(
error
)
{
console
.
warn
(
'
Drone crashed on start due to error:
'
,
error
);
this
.
_internal_crash
(
error
);
}
};
DroneManager
.
prototype
.
_callSetTargetCommand
=
function
(
latitude
,
longitude
,
altitude
,
speed
,
radius
)
{
var
current_time
=
this
.
_API
.
_gameManager
.
getCurrentTime
();
if
(
!
this
.
isReadyToFly
())
{
return
;
}
if
(
current_time
-
this
.
_last_command_timestamp
<
1000
/
this
.
_API
.
getMaxCommandFrequency
())
{
this
.
_internal_crash
(
new
Error
(
'
Minimum interval between commands is
'
+
1000
/
this
.
_API
.
getMaxCommandFrequency
()
+
'
milliseconds
'
));
}
this
.
_internal_setTargetCoordinates
(
latitude
,
longitude
,
altitude
,
speed
,
radius
);
this
.
_last_command_timestamp
=
current_time
;
};
/**
* Set a target point to move
*/
DroneManager
.
prototype
.
setTargetCoordinates
=
function
(
latitude
,
longitude
,
altitude
,
speed
)
{
this
.
_
internal_setTargetCoordinates
(
latitude
,
longitude
,
altitude
,
speed
);
this
.
_
callSetTargetCommand
(
latitude
,
longitude
,
altitude
,
speed
);
};
DroneManager
.
prototype
.
_internal_setTargetCoordinates
=
function
(
latitude
,
longitude
,
altitude
,
speed
,
radius
)
{
if
(
!
this
.
_canPlay
||
!
this
.
isReadyToFly
()
)
{
if
(
!
this
.
_canPlay
)
{
return
;
}
if
(
this
.
_API
.
_gameManager
.
_game_duration
-
this
.
_last_command_timestamp
<
1000
/
this
.
_API
.
getMaxCommandFrequency
())
{
this
.
_internal_crash
(
new
Error
(
'
Minimum interval between commands is
'
+
1000
/
this
.
_API
.
getMaxCommandFrequency
()
+
'
milliseconds
'
));
}
//convert real geo-coordinates to virtual x-y coordinates
this
.
_targetCoordinates
=
this
.
_API
.
processCoordinates
(
latitude
,
longitude
,
altitude
);
...
...
@@ -156,17 +211,30 @@ var DroneManager = /** @class */ (function () {
speed
,
radius
);
this
.
_last_command_timestamp
=
this
.
_API
.
_gameManager
.
_game_duration
;
};
DroneManager
.
prototype
.
internal_update
=
function
(
delta_time
)
{
var
context
=
this
;
var
context
=
this
,
current_time
=
this
.
_API
.
_gameManager
.
getCurrentTime
(),
onUpdate_interval
=
this
.
_API
.
getOnUpdateInterval
(),
onUpdate_start
;
if
(
this
.
_controlMesh
)
{
context
.
_API
.
internal_update
(
context
,
delta_time
);
if
(
context
.
_canUpdate
)
{
context
.
_API
.
internal_position_update
(
context
,
delta_time
);
if
(
context
.
_canUpdate
&&
current_time
-
this
.
_last_onUpdate_timestamp
>=
onUpdate_interval
)
{
context
.
_canUpdate
=
false
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
context
.
onUpdate
(
context
.
_API
.
_gameManager
.
_game_duration
);
onUpdate_start
=
Date
.
now
();
context
.
_last_onUpdate_timestamp
=
current_time
;
context
.
onUpdate
(
current_time
);
if
(
onUpdate_interval
>
0
&&
Date
.
now
()
-
onUpdate_start
>
onUpdate_interval
)
{
throw
new
Error
(
'
onUpdate execution took
'
+
(
Date
.
now
()
-
onUpdate_start
)
+
'
milliseconds but loop interval is only
'
+
onUpdate_interval
+
'
milliseconds
'
);
}
})
.
push
(
function
()
{
context
.
_canUpdate
=
true
;
...
...
@@ -175,7 +243,7 @@ var DroneManager = /** @class */ (function () {
context
.
_internal_crash
(
error
);
})
.
push
(
function
()
{
context
.
_API
.
internal_
post
_update
(
context
);
context
.
_API
.
internal_
info
_update
(
context
);
})
.
push
(
undefined
,
function
(
error
)
{
console
.
warn
(
'
Drone crashed on update due to error:
'
,
error
);
...
...
@@ -274,7 +342,7 @@ var DroneManager = /** @class */ (function () {
this
.
_controlMesh
.
position
.
z
,
this
.
_controlMesh
.
position
.
y
);
position
.
timestamp
=
this
.
_API
.
_gameManager
.
_game_duration
;
position
.
timestamp
=
this
.
_API
.
_gameManager
.
getCurrentTime
()
;
return
position
;
}
return
null
;
...
...
@@ -284,13 +352,7 @@ var DroneManager = /** @class */ (function () {
*/
DroneManager
.
prototype
.
loiter
=
function
(
latitude
,
longitude
,
altitude
,
radius
,
speed
)
{
this
.
_internal_setTargetCoordinates
(
latitude
,
longitude
,
altitude
,
speed
,
radius
);
this
.
_callSetTargetCommand
(
latitude
,
longitude
,
altitude
,
speed
,
radius
);
};
DroneManager
.
prototype
.
getFlightParameters
=
function
()
{
if
(
this
.
_API
.
getFlightParameters
)
{
...
...
@@ -298,6 +360,9 @@ var DroneManager = /** @class */ (function () {
}
return
null
;
};
DroneManager
.
prototype
.
getMaxCommandFrequency
=
function
()
{
return
this
.
_API
.
getMaxCommandFrequency
();
};
DroneManager
.
prototype
.
getYaw
=
function
()
{
return
this
.
_API
.
getYaw
(
this
);
};
...
...
@@ -314,7 +379,9 @@ var DroneManager = /** @class */ (function () {
return
this
.
_API
.
takeOff
();
};
DroneManager
.
prototype
.
land
=
function
()
{
if
(
!
this
.
isLanding
())
{
return
this
.
_API
.
land
(
this
);
}
};
DroneManager
.
prototype
.
exit
=
function
()
{
return
this
.
_internal_crash
();
...
...
@@ -659,7 +726,6 @@ var GameManager = /** @class */ (function () {
this
.
_droneList
.
forEach
(
function
(
drone
)
{
queue
.
push
(
function
()
{
drone
.
_tick
+=
1
;
if
(
drone
.
_API
.
isCollidable
&&
drone
.
can_play
)
{
if
(
drone
.
getCurrentPosition
().
altitude
<=
0
)
{
if
(
!
drone
.
isLanding
())
{
...
...
@@ -698,7 +764,8 @@ var GameManager = /** @class */ (function () {
this
.
_game_duration
+=
delta_time
;
var
color
,
drone_position
,
game_manager
=
this
,
geo_coordinates
,
log_count
,
map_info
,
map_manager
,
material
,
position_obj
,
seconds
=
Math
.
floor
(
this
.
_game_duration
/
1000
),
trace_objects
;
current_time
=
this
.
getCurrentTime
(),
seconds
=
Math
.
floor
(
current_time
/
1000
),
trace_objects
;
if
(
GAMEPARAMETERS
.
log_drone_flight
||
GAMEPARAMETERS
.
draw_flight_path
)
{
this
.
_droneList
.
forEach
(
function
(
drone
,
index
)
{
...
...
@@ -717,7 +784,7 @@ var GameManager = /** @class */ (function () {
drone_position
.
z
);
game_manager
.
_flight_log
[
index
].
push
([
game_manager
.
_game_duration
,
geo_coordinates
.
latitude
,
current_time
,
geo_coordinates
.
latitude
,
geo_coordinates
.
longitude
,
map_info
.
start_AMSL
+
drone_position
.
z
,
drone_position
.
z
,
drone
.
getYaw
(),
drone
.
getSpeed
(),
...
...
@@ -763,8 +830,7 @@ var GameManager = /** @class */ (function () {
};
GameManager
.
prototype
.
_timeOut
=
function
()
{
var
seconds
=
Math
.
floor
(
this
.
_game_duration
/
1000
);
return
this
.
_totalTime
-
seconds
<=
0
;
return
this
.
_totalTime
-
this
.
_game_duration
<=
0
;
};
GameManager
.
prototype
.
_allDronesFinished
=
function
()
{
...
...
@@ -903,14 +969,14 @@ var GameManager = /** @class */ (function () {
_this
.
ongoing_update_promise
=
null
;
_this
.
finish_deferred
=
RSVP
.
defer
();
console
.
log
(
"
Simulation started.
"
);
this
.
_game_duration
=
Date
.
now
();
this
.
_totalTime
=
GAMEPARAMETERS
.
gameTime
+
this
.
_game_duration
;
this
.
_start_time
=
Date
.
now
();
this
.
_game_duration
=
0
;
this
.
_totalTime
=
GAMEPARAMETERS
.
gameTime
*
1000
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
promise_list
=
[];
_this
.
_droneList
.
forEach
(
function
(
drone
)
{
drone
.
_tick
=
0
;
promise_list
.
push
(
drone
.
internal_start
(
_this
.
_mapManager
.
getMapInfo
().
initial_position
));
...
...
@@ -980,44 +1046,6 @@ var GameManager = /** @class */ (function () {
}
return
false
;
}
function
spawnDrone
(
x
,
y
,
z
,
index
,
drone_info
,
api
)
{
var
default_drone_AI
=
api
.
getDroneAI
(),
code
,
base
,
code_eval
;
if
(
default_drone_AI
)
{
code
=
default_drone_AI
;
}
else
{
code
=
drone_info
.
script_content
;
}
code_eval
=
"
let drone = new DroneManager(ctx._scene,
"
+
index
+
'
, api);
'
+
"
let droneMe = function(NativeDate, me, Math, window, DroneManager,
"
+
"
GameManager, DroneLogAPI, FixedWingDroneAPI, BABYLON,
"
+
"
GAMEPARAMETERS) {
"
+
"
var start_time = (new Date(2070, 0, 0, 0, 0, 0, 0)).getTime();
"
+
"
Date.now = function () {
"
+
"
return start_time + drone._tick * 1000/60;};
"
+
"
function Date() {if (!(this instanceof Date))
"
+
"
{throw new Error('Missing new operator');}
"
+
"
if (arguments.length === 0) {return new NativeDate(Date.now());}
"
+
"
else {return new NativeDate(...arguments);}}
"
;
// Simple desactivation of direct access of all globals
// It is still accessible in reality, but it will me more visible
// if people really access them
if
(
x
!==
null
&&
y
!==
null
&&
z
!==
null
)
{
code_eval
+=
"
me.setStartingPosition(
"
+
x
+
"
,
"
+
y
+
"
,
"
+
z
+
"
);
"
;
}
base
=
code_eval
;
code_eval
+=
code
+
"
}; droneMe(Date, drone, Math, {});
"
;
base
+=
"
};ctx._droneList.push(drone)
"
;
code_eval
+=
"
ctx._droneList.push(drone)
"
;
/*jslint evil: true*/
try
{
eval
(
code_eval
);
}
catch
(
error
)
{
console
.
error
(
error
);
eval
(
base
);
}
/*jslint evil: false*/
}
function
randomSpherePoint
(
x0
,
y0
,
z0
,
rx0
,
ry0
,
rz0
)
{
var
u
=
Math
.
random
(),
v
=
Math
.
random
(),
rx
=
Math
.
random
()
*
rx0
,
ry
=
Math
.
random
()
*
ry0
,
...
...
@@ -1045,11 +1073,15 @@ var GameManager = /** @class */ (function () {
i
);
spawnDrone
(
position
.
x
,
position
.
y
,
position
.
z
,
i
,
drone_list
[
i
],
api
);
drone_list
[
i
],
api
,
ctx
.
_scene
,
ctx
.
_droneList
);
}
}
};
GameManager
.
prototype
.
getCurrentTime
=
function
()
{
return
this
.
_start_time
+
this
.
_game_duration
;
};
return
GameManager
;
}());
...
...
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_logic_js.xml
View file @
2d2050eb
...
...
@@ -240,7 +240,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
101
4.65027.38618.31573
</string>
</value>
<value>
<string>
101
6.21987.28184.16844
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>
17
09560536.57
</float>
<float>
17
14742619.34
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/ojs_drone_simulator_script_page_js.js
View file @
2d2050eb
...
...
@@ -122,11 +122,13 @@
'
}
\n
'
+
'
return;
\n
'
+
'
}
\n
'
+
'
me.exit(0);
\n
'
+
'
if (!me.isLanding()) { me.land() };
\n
'
+
'
if (me.getCurrentPosition().altitude <= 0) { me.exit(0) };
\n
'
+
'
};
'
,
DRAW
=
true
,
LOG
=
true
,
LOG_TIME
=
1662.7915426540285
,
ONUPDATE_INTERVAL
=
100
,
DRONE_LIST
=
[],
WIDTH
=
680
,
HEIGHT
=
340
,
...
...
@@ -191,6 +193,17 @@
"
hidden
"
:
0
,
"
type
"
:
"
IntegerField
"
},
"
my_onupdate_interval
"
:
{
"
description
"
:
"
Minimum interval (in milliseconds) between 2 executions of onUpdate function as well as periodicity to send telemetry to the swarm
"
,
"
title
"
:
"
OnUpdate interval
"
,
"
default
"
:
ONUPDATE_INTERVAL
,
"
css_class
"
:
""
,
"
required
"
:
1
,
"
editable
"
:
1
,
"
key
"
:
"
onupdate_interval
"
,
"
hidden
"
:
0
,
"
type
"
:
"
IntegerField
"
},
"
my_drone_min_speed
"
:
{
"
description
"
:
""
,
"
title
"
:
"
Drone min speed
"
,
...
...
@@ -444,8 +457,8 @@
form_definition
:
{
group_list
:
[[
"
left
"
,
[[
"
my_simulation_speed
"
],
[
"
my_simulation_time
"
],
[
"
my_
number_of_drones
"
],
[
"
my_minimum_latitud
"
],
[
"
my_maximum_latitud
"
],
[[
"
my_simulation_speed
"
],
[
"
my_simulation_time
"
],
[
"
my_
onupdate_interval
"
],
[
"
my_
number_of_drones
"
],
[
"
my_
minimum_latitud
"
],
[
"
my_maximum_latitud
"
],
[
"
my_minimum_longitud
"
],
[
"
my_maximum_longitud
"
],
[
"
my_init_pos_lat
"
],
[
"
my_init_pos_lon
"
],
[
"
my_init_pos_alt
"
],
[
"
my_map_height
"
]]
...
...
@@ -494,7 +507,8 @@
"
maxPitchAngle
"
:
parseFloat
(
options
.
drone_max_pitch
),
"
maxSinkRate
"
:
parseFloat
(
options
.
drone_max_sink_rate
),
"
maxClimbRate
"
:
parseFloat
(
options
.
drone_max_climb_rate
),
"
maxCommandFrequency
"
:
parseFloat
(
options
.
drone_max_command_frequency
)
"
maxCommandFrequency
"
:
parseFloat
(
options
.
drone_max_command_frequency
),
"
onUpdateInterval
"
:
parseInt
(
options
.
onupdate_interval
,
10
)
},
"
gameTime
"
:
parseInt
(
options
.
simulation_time
,
10
),
"
simulation_speed
"
:
parseInt
(
options
.
simulation_speed
,
10
),
...
...
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/ojs_drone_simulator_script_page_js.xml
View file @
2d2050eb
...
...
@@ -246,7 +246,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
101
4.60725.60577.24917
</string>
</value>
<value>
<string>
101
5.64120.46679.6946
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>
17
09289017.41
</float>
<float>
17
13425712.2
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_simulator_test/PathTemplateItem/web_page_module/test_drone_simulator_flight_js.js
View file @
2d2050eb
...
...
@@ -3,11 +3,10 @@
(
function
(
window
,
rJS
,
domsugar
,
document
,
URLSearchParams
,
Blob
)
{
"
use strict
"
;
var
SIMULATION_SPEED
=
10
,
SIMULATION_TIME
=
270
,
MAP_SIZE
=
600
,
map_height
=
700
,
start_AMSL
=
595
,
var
SIMULATION_SPEED
=
1
,
LOOP_INTERVAL
=
1000
/
60
,
ON_UPDATE_INTERVAL
=
LOOP_INTERVAL
,
SIMULATION_TIME
=
LOOP_INTERVAL
/
1000
,
DEFAULT_SPEED
=
16
,
MAX_ACCELERATION
=
6
,
MAX_DECELERATION
=
1
,
...
...
@@ -19,7 +18,6 @@
MAX_CLIMB_RATE
=
8
,
MAX_SINK_RATE
=
3
,
NUMBER_OF_DRONES
=
1
,
FLAG_WEIGHT
=
5
,
MIN_LAT
=
45.6364
,
MAX_LAT
=
45.65
,
MIN_LON
=
14.2521
,
...
...
@@ -78,9 +76,10 @@
'
me.getCurrentPosition().longitude
\n
'
+
'
).toFixed(8),
\n
'
+
'
time_interval = timestamp - me.start_time,
\n
'
+
'
expected_interval =
1000 / 60
,
\n
'
+
'
expected_interval =
'
+
LOOP_INTERVAL
+
'
,
\n
'
+
'
expectedDistance = (me.getSpeed() * expected_interval / 1000).toFixed(8);
\n
'
+
'
assert(time_interval.toFixed(4), expected_interval.toFixed(4), "Timestamp");
\n
'
+
'
assert(Date.now(), timestamp, "Date");
\n
'
+
'
assert(realDistance, expectedDistance, "Distance");
\n
'
+
'
current_position.latitude = current_position.latitude.toFixed(7);
\n
'
+
'
compare(current_position, {
\n
'
+
...
...
@@ -88,7 +87,6 @@
'
longitude: me.initialPosition.longitude,
\n
'
+
'
altitude: me.initialPosition.altitude
\n
'
+
'
});
\n
'
+
'
me.exit(me.land());
\n
'
+
'
};
'
,
DRAW
=
true
,
LOG
=
true
,
...
...
@@ -175,35 +173,36 @@
game_parameters_json
=
{
"
debug_test_mode
"
:
true
,
"
drone
"
:
{
"
maxAcceleration
"
:
parseInt
(
MAX_ACCELERATION
,
10
),
"
maxDeceleration
"
:
parseInt
(
MAX_DECELERATION
,
10
),
"
minSpeed
"
:
parseInt
(
MIN_SPEED
,
10
),
"
speed
"
:
parseFloat
(
DEFAULT_SPEED
),
"
maxSpeed
"
:
parseInt
(
MAX_SPEED
,
10
),
"
maxRoll
"
:
parseFloat
(
MAX_ROLL
),
"
minPitchAngle
"
:
parseFloat
(
MIN_PITCH
),
"
maxPitchAngle
"
:
parseFloat
(
MAX_PITCH
),
"
maxSinkRate
"
:
parseFloat
(
MAX_SINK_RATE
),
"
maxClimbRate
"
:
parseFloat
(
MAX_CLIMB_RATE
)
"
maxAcceleration
"
:
MAX_ACCELERATION
,
"
maxDeceleration
"
:
MAX_DECELERATION
,
"
minSpeed
"
:
MIN_SPEED
,
"
speed
"
:
DEFAULT_SPEED
,
"
maxSpeed
"
:
MAX_SPEED
,
"
maxRoll
"
:
MAX_ROLL
,
"
minPitchAngle
"
:
MIN_PITCH
,
"
maxPitchAngle
"
:
MAX_PITCH
,
"
maxSinkRate
"
:
MAX_SINK_RATE
,
"
maxClimbRate
"
:
MAX_CLIMB_RATE
,
"
onUpdateInterval
"
:
ON_UPDATE_INTERVAL
},
"
gameTime
"
:
parseInt
(
SIMULATION_TIME
,
10
)
,
"
simulation_speed
"
:
parseInt
(
SIMULATION_SPEED
,
10
)
,
"
gameTime
"
:
SIMULATION_TIME
,
"
simulation_speed
"
:
SIMULATION_SPEED
,
"
latency
"
:
{
"
information
"
:
0
,
"
communication
"
:
0
},
"
map
"
:
{
"
min_lat
"
:
parseFloat
(
MIN_LAT
)
,
"
max_lat
"
:
parseFloat
(
MAX_LAT
)
,
"
min_lon
"
:
parseFloat
(
MIN_LON
)
,
"
max_lon
"
:
parseFloat
(
MAX_LON
)
,
"
height
"
:
parseInt
(
HEIGHT
)
,
"
start_AMSL
"
:
parseFloat
(
start_AMSL
)
"
min_lat
"
:
MIN_LAT
,
"
max_lat
"
:
MAX_LAT
,
"
min_lon
"
:
MIN_LON
,
"
max_lon
"
:
MAX_LON
,
"
height
"
:
HEIGHT
,
"
start_AMSL
"
:
start_AMSL
},
"
initialPosition
"
:
{
"
longitude
"
:
parseFloat
(
INIT_LON
)
,
"
latitude
"
:
parseFloat
(
INIT_LAT
)
,
"
altitude
"
:
parseFloat
(
INIT_ALT
)
"
longitude
"
:
INIT_LON
,
"
latitude
"
:
INIT_LAT
,
"
altitude
"
:
INIT_ALT
},
"
draw_flight_path
"
:
DRAW
,
"
temp_flight_path
"
:
true
,
...
...
@@ -257,19 +256,27 @@
return
form_gadget
.
getContent
();
})
.
push
(
function
(
result
)
{
var
div
=
domsugar
(
'
div
'
,
{
text
:
"
CONSOLE LOG ENTRIES:
"
});
var
div
=
domsugar
(
'
div
'
,
{
text
:
"
CONSOLE LOG ENTRIES:
"
}),
lines
=
result
.
console_log
.
split
(
'
\n
'
),
line_nb
,
node
,
test_log_node
=
document
.
querySelector
(
'
.test_log
'
);;
document
.
querySelector
(
'
.container
'
).
parentNode
.
appendChild
(
div
);
function
createLogNode
(
message
)
{
var
node
=
document
.
createElement
(
"
div
"
);
var
textNode
=
document
.
createTextNode
(
message
);
node
.
appendChild
(
textNode
);
return
node
;
function
appendToTestLog
(
test_log_node
,
message
)
{
var
log_node
=
document
.
createElement
(
"
div
"
),
textNode
=
document
.
createTextNode
(
message
);
log_node
.
appendChild
(
textNode
);
test_log_node
.
appendChild
(
log_node
);
}
for
(
line_nb
=
0
;
line_nb
<
lines
.
length
;
line_nb
+=
1
)
{
if
(
lines
[
line_nb
]
!==
'
TIMEOUT!
'
)
{
appendToTestLog
(
test_log_node
,
lines
[
line_nb
]);
}
else
{
appendToTestLog
(
test_log_node
,
'
Timeout: OK
'
);
return
;
}
var
lines
=
result
.
console_log
.
split
(
'
\n
'
);
for
(
var
i
=
0
;
i
<
lines
.
length
;
i
++
)
{
var
node
=
createLogNode
(
lines
[
i
]);
document
.
querySelector
(
'
.test_log
'
).
appendChild
(
node
);
}
appendToTestLog
(
test_log_node
,
'
Timeout: FAILED
'
);
},
function
(
error
)
{
return
gadget
.
notifySubmitted
({
message
:
"
Error:
"
+
error
.
message
,
status
:
'
error
'
});
...
...
bt5/erp5_officejs_drone_simulator_test/PathTemplateItem/web_page_module/test_drone_simulator_flight_js.xml
View file @
2d2050eb
...
...
@@ -246,7 +246,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
101
4.60681.20667.37171
</string>
</value>
<value>
<string>
101
5.64176.45813.63488
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>
17
0928643
6.53
</float>
<float>
17
1342837
6.53
</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