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
d63ec839
Commit
d63ec839
authored
Mar 01, 2024
by
Léo-Paul Géneau
👾
Browse files
Options
Browse Files
Download
Plain Diff
Rename functions for multicopters
See merge request
nexedi/erp5!1891
parents
760e47a9
d240b5c2
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
272 additions
and
349 deletions
+272
-349
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
+19
-21
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
+30
-70
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
+103
-100
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
+43
-28
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.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
+3
-3
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
+2
-5
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
+25
-65
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
+22
-32
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.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
+3
-3
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 @
d63ec839
...
...
@@ -23,6 +23,8 @@ var EnemyDroneAPI = /** @class */ (function () {
this
.
_drone_dict_list
=
[];
this
.
_acceleration
=
DEFAULT_ACCELERATION
;
this
.
_collision_sector
=
COLLISION_SECTOR
;
this
.
_is_landing
=
false
;
this
.
_is_ready_to_fly
=
true
;
}
/*
** Function called on start phase of the drone, just before onStart AI script
...
...
@@ -49,7 +51,6 @@ var EnemyDroneAPI = /** @class */ (function () {
if
(
drone
.
_maxSinkRate
>
drone
.
_maxSpeed
)
{
throw
new
Error
(
'
max sink rate cannot be superior to max speed
'
);
}
drone
.
_maxOrientation
=
this
.
getMaxOrientation
();
return
;
};
/*
...
...
@@ -57,10 +58,12 @@ var EnemyDroneAPI = /** @class */ (function () {
*/
EnemyDroneAPI
.
prototype
.
internal_update
=
function
(
context
,
delta_time
)
{
context
.
_speed
+=
context
.
_acceleration
*
delta_time
/
1000
;
if
(
context
.
_speed
>
context
.
_maxSpeed
)
if
(
context
.
_speed
>
context
.
_maxSpeed
)
{
context
.
_speed
=
context
.
_maxSpeed
;
if
(
context
.
_speed
<
-
context
.
_maxSpeed
)
}
if
(
context
.
_speed
<
-
context
.
_maxSpeed
)
{
context
.
_speed
=
-
context
.
_maxSpeed
;
}
var
updateSpeed
=
context
.
_speed
*
delta_time
/
1000
;
if
(
context
.
_direction
.
x
!==
0
||
context
.
_direction
.
y
!==
0
||
...
...
@@ -68,13 +71,9 @@ var EnemyDroneAPI = /** @class */ (function () {
context
.
_controlMesh
.
position
.
addInPlace
(
new
BABYLON
.
Vector3
(
context
.
_direction
.
x
*
updateSpeed
,
context
.
_direction
.
y
*
updateSpeed
,
context
.
_direction
.
z
*
updateSpeed
));
context
.
_direction
.
z
*
updateSpeed
)
);
}
var
orientationValue
=
context
.
_maxOrientation
*
(
context
.
_speed
/
context
.
_maxSpeed
);
context
.
_mesh
.
rotation
=
new
BABYLON
.
Vector3
(
orientationValue
*
context
.
_direction
.
z
,
0
,
-
orientationValue
*
context
.
_direction
.
x
);
context
.
_controlMesh
.
computeWorldMatrix
(
true
);
context
.
_mesh
.
computeWorldMatrix
(
true
);
return
;
...
...
@@ -119,7 +118,9 @@ var EnemyDroneAPI = /** @class */ (function () {
EnemyDroneAPI
.
prototype
.
internal_setTargetCoordinates
=
function
(
drone
,
coordinates
)
{
if
(
!
drone
.
_canPlay
)
return
;
if
(
!
drone
.
_canPlay
)
{
return
;
}
var
x
=
coordinates
.
x
,
y
=
coordinates
.
y
,
z
=
coordinates
.
z
;
if
(
isNaN
(
x
)
||
isNaN
(
y
)
||
isNaN
(
z
))
{
throw
new
Error
(
'
Target coordinates must be numbers
'
);
...
...
@@ -279,20 +280,17 @@ var EnemyDroneAPI = /** @class */ (function () {
EnemyDroneAPI
.
prototype
.
getMaxAcceleration
=
function
()
{
return
this
.
_flight_parameters
.
drone
.
maxAcceleration
;
};
EnemyDroneAPI
.
prototype
.
getMaxOrientation
=
function
()
{
//TODO should be a game parameter (but how to force value to PI quarters?)
return
Math
.
PI
/
4
;
};
EnemyDroneAPI
.
prototype
.
triggerParachute
=
function
(
drone
)
{
EnemyDroneAPI
.
prototype
.
land
=
function
(
drone
)
{
var
drone_pos
=
drone
.
getCurrentPosition
();
drone
.
setTargetCoordinates
(
drone_pos
.
latitude
,
drone_pos
.
longitude
,
5
);
drone
.
setTargetCoordinates
(
drone_pos
.
latitude
,
drone_pos
.
longitude
,
0
);
this
.
_is_ready_to_fly
=
false
;
this
.
_is_landing
=
true
;
};
EnemyDroneAPI
.
prototype
.
landed
=
function
(
drone
)
{
var
drone_pos
=
drone
.
getCurrentPosition
();
return
Math
.
floor
(
drone_pos
.
altitude
)
<
10
;
EnemyDroneAPI
.
prototype
.
isReadyToFly
=
function
()
{
return
this
.
_is_ready_to_fly
;
};
EnemyDroneAPI
.
prototype
.
exit
=
function
()
{
return
;
EnemyDroneAPI
.
prototype
.
isLanding
=
function
()
{
return
this
.
_is_landing
;
};
EnemyDroneAPI
.
prototype
.
getInitialAltitude
=
function
()
{
return
0
;
...
...
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/drone_capture_flag_enemydrone_js.xml
View file @
d63ec839
...
...
@@ -246,7 +246,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
101
1.46035.33513.61849
</string>
</value>
<value>
<string>
101
4.56714.1017.16076
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>
1
697031010.9
9
</float>
<float>
1
709221104.1
9
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/drone_capture_flag_fixedwingdrone_js.js
View file @
d63ec839
...
...
@@ -31,6 +31,8 @@ var FixedWingDroneAPI = /** @class */ (function () {
this
.
_loiter_radius
=
100
;
//this._start_altitude = 0;
this
.
_loiter_mode
=
false
;
this
.
_is_landing
=
false
;
this
.
_is_ready_to_fly
=
true
;
this
.
_drone_dict_list
=
[];
}
/*
...
...
@@ -86,45 +88,15 @@ var FixedWingDroneAPI = /** @class */ (function () {
if
(
drone
.
_maxClimbRate
>
drone
.
_maxSpeed
)
{
throw
new
Error
(
'
max climb rate cannot be superior to max speed
'
);
}
drone
.
_maxOrientation
=
this
.
getMaxOrientation
();
return
;
};
/*
** Function called on every drone update, right before onUpdate AI script
*/
FixedWingDroneAPI
.
prototype
.
internal_update
=
function
(
context
,
delta_time
)
{
var
diff
,
newrot
,
orientationValue
,
rotStep
;
//TODO rotation
if
(
context
.
_rotationTarget
)
{
rotStep
=
BABYLON
.
Vector3
.
Zero
();
diff
=
context
.
_rotationTarget
.
subtract
(
context
.
_controlMesh
.
rotation
);
rotStep
.
x
=
(
diff
.
x
>=
1
)
?
1
:
diff
.
x
;
rotStep
.
y
=
(
diff
.
y
>=
1
)
?
1
:
diff
.
y
;
rotStep
.
z
=
(
diff
.
z
>=
1
)
?
1
:
diff
.
z
;
if
(
rotStep
===
BABYLON
.
Vector3
.
Zero
())
{
context
.
_rotationTarget
=
null
;
return
;
}
newrot
=
new
BABYLON
.
Vector3
(
context
.
_controlMesh
.
rotation
.
x
+
(
rotStep
.
x
*
context
.
_rotationSpeed
),
context
.
_controlMesh
.
rotation
.
y
+
(
rotStep
.
y
*
context
.
_rotationSpeed
),
context
.
_controlMesh
.
rotation
.
z
+
(
rotStep
.
z
*
context
.
_rotationSpeed
)
);
context
.
_controlMesh
.
rotation
=
newrot
;
}
this
.
_updateSpeed
(
context
,
delta_time
);
this
.
_updatePosition
(
context
,
delta_time
);
//TODO rotation
orientationValue
=
context
.
_maxOrientation
*
(
context
.
_speed
/
context
.
_maxSpeed
);
context
.
_mesh
.
rotation
=
new
BABYLON
.
Vector3
(
orientationValue
*
context
.
_direction
.
z
,
0
,
-
orientationValue
*
context
.
_direction
.
x
);
context
.
_controlMesh
.
computeWorldMatrix
(
true
);
context
.
_mesh
.
computeWorldMatrix
(
true
);
};
...
...
@@ -144,7 +116,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
'
latitude
'
:
drone_position
.
latitude
,
'
longitude
'
:
drone_position
.
longitude
,
'
yaw
'
:
drone
.
getYaw
(),
'
speed
'
:
drone
.
get
Air
Speed
(),
'
speed
'
:
drone
.
getSpeed
(),
'
climbRate
'
:
drone
.
getClimbRate
()
};
_this
.
_drone_dict_list
[
_this
.
_id
]
=
drone_info
;
...
...
@@ -158,7 +130,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
};
FixedWingDroneAPI
.
prototype
.
_updateSpeed
=
function
(
drone
,
delta_time
)
{
var
speed
=
drone
.
get
Air
Speed
(),
speedDiff
,
speedUpdate
;
var
speed
=
drone
.
get
3D
Speed
(),
speedDiff
,
speedUpdate
;
if
(
speed
!==
this
.
_targetSpeed
)
{
speedDiff
=
this
.
_targetSpeed
-
speed
;
speedUpdate
=
drone
.
_acceleration
*
delta_time
/
1000
;
...
...
@@ -231,7 +203,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
verticalSpeed
=
this
.
_getVerticalSpeed
(
drone
);
groundSpeed
=
Math
.
sqrt
(
Math
.
pow
(
drone
.
get
Air
Speed
(),
2
)
-
Math
.
pow
(
verticalSpeed
,
2
)
Math
.
pow
(
drone
.
get
3D
Speed
(),
2
)
-
Math
.
pow
(
verticalSpeed
,
2
)
);
distance
=
(
groundSpeed
*
delta_time
/
1000
)
/
R
;
...
...
@@ -240,7 +212,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
newLatRad
=
Math
.
asin
(
currentSinLat
*
distanceCos
+
currentCosLat
*
distanceSin
*
Math
.
cos
(
newYawRad
)
currentCosLat
*
distanceSin
*
Math
.
cos
(
newYawRad
)
);
newLonRad
=
currentLonRad
+
Math
.
atan2
(
Math
.
sin
(
newYawRad
)
*
distanceSin
*
currentCosLat
,
...
...
@@ -256,10 +228,10 @@ var FixedWingDroneAPI = /** @class */ (function () {
// swap y and z axis so z axis represents altitude
drone
.
_controlMesh
.
position
.
addInPlace
(
new
BABYLON
.
Vector3
(
Math
.
abs
(
newCoordinates
.
x
-
drone
.
position
.
x
)
*
(
newCoordinates
.
x
<
drone
.
position
.
x
?
-
1
:
1
),
(
newCoordinates
.
x
<
drone
.
position
.
x
?
-
1
:
1
),
verticalSpeed
*
delta_time
/
1000
,
Math
.
abs
(
newCoordinates
.
y
-
drone
.
position
.
y
)
*
(
newCoordinates
.
y
<
drone
.
position
.
y
?
-
1
:
1
)
(
newCoordinates
.
y
<
drone
.
position
.
y
?
-
1
:
1
)
));
yawToDirection
=
this
.
_toRad
(
-
newYaw
+
90
);
drone
.
setDirection
(
...
...
@@ -293,40 +265,28 @@ var FixedWingDroneAPI = /** @class */ (function () {
verticalSpeed
=
this
.
_computeVerticalSpeed
(
altitudeDiff
,
this
.
getMaxClimbRate
(),
drone
.
get
Air
Speed
(),
drone
.
get
3D
Speed
(),
this
.
getMaxPitchAngle
()
);
}
else
{
verticalSpeed
=
-
this
.
_computeVerticalSpeed
(
Math
.
abs
(
altitudeDiff
),
this
.
getMaxSinkRate
(),
drone
.
get
Air
Speed
(),
drone
.
get
3D
Speed
(),
-
this
.
getMinPitchAngle
()
);
}
return
verticalSpeed
;
};
FixedWingDroneAPI
.
prototype
.
setRotation
=
function
(
drone
,
x
,
y
,
z
)
{
//TODO rotation
drone
.
_rotationTarget
=
new
BABYLON
.
Vector3
(
x
,
z
,
y
);
};
FixedWingDroneAPI
.
prototype
.
setRotationBy
=
function
(
drone
,
x
,
y
,
z
)
{
//TODO rotation
drone
.
_rotationTarget
=
new
BABYLON
.
Vector3
(
drone
.
rotation
.
x
+
x
,
drone
.
rotation
.
y
+
z
,
drone
.
rotation
.
z
+
y
);
};
FixedWingDroneAPI
.
prototype
.
setSpeed
=
function
(
drone
,
speed
)
{
this
.
_targetSpeed
=
Math
.
max
(
Math
.
min
(
speed
,
this
.
getMaxSpeed
()),
this
.
getMinSpeed
()
);
drone
.
_acceleration
=
(
this
.
_targetSpeed
>
drone
.
get
Air
Speed
())
?
this
.
getMaxAcceleration
()
:
-
this
.
getMaxDeceleration
();
drone
.
_acceleration
=
(
this
.
_targetSpeed
>
drone
.
get
3D
Speed
())
?
this
.
getMaxAcceleration
()
:
-
this
.
getMaxDeceleration
();
};
FixedWingDroneAPI
.
prototype
.
setStartingPosition
=
function
(
drone
,
x
,
y
,
z
)
{
...
...
@@ -490,14 +450,10 @@ var FixedWingDroneAPI = /** @class */ (function () {
FixedWingDroneAPI
.
prototype
.
getMaxClimbRate
=
function
()
{
return
this
.
_flight_parameters
.
drone
.
maxClimbRate
;
};
FixedWingDroneAPI
.
prototype
.
getMaxOrientation
=
function
()
{
//TODO should be a game parameter (but how to force value to PI quarters?)
return
Math
.
PI
/
4
;
};
FixedWingDroneAPI
.
prototype
.
getYawVelocity
=
function
(
drone
)
{
return
360
*
EARTH_GRAVITY
*
Math
.
tan
(
this
.
_toRad
(
this
.
getMaxRollAngle
()))
/
(
2
*
Math
.
PI
*
drone
.
get
Air
Speed
());
(
2
*
Math
.
PI
*
drone
.
get
3D
Speed
());
};
FixedWingDroneAPI
.
prototype
.
getYaw
=
function
(
drone
)
{
var
direction
=
drone
.
worldDirection
;
...
...
@@ -523,7 +479,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
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
))
speed
*
Math
.
sin
(
this
.
_toRad
(
max_pitch
))
:
maxVerticalSpeed
;
};
FixedWingDroneAPI
.
prototype
.
_toRad
=
function
(
angle
)
{
...
...
@@ -533,30 +489,34 @@ var FixedWingDroneAPI = /** @class */ (function () {
return
angle
*
180
/
Math
.
PI
;
};
FixedWingDroneAPI
.
prototype
.
getClimbRate
=
function
(
drone
)
{
return
drone
.
worldDirection
.
y
*
drone
.
get
Air
Speed
();
return
drone
.
worldDirection
.
y
*
drone
.
get
3D
Speed
();
};
FixedWingDroneAPI
.
prototype
.
get
Ground
Speed
=
function
(
drone
)
{
FixedWingDroneAPI
.
prototype
.
getSpeed
=
function
(
drone
)
{
var
direction
=
drone
.
worldDirection
;
return
Math
.
sqrt
(
Math
.
pow
(
direction
.
x
*
drone
.
get
Air
Speed
(),
2
)
+
Math
.
pow
(
direction
.
z
*
drone
.
getAir
Speed
(),
2
)
Math
.
pow
(
direction
.
x
*
drone
.
get
3D
Speed
(),
2
)
+
Math
.
pow
(
direction
.
z
*
drone
.
get3D
Speed
(),
2
)
);
};
FixedWingDroneAPI
.
prototype
.
triggerParachute
=
function
(
drone
)
{
FixedWingDroneAPI
.
prototype
.
takeOff
=
function
()
{
return
console
.
log
(
"
Fixed-wing drones can only be taken off manually.
"
);
};
FixedWingDroneAPI
.
prototype
.
land
=
function
(
drone
)
{
var
drone_pos
=
drone
.
getCurrentPosition
();
drone
.
setTargetCoordinates
(
drone_pos
.
latitude
,
drone_pos
.
longitude
,
5
,
drone
.
get
Air
Speed
()
0
,
drone
.
get
3D
Speed
()
);
this
.
_is_ready_to_fly
=
false
;
this
.
_is_landing
=
true
;
};
FixedWingDroneAPI
.
prototype
.
landed
=
function
(
drone
)
{
var
drone_pos
=
drone
.
getCurrentPosition
();
return
Math
.
floor
(
drone_pos
.
altitude
)
<
10
;
FixedWingDroneAPI
.
prototype
.
isReadyToFly
=
function
()
{
return
this
.
_is_ready_to_fly
;
};
FixedWingDroneAPI
.
prototype
.
exit
=
function
()
{
return
;
FixedWingDroneAPI
.
prototype
.
isLanding
=
function
()
{
return
this
.
_is_landing
;
};
FixedWingDroneAPI
.
prototype
.
getInitialAltitude
=
function
()
{
return
this
.
_map_dict
.
start_AMSL
;
...
...
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/drone_capture_flag_fixedwingdrone_js.xml
View file @
d63ec839
...
...
@@ -246,7 +246,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1014.
48041.44620.29337
</string>
</value>
<value>
<string>
1014.
56746.48697.2713
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>
1709
113157.81
</float>
<float>
1709
223091.4
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/drone_capture_flag_logic_js.js
View file @
d63ec839
...
...
@@ -25,11 +25,9 @@ var DroneManager = /** @class */ (function () {
this
.
_maxRollAngle
=
0
;
this
.
_maxSinkRate
=
0
;
this
.
_maxClimbRate
=
0
;
this
.
_maxOrientation
=
0
;
this
.
_speed
=
0
;
this
.
_acceleration
=
0
;
this
.
_direction
=
new
BABYLON
.
Vector3
(
0
,
0
,
1
);
// North
this
.
_rotationSpeed
=
0.4
;
this
.
_scene
=
scene
;
this
.
_canUpdate
=
true
;
this
.
_id
=
id
;
...
...
@@ -155,7 +153,7 @@ var DroneManager = /** @class */ (function () {
};
DroneManager
.
prototype
.
_internal_setTargetCoordinates
=
function
(
latitude
,
longitude
,
altitude
,
speed
,
radius
)
{
if
(
!
this
.
_canPlay
)
{
if
(
!
this
.
_canPlay
||
!
this
.
isReadyToFly
()
)
{
return
;
}
//each drone API process coordinates on its needs
...
...
@@ -208,14 +206,15 @@ var DroneManager = /** @class */ (function () {
}
return
;
};
DroneManager
.
prototype
.
_internal_crash
=
function
(
error
)
{
DroneManager
.
prototype
.
_internal_crash
=
function
(
error
,
print_stack
)
{
if
(
print_stack
===
"
undefined
"
)
{
print_stack
=
true
;
}
this
.
last_position
=
this
.
position
;
this
.
_canCommunicate
=
false
;
this
.
_controlMesh
=
null
;
this
.
_mesh
=
null
;
this
.
_canPlay
=
false
;
if
(
error
)
{
this
.
_API
.
_gameManager
.
logError
(
this
,
error
);
this
.
_API
.
_gameManager
.
logError
(
this
,
error
,
print_stack
);
}
this
.
onTouched
();
};
...
...
@@ -236,20 +235,6 @@ var DroneManager = /** @class */ (function () {
this
.
_direction
=
new
BABYLON
.
Vector3
(
x
,
z
,
y
).
normalize
();
};
//TODO rotation
DroneManager
.
prototype
.
setRotation
=
function
(
x
,
y
,
z
)
{
if
(
!
this
.
_canPlay
)
{
return
;
}
return
this
.
_API
.
setRotation
(
this
,
x
,
y
,
z
);
};
DroneManager
.
prototype
.
setRotationBy
=
function
(
x
,
y
,
z
)
{
if
(
!
this
.
_canPlay
)
{
return
;
}
return
this
.
_API
.
setRotation
(
this
,
x
,
y
,
z
);
};
/**
* Send a message to drones
* @param msg The message to send
...
...
@@ -342,41 +327,40 @@ var DroneManager = /** @class */ (function () {
return
null
;
};
DroneManager
.
prototype
.
getYaw
=
function
()
{
if
(
t
ypeof
this
.
_API
.
getYaw
!==
"
undefined
"
)
{
if
(
t
his
.
_API
.
getYaw
!==
undefined
)
{
return
this
.
_API
.
getYaw
(
this
);
}
return
;
};
DroneManager
.
prototype
.
get
Air
Speed
=
function
()
{
DroneManager
.
prototype
.
get
3D
Speed
=
function
()
{
return
this
.
_speed
;
};
DroneManager
.
prototype
.
get
Ground
Speed
=
function
()
{
if
(
t
ypeof
this
.
_API
.
getGround
Speed
!==
"
undefined
"
)
{
return
this
.
_API
.
get
Ground
Speed
(
this
);
DroneManager
.
prototype
.
getSpeed
=
function
()
{
if
(
t
his
.
_API
.
get
Speed
!==
"
undefined
"
)
{
return
this
.
_API
.
getSpeed
(
this
);
}
return
;
};
DroneManager
.
prototype
.
getClimbRate
=
function
()
{
if
(
t
ypeof
t
his
.
_API
.
getClimbRate
!==
"
undefined
"
)
{
if
(
this
.
_API
.
getClimbRate
!==
"
undefined
"
)
{
return
this
.
_API
.
getClimbRate
(
this
);
}
return
;
};
DroneManager
.
prototype
.
getSinkRate
=
function
()
{
if
(
typeof
this
.
_API
.
getSinkRate
!==
"
undefined
"
)
{
return
this
.
_API
.
getSinkRate
(
this
);
}
return
;
DroneManager
.
prototype
.
takeOff
=
function
()
{
return
this
.
_API
.
takeOff
();
};
DroneManager
.
prototype
.
triggerParachute
=
function
()
{
return
this
.
_API
.
triggerParachute
(
this
);
DroneManager
.
prototype
.
land
=
function
()
{
return
this
.
_API
.
land
(
this
);
};
DroneManager
.
prototype
.
exit
=
function
()
{
this
.
_internal_crash
();
return
this
.
_API
.
exit
();
return
this
.
_internal_crash
();
};
DroneManager
.
prototype
.
landed
=
function
()
{
return
this
.
_API
.
landed
(
this
);
DroneManager
.
prototype
.
isReadyToFly
=
function
()
{
return
this
.
_API
.
isReadyToFly
();
};
DroneManager
.
prototype
.
isLanding
=
function
()
{
return
this
.
_API
.
isLanding
();
};
/**
* Set the drone last checkpoint reached
...
...
@@ -394,7 +378,7 @@ var DroneManager = /** @class */ (function () {
* Function called on game update
* @param timestamp The tic value
*/
DroneManager
.
prototype
.
onUpdate
=
function
()
{
return
;
};
DroneManager
.
prototype
.
onUpdate
=
function
(
timestamp
)
{
return
;
};
/**
* Function called when drone crashes
*/
...
...
@@ -442,7 +426,12 @@ var MapManager = /** @class */ (function () {
function
MapManager
(
scene
,
map_param
)
{
var
_this
=
this
,
max_sky
,
skybox
,
skyboxMat
,
largeGroundMat
,
flag_material
,
largeGroundBottom
,
width
,
depth
,
terrain
,
max
,
flag_a
,
flag_b
,
mast
,
flag
,
count
=
0
,
new_obstacle
,
obstacle
,
flag_info
,
enemy
;
count
=
0
,
new_obstacle
,
obstacle
,
flag_info
,
enemy
,
FLAG_SIZE
=
{
'
x
'
:
1
,
'
y
'
:
1
,
'
z
'
:
6
};
if
(
!
map_param
)
{
// Use default map base parameters
map_param
=
MAP
;
...
...
@@ -453,7 +442,8 @@ var MapManager = /** @class */ (function () {
_this
.
map_info
.
initial_position
=
_this
.
mapUtils
.
convertToLocalCoordinates
(
_this
.
map_info
.
initial_position
.
latitude
,
_this
.
map_info
.
initial_position
.
longitude
,
_this
.
map_info
.
initial_position
.
altitude
);
_this
.
map_info
.
initial_position
.
altitude
);
max
=
_this
.
map_info
.
width
;
if
(
_this
.
map_info
.
depth
>
max
)
{
max
=
_this
.
map_info
.
depth
;
...
...
@@ -504,7 +494,8 @@ var MapManager = /** @class */ (function () {
enemy
.
position
=
_this
.
mapUtils
.
convertToLocalCoordinates
(
geo_enemy
.
position
.
latitude
,
geo_enemy
.
position
.
longitude
,
geo_enemy
.
position
.
altitude
);
geo_enemy
.
position
.
altitude
);
_this
.
_enemy_list
.
push
(
enemy
);
});
// Obstacles
...
...
@@ -515,7 +506,8 @@ var MapManager = /** @class */ (function () {
obstacle
.
position
=
_this
.
mapUtils
.
convertToLocalCoordinates
(
geo_obstacle
.
position
.
latitude
,
geo_obstacle
.
position
.
longitude
,
geo_obstacle
.
position
.
altitude
);
geo_obstacle
.
position
.
altitude
);
switch
(
obstacle
.
type
)
{
case
"
box
"
:
new_obstacle
=
BABYLON
.
MeshBuilder
.
CreateBox
(
"
obs_
"
+
count
,
...
...
@@ -539,41 +531,41 @@ var MapManager = /** @class */ (function () {
return
;
}
new_obstacle
.
type
=
obstacle
.
type
;
var
convertion
=
Math
.
PI
/
180
;
if
(
"
position
"
in
obstacle
)
var
convertion
=
Math
.
PI
/
180
,
obs_material
=
new
BABYLON
.
StandardMaterial
(
"
obsmat_
"
+
count
,
scene
);
if
(
obstacle
.
hasOwnProperty
(
"
position
"
))
{
new_obstacle
.
position
=
new
BABYLON
.
Vector3
(
obstacle
.
position
.
x
,
obstacle
.
position
.
z
,
obstacle
.
position
.
y
);
if
(
"
rotation
"
in
obstacle
)
}
if
(
obstacle
.
hasOwnProperty
(
"
rotation
"
))
{
new_obstacle
.
rotation
=
new
BABYLON
.
Vector3
(
obstacle
.
rotation
.
x
*
convertion
,
obstacle
.
rotation
.
z
*
convertion
,
obstacle
.
rotation
.
y
*
convertion
);
if
(
"
scale
"
in
obstacle
)
}
if
(
obstacle
.
hasOwnProperty
(
"
scale
"
))
{
new_obstacle
.
scaling
=
new
BABYLON
.
Vector3
(
obstacle
.
scale
.
x
,
obstacle
.
scale
.
z
,
obstacle
.
scale
.
y
);
var
obs_material
=
new
BABYLON
.
StandardMaterial
(
"
obsmat_
"
+
count
,
scene
);
}
obs_material
.
alpha
=
1
;
obs_material
.
diffuseColor
=
new
BABYLON
.
Color3
(
255
,
153
,
0
);
new_obstacle
.
material
=
obs_material
;
_this
.
_obstacle_list
.
push
(
new_obstacle
);
count
++
;
count
+=
1
;
});
// Flags
_this
.
_flag_list
=
[];
var
FLAG_SIZE
=
{
'
x
'
:
1
,
'
y
'
:
1
,
'
z
'
:
6
};
_this
.
map_info
.
flag_list
.
forEach
(
function
(
geo_flag
,
index
)
{
flag_info
=
{};
Object
.
assign
(
flag_info
,
geo_flag
);
flag_info
.
position
=
_this
.
mapUtils
.
convertToLocalCoordinates
(
geo_flag
.
position
.
latitude
,
geo_flag
.
position
.
longitude
,
geo_flag
.
position
.
altitude
);
geo_flag
.
position
.
altitude
);
flag_material
=
new
BABYLON
.
StandardMaterial
(
"
flag_mat_
"
+
index
,
scene
);
flag_material
.
alpha
=
1
;
flag_material
.
diffuseColor
=
BABYLON
.
Color3
.
Green
();
...
...
@@ -607,7 +599,8 @@ var MapManager = /** @class */ (function () {
mast
.
scaling
=
new
BABYLON
.
Vector3
(
FLAG_SIZE
.
x
,
FLAG_SIZE
.
z
,
//swap
FLAG_SIZE
.
y
);
FLAG_SIZE
.
y
);
mast
.
material
=
flag_material
;
flag
=
BABYLON
.
Mesh
.
MergeMeshes
([
flag_a
,
flag_b
,
mast
]);
flag
.
id
=
index
;
...
...
@@ -633,7 +626,10 @@ var MapManager = /** @class */ (function () {
MapManager
.
prototype
.
convertToLocalCoordinates
=
function
(
latitude
,
longitude
,
altitude
)
{
return
this
.
mapUtils
.
convertToLocalCoordinates
(
latitude
,
longitude
,
altitude
);
latitude
,
longitude
,
altitude
);
};
MapManager
.
prototype
.
convertToGeoCoordinates
=
function
(
x
,
y
,
z
)
{
return
this
.
mapUtils
.
convertToGeoCoordinates
(
x
,
y
,
z
);
...
...
@@ -712,7 +708,7 @@ var GameManager = /** @class */ (function () {
console
.
log
=
function
()
{
baseLogFunction
.
apply
(
console
,
arguments
);
var
args
=
Array
.
prototype
.
slice
.
call
(
arguments
);
for
(
i
=
0
;
i
<
args
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
args
.
length
;
i
+=
1
)
{
console_log
+=
args
[
i
]
+
"
\n
"
;
}
};
...
...
@@ -753,13 +749,13 @@ var GameManager = /** @class */ (function () {
(
0
<
_this
.
waiting_update_count
))
{
_this
.
ongoing_update_promise
=
_this
.
_update
(
TIME_DELTA
,
fullscreen
)
.
push
(
function
()
{
_this
.
waiting_update_count
-=
1
;
_this
.
ongoing_update_promise
=
null
;
triggerUpdateIfPossible
();
}).
push
(
undefined
,
function
(
error
)
{
console
.
log
(
"
ERROR on Game Manager update:
"
,
error
);
_this
.
finish_deferred
.
reject
.
bind
(
_this
.
finish_deferred
);
});
_this
.
waiting_update_count
-=
1
;
_this
.
ongoing_update_promise
=
null
;
triggerUpdateIfPossible
();
}).
push
(
undefined
,
function
(
error
)
{
console
.
log
(
"
ERROR on Game Manager update:
"
,
error
);
_this
.
finish_deferred
.
reject
.
bind
(
_this
.
finish_deferred
);
});
}
}
try
{
...
...
@@ -775,9 +771,12 @@ var GameManager = /** @class */ (function () {
this
.
_delayed_defer_list
.
push
([
callback
,
millisecond
]);
};
GameManager
.
prototype
.
logError
=
function
(
drone
,
error
)
{
GameManager
.
prototype
.
logError
=
function
(
drone
,
error
,
print_stack
)
{
if
(
drone
.
_id
<
this
.
_flight_log
.
length
)
{
// don't log enemies
this
.
_flight_log
[
drone
.
_id
].
push
(
error
.
stack
);
this
.
_flight_log
[
drone
.
_id
].
push
(
error
.
message
);
if
(
print_stack
)
{
this
.
_flight_log
[
drone
.
_id
].
push
(
error
.
stack
);
}
}
};
...
...
@@ -793,11 +792,10 @@ var GameManager = /** @class */ (function () {
};
GameManager
.
prototype
.
_checkObstacleCollision
=
function
(
drone
,
obstacle
)
{
var
closest
=
void
0
,
projected
=
BABYLON
.
Vector3
.
Zero
();
if
(
drone
.
colliderMesh
&&
drone
.
colliderMesh
.
intersectsMesh
(
obstacle
,
true
))
{
drone
.
colliderMesh
.
intersectsMesh
(
obstacle
,
true
))
{
drone
.
_internal_crash
(
new
Error
(
'
Drone
'
+
drone
.
id
+
'
touched an obstacle.
'
));
'
touched an obstacle.
'
)
,
false
);
//Following workaround seems not needed with new babylonjs versions
/**
* Closest facet check is needed for sphere and cylinder,
...
...
@@ -821,7 +819,9 @@ var GameManager = /** @class */ (function () {
};
GameManager
.
prototype
.
_checkFlagCollision
=
function
(
drone
,
flag
)
{
if
(
drone
.
team
==
TEAM_ENEMY
)
return
;
if
(
drone
.
team
===
TEAM_ENEMY
)
{
return
;
}
function
distance
(
a
,
b
)
{
return
Math
.
sqrt
(
Math
.
pow
((
a
.
x
-
b
.
x
),
2
)
+
Math
.
pow
((
a
.
y
-
b
.
y
),
2
)
+
Math
.
pow
((
a
.
z
-
b
.
z
),
2
));
...
...
@@ -830,9 +830,9 @@ var GameManager = /** @class */ (function () {
//TODO epsilon distance is 15 because of fixed wing loiter flights
//there is not a proper collision
if
(
distance
(
drone
.
position
,
flag
.
location
)
<=
this
.
_mapManager
.
getMapInfo
().
flag_distance_epsilon
)
{
this
.
_mapManager
.
getMapInfo
().
flag_distance_epsilon
)
{
drone
.
_internal_crash
(
new
Error
(
'
Drone
'
+
drone
.
id
+
'
touched flag
'
+
flag
.
id
));
'
touched flag
'
+
flag
.
id
)
,
false
);
if
(
flag
.
weight
>
0
)
{
flag
.
weight
-=
1
;
drone
.
score
+=
flag
.
score
;
// move score to a global place? GM, MM?
...
...
@@ -842,17 +842,19 @@ var GameManager = /** @class */ (function () {
};
GameManager
.
prototype
.
_checkCollision
=
function
(
drone
,
other
)
{
if
(
drone
.
team
==
TEAM_ENEMY
&&
other
.
team
==
TEAM_ENEMY
)
return
;
if
(
drone
.
team
===
TEAM_ENEMY
&&
other
.
team
===
TEAM_ENEMY
)
{
return
;
}
function
distance
(
a
,
b
)
{
return
Math
.
sqrt
(
Math
.
pow
((
a
.
x
-
b
.
x
),
2
)
+
Math
.
pow
((
a
.
y
-
b
.
y
),
2
)
+
Math
.
pow
((
a
.
z
-
b
.
z
),
2
));
}
if
(
drone
.
team
!=
other
.
team
)
{
if
(
drone
.
team
!=
=
other
.
team
)
{
var
enemy
,
prey
;
if
(
drone
.
team
==
TEAM_ENEMY
)
{
if
(
drone
.
team
==
=
TEAM_ENEMY
)
{
enemy
=
drone
;
prey
=
other
;
}
else
if
(
other
.
team
==
TEAM_ENEMY
)
{
}
else
if
(
other
.
team
==
=
TEAM_ENEMY
)
{
enemy
=
other
;
prey
=
drone
;
}
...
...
@@ -860,18 +862,18 @@ var GameManager = /** @class */ (function () {
if
(
distance
(
drone
.
position
,
other
.
position
)
<
enemy
.
getCollisionSector
())
{
drone
.
_internal_crash
(
new
Error
(
'
enemy drone
'
+
enemy
.
id
+
'
bumped drone
'
+
prey
.
id
+
'
.
'
));
'
bumped drone
'
+
prey
.
id
+
'
.
'
)
,
false
);
other
.
_internal_crash
(
new
Error
(
'
enemy drone
'
+
enemy
.
id
+
'
bumped drone
'
+
prey
.
id
+
'
.
'
));
'
bumped drone
'
+
prey
.
id
+
'
.
'
)
,
false
);
}
}
}
if
(
drone
.
colliderMesh
&&
other
.
colliderMesh
&&
drone
.
colliderMesh
.
intersectsMesh
(
other
.
colliderMesh
,
false
))
{
drone
.
_internal_crash
(
new
Error
(
'
drone
'
+
drone
.
id
+
'
touched drone
'
+
other
.
id
+
'
.
'
));
'
touched drone
'
+
other
.
id
+
'
.
'
)
,
false
);
other
.
_internal_crash
(
new
Error
(
'
drone
'
+
drone
.
id
+
'
touched drone
'
+
other
.
id
+
'
.
'
));
'
touched drone
'
+
other
.
id
+
'
.
'
)
,
false
);
}
};
...
...
@@ -907,20 +909,21 @@ var GameManager = /** @class */ (function () {
this
.
_droneList
.
forEach
(
function
(
drone
)
{
queue
.
push
(
function
()
{
var
msg
=
''
;
drone
.
_tick
+=
1
;
if
(
drone
.
can_play
)
{
if
(
drone
.
getCurrentPosition
().
altitude
<=
0
)
{
if
(
!
drone
.
isLanding
())
{
drone
.
_internal_crash
(
new
Error
(
'
Drone
'
+
drone
.
id
+
'
touched the floor.
'
),
false
);
}
else
{
drone
.
_internal_crash
();
}
}
else
if
(
_this
.
_checkDroneOut
(
drone
))
{
drone
.
_internal_crash
(
new
Error
(
'
Drone
'
+
drone
.
id
+
'
touched the floor.
'
));
}
else
if
(
_this
.
_checkDroneOut
(
drone
))
{
drone
.
_internal_crash
(
new
Error
(
'
Drone
'
+
drone
.
id
+
'
out of limits.
'
));
}
else
{
'
out of limits.
'
),
false
);
}
else
{
_this
.
_droneList
.
forEach
(
function
(
other
)
{
if
(
other
.
can_play
&&
drone
.
id
!=
other
.
id
)
{
if
(
other
.
can_play
&&
drone
.
id
!=
=
other
.
id
)
{
_this
.
_checkCollision
(
drone
,
other
);
}
});
...
...
@@ -941,7 +944,9 @@ var GameManager = /** @class */ (function () {
if
(
_this
.
_timeOut
())
{
console
.
log
(
"
TIMEOUT!
"
);
_this
.
_droneList
.
forEach
(
function
(
drone
)
{
if
(
drone
.
can_play
)
drone
.
_internal_crash
(
new
Error
(
'
Timeout.
'
));
if
(
drone
.
can_play
)
{
drone
.
_internal_crash
(
new
Error
(
'
Timeout.
'
),
false
);
}
});
_this
.
_result_message
+=
"
TIMEOUT!
"
;
return
_this
.
_finish
();
...
...
@@ -986,7 +991,7 @@ var GameManager = /** @class */ (function () {
game_manager
.
_game_duration
,
geo_coordinates
.
latitude
,
geo_coordinates
.
longitude
,
map_info
.
start_AMSL
+
drone_position
.
z
,
drone_position
.
z
,
drone
.
getYaw
(),
drone
.
get
Ground
Speed
(),
drone_position
.
z
,
drone
.
getYaw
(),
drone
.
getSpeed
(),
drone
.
getClimbRate
()
]);
}
...
...
@@ -1052,7 +1057,9 @@ var GameManager = /** @class */ (function () {
if
(
drone
.
last_position
)
{
dist
=
Math
.
sqrt
(
Math
.
pow
((
drone
.
last_position
.
x
-
base
.
x
),
2
)
+
Math
.
pow
((
drone
.
last_position
.
y
-
base
.
y
),
2
));
if
(
dist
<
BASE_DISTANCE
)
score
+=
1
;
if
(
dist
<
BASE_DISTANCE
)
{
score
+=
1
;
}
}
});
return
score
;
...
...
@@ -1072,8 +1079,8 @@ var GameManager = /** @class */ (function () {
};
GameManager
.
prototype
.
_init
=
function
()
{
var
_this
=
this
,
canvas
,
hemi_north
,
hemi_south
,
camera
,
cam_radius
,
on3DmodelsReady
;
var
_this
=
this
,
canvas
,
hemi_north
,
hemi_south
,
camera
,
cam_radius
,
on3DmodelsReady
,
map_size
=
900
;
//GAMEPARAMETERS.map.map_size
canvas
=
this
.
_canvas
;
this
.
_delayed_defer_list
=
[];
this
.
_dispose
();
...
...
@@ -1111,7 +1118,6 @@ var GameManager = /** @class */ (function () {
);
hemi_south
.
intensity
=
0.75
;
//HARDCODE camera to a hardcoded map_size
var
map_size
=
900
;
//GAMEPARAMETERS.map.map_size
//skybox scene limit
cam_radius
=
(
map_size
*
1.10
<
6000
)
?
map_size
*
1.10
:
6000
;
camera
=
new
BABYLON
.
ArcRotateCamera
(
"
camera
"
,
0
,
1.25
,
cam_radius
,
...
...
@@ -1146,7 +1152,7 @@ var GameManager = /** @class */ (function () {
DroneManager
.
Prefab
.
isVisible
=
false
;
//Hack to make advanced texture work
var
documentTmp
=
document
,
advancedTexture
,
count
,
controlMesh
,
rect
,
label
;
controlMesh
,
rect
;
document
=
undefined
;
advancedTexture
=
BABYLON
.
GUI
.
AdvancedDynamicTexture
.
CreateFullscreenUI
(
"
UI
"
,
...
...
@@ -1287,7 +1293,7 @@ var GameManager = /** @class */ (function () {
GameManager
.
prototype
.
_spawnDrones
=
function
(
init_position
,
drone_list
,
team
,
ctx
,
drone_location
)
{
var
position
,
i
,
position_list
=
[],
max_collision
=
10
*
drone_list
.
length
,
collision_nb
=
0
,
api
,
center
;
collision_nb
=
0
,
api
,
center
,
id_offset
;
function
checkCollision
(
position
,
list
)
{
var
el
;
for
(
el
=
0
;
el
<
list
.
length
;
el
+=
1
)
{
...
...
@@ -1363,10 +1369,7 @@ var GameManager = /** @class */ (function () {
}
}
else
{
position_list
.
push
(
position
);
var
id_offset
=
0
;
if
(
team
==
TEAM_ENEMY
)
{
id_offset
=
GAMEPARAMETERS
.
drone
.
list
.
length
;
}
id_offset
=
team
===
TEAM_ENEMY
?
GAMEPARAMETERS
.
drone
.
list
.
length
:
0
;
api
=
new
this
.
APIs_dict
[
drone_list
[
i
].
type
](
this
,
drone_list
[
i
],
...
...
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/drone_capture_flag_logic_js.xml
View file @
d63ec839
...
...
@@ -246,7 +246,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1014.
48183.45277.76
97
</string>
</value>
<value>
<string>
1014.
56745.33504.261
97
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>
1709
113192.28
</float>
<float>
1709
223446.72
</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 @
d63ec839
...
...
@@ -340,6 +340,24 @@
<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>
<div>
<h5
class=
"item-param-1"
>
Param
</h5>
<h5
class=
"item-param-2"
>
Description
</h5>
</div>
<div>
<h5
class=
"item-param-1"
>
Example
</h5>
</div>
<p
class=
"item-param-1"
>
me.takeOff();
<br>
</p>
<div
class=
"line"
></div>
<!-- setTargetCoordinates -->
<h4
class=
"item-name"
id=
"setTargetCoordinates"
><span>
setTargetCoordinates
</span><span>
: void
</span></h4>
<p
class=
"item-descr"
>
...
...
@@ -439,9 +457,9 @@
<div
class=
"line"
></div>
<!--
triggerParachute
-->
<h4
class=
"item-name"
id=
"
triggerParachute"
><span>
triggerParachute
</span><span>
: void
</span></h4>
<p
class=
"item-descr"
>
Indicates the drone to
deploy the parachute to finish the
landing.
</p>
<!--
land
-->
<h4
class=
"item-name"
id=
"
land"
><span>
land
</span><span>
: void
</span></h4>
<p
class=
"item-descr"
>
Indicates the drone to
trigger
landing.
</p>
<div>
<h5
class=
"item-param-1"
>
Param
</h5>
...
...
@@ -452,23 +470,33 @@
<h5
class=
"item-param-1"
>
Example
</h5>
</div>
<p
class=
"item-param-1"
>
me.
triggerParachute
();
<br>
<p
class=
"item-param-1"
>
me.
land
();
<br>
</p>
<div
class=
"line"
></div>
<!--
landed
-->
<h4
class=
"item-name"
id=
"
landed"
><span>
landed
</span><span>
: boolean
</span></h4>
<p
class=
"item-descr"
>
Indicates if the drone has landed (reached the floor altitude)
.
</p>
<!--
isReadyToFly
-->
<h4
class=
"item-name"
id=
"
isReadyToFly"
><span>
isReadyToFly
</span><span>
: void
</span></h4>
<p
class=
"item-descr"
>
Check if drone takeoff is finished
.
</p>
<div>
<h5
class=
"item-param-1"
>
Example
</h5>
</div>
<p
class=
"item-example"
>
if (me.landed()) {
<br>
//do something
<br>
}
<br>
<p
class=
"item-param-1"
>
me.isReadyToFly();
<br>
</p>
<div
class=
"line"
></div>
<!-- isLanding -->
<h4
class=
"item-name"
id=
"isLanding"
><span>
isLanding
</span><span>
: void
</span></h4>
<p
class=
"item-descr"
>
Check if drone landing has been triggered.
</p>
<div>
<h5
class=
"item-param-1"
>
Example
</h5>
</div>
<p
class=
"item-param-1"
>
me.isLanding();
<br>
</p>
<div
class=
"line"
></div>
...
...
@@ -501,15 +529,15 @@
<div
class=
"line"
></div>
<!-- get
Air
Speed -->
<h4
class=
"item-name"
id=
"get
AirSpeed"
><span>
getAir
Speed
</span><span>
: Float
</span></h4>
<p
class=
"item-descr"
>
Get drone
air speed in meters/secon
d.
</p>
<!-- getSpeed -->
<h4
class=
"item-name"
id=
"get
Speed"
><span>
get
Speed
</span><span>
: Float
</span></h4>
<p
class=
"item-descr"
>
Get drone
ground speed in meters/second as wind is neglected in simulation. In real flights with fixed wings drones the returned value is the airspee
d.
</p>
<div>
<h5
class=
"item-param-1"
>
Example
</h5>
</div>
<p
class=
"item-param-1"
>
me.get
Air
Speed();
<br>
<p
class=
"item-param-1"
>
me.getSpeed();
<br>
</p>
<div
class=
"line"
></div>
...
...
@@ -553,19 +581,6 @@
<div
class=
"line"
></div>
<!-- getSinkRate -->
<h4
class=
"item-name"
id=
"getSinkRate"
><span>
getSinkRate
</span><span>
: Float
</span></h4>
<p
class=
"item-descr"
>
Get drone sink rate in meters/second.
</p>
<div>
<h5
class=
"item-param-1"
>
Example
</h5>
</div>
<p
class=
"item-param-1"
>
me.getSinkRate();
<br>
</p>
<div
class=
"line"
></div>
<h3>
Drone properties
</h3>
<div
class=
"line"
></div>
...
...
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/ojs_drone_capture_flag_API_page_html.xml
View file @
d63ec839
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1014.4
5296.39536.30276
</string>
</value>
<value>
<string>
1014.4
6767.47211.3123
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -264,7 +264,7 @@
</tuple>
<state>
<tuple>
<float>
1708
536065.15
</float>
<float>
1708
688564.0
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_capture_flag/PathTemplateItem/web_page_module/ojs_drone_capture_flag_script_page_js.xml
View file @
d63ec839
...
...
@@ -246,7 +246,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1014.
55204.2137.9676
</string>
</value>
<value>
<string>
1014.
46368.9372.48435
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>
170
9130500.2
</float>
<float>
170
8616910.25
</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 @
d63ec839
...
...
@@ -53,7 +53,7 @@
'
}
\n
'
+
'
\n
'
+
'
me.onStart = function () {
\n
'
+
'
assert(me.get
Air
Speed(),
'
+
DEFAULT_SPEED
+
'
, "Initial speed");
\n
'
+
'
assert(me.getSpeed(),
'
+
DEFAULT_SPEED
+
'
, "Initial speed");
\n
'
+
'
assert(me.getYaw(), 0, "Yaw angle")
\n
'
+
'
me.initialPosition = me.getCurrentPosition();
\n
'
+
'
me.setTargetCoordinates(
\n
'
+
...
...
@@ -73,7 +73,7 @@
'
me.getCurrentPosition().longitude
\n
'
+
'
).toFixed(8),
\n
'
+
'
time_interval = 1000 / 60,
\n
'
+
'
expectedDistance = (me.get
Air
Speed() * time_interval / 1000).toFixed(8);
\n
'
+
'
expectedDistance = (me.getSpeed() * time_interval / 1000).toFixed(8);
\n
'
+
'
assert(timestamp, Math.floor(time_interval), "Timestamp");
\n
'
+
'
assert(realDistance, expectedDistance, "Distance");
\n
'
+
'
current_position.latitude = current_position.latitude.toFixed(7);
\n
'
+
...
...
@@ -82,7 +82,7 @@
'
longitude: me.initialPosition.longitude,
\n
'
+
'
altitude: me.initialPosition.altitude
\n
'
+
'
});
\n
'
+
'
me.exit(me.
triggerParachute
());
\n
'
+
'
me.exit(me.
land
());
\n
'
+
'
};
'
,
DRAW
=
true
,
LOG
=
true
,
...
...
bt5/erp5_officejs_drone_capture_flag_test/PathTemplateItem/web_page_module/test_capture_drone_flight_js.xml
View file @
d63ec839
...
...
@@ -246,7 +246,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1014.552
02.48917.18107
</string>
</value>
<value>
<string>
1014.552
87.25371.8430
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>
170913
0419.
7
</float>
<float>
170913
6147.5
7
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_dronelogfollower_js.js
View file @
d63ec839
...
...
@@ -207,11 +207,8 @@ var DroneLogAPI = /** @class */ (function () {
DroneLogAPI
.
prototype
.
getFlightParameters
=
function
()
{
return
this
.
_flight_parameters
;
};
DroneLogAPI
.
prototype
.
exit
=
function
(
drone
)
{
return
;
};
DroneLogAPI
.
prototype
.
set_loiter_mode
=
function
(
loiter
)
{
return
;
DroneLogAPI
.
prototype
.
isReadyToFly
=
function
()
{
return
true
;
};
return
DroneLogAPI
;
...
...
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_dronelogfollower_js.xml
View file @
d63ec839
...
...
@@ -246,7 +246,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
101
1.48679.53693.47701
</string>
</value>
<value>
<string>
101
4.12050.13065.34372
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>
1
697030760.4
8
</float>
<float>
1
706542267.2
8
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_fixedwingdrone_js.js
View file @
d63ec839
...
...
@@ -30,6 +30,8 @@ var FixedWingDroneAPI = /** @class */ (function () {
this
.
_loiter_radius
=
100
;
//this._start_altitude = 0;
this
.
_loiter_mode
=
false
;
this
.
_is_landing
=
false
;
this
.
_is_ready_to_fly
=
true
;
this
.
_drone_dict_list
=
[];
}
Object
.
defineProperty
(
FixedWingDroneAPI
.
prototype
,
"
isCollidable
"
,
{
...
...
@@ -90,45 +92,15 @@ var FixedWingDroneAPI = /** @class */ (function () {
if
(
drone
.
_maxClimbRate
>
drone
.
_maxSpeed
)
{
throw
new
Error
(
'
max climb rate cannot be superior to max speed
'
);
}
drone
.
_maxOrientation
=
this
.
getMaxOrientation
();
return
;
};
/*
** Function called on every drone update, right before onUpdate AI script
*/
FixedWingDroneAPI
.
prototype
.
internal_update
=
function
(
context
,
delta_time
)
{
var
diff
,
newrot
,
orientationValue
,
rotStep
;
//TODO rotation
if
(
context
.
_rotationTarget
)
{
rotStep
=
BABYLON
.
Vector3
.
Zero
();
diff
=
context
.
_rotationTarget
.
subtract
(
context
.
_controlMesh
.
rotation
);
rotStep
.
x
=
(
diff
.
x
>=
1
)
?
1
:
diff
.
x
;
rotStep
.
y
=
(
diff
.
y
>=
1
)
?
1
:
diff
.
y
;
rotStep
.
z
=
(
diff
.
z
>=
1
)
?
1
:
diff
.
z
;
if
(
rotStep
===
BABYLON
.
Vector3
.
Zero
())
{
context
.
_rotationTarget
=
null
;
return
;
}
newrot
=
new
BABYLON
.
Vector3
(
context
.
_controlMesh
.
rotation
.
x
+
(
rotStep
.
x
*
context
.
_rotationSpeed
),
context
.
_controlMesh
.
rotation
.
y
+
(
rotStep
.
y
*
context
.
_rotationSpeed
),
context
.
_controlMesh
.
rotation
.
z
+
(
rotStep
.
z
*
context
.
_rotationSpeed
)
);
context
.
_controlMesh
.
rotation
=
newrot
;
}
this
.
_updateSpeed
(
context
,
delta_time
);
this
.
_updatePosition
(
context
,
delta_time
);
//TODO rotation
orientationValue
=
context
.
_maxOrientation
*
(
context
.
_speed
/
context
.
_maxSpeed
);
context
.
_mesh
.
rotation
=
new
BABYLON
.
Vector3
(
orientationValue
*
context
.
_direction
.
z
,
0
,
-
orientationValue
*
context
.
_direction
.
x
);
context
.
_controlMesh
.
computeWorldMatrix
(
true
);
context
.
_mesh
.
computeWorldMatrix
(
true
);
};
...
...
@@ -148,7 +120,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
'
latitude
'
:
drone_position
.
latitude
,
'
longitude
'
:
drone_position
.
longitude
,
'
yaw
'
:
drone
.
getYaw
(),
'
speed
'
:
drone
.
get
Air
Speed
(),
'
speed
'
:
drone
.
getSpeed
(),
'
climbRate
'
:
drone
.
getClimbRate
()
};
_this
.
_drone_dict_list
[
_this
.
_id
]
=
drone_info
;
...
...
@@ -162,7 +134,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
};
FixedWingDroneAPI
.
prototype
.
_updateSpeed
=
function
(
drone
,
delta_time
)
{
var
speed
=
drone
.
get
Air
Speed
(),
speedDiff
,
speedUpdate
;
var
speed
=
drone
.
get
3D
Speed
(),
speedDiff
,
speedUpdate
;
if
(
speed
!==
this
.
_targetSpeed
)
{
speedDiff
=
this
.
_targetSpeed
-
speed
;
speedUpdate
=
drone
.
_acceleration
*
delta_time
/
1000
;
...
...
@@ -235,7 +207,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
verticalSpeed
=
this
.
_getVerticalSpeed
(
drone
);
groundSpeed
=
Math
.
sqrt
(
Math
.
pow
(
drone
.
get
Air
Speed
(),
2
)
-
Math
.
pow
(
verticalSpeed
,
2
)
Math
.
pow
(
drone
.
get
3D
Speed
(),
2
)
-
Math
.
pow
(
verticalSpeed
,
2
)
);
distance
=
(
groundSpeed
*
delta_time
/
1000
)
/
R
;
...
...
@@ -297,39 +269,27 @@ var FixedWingDroneAPI = /** @class */ (function () {
verticalSpeed
=
this
.
_computeVerticalSpeed
(
altitudeDiff
,
this
.
getMaxClimbRate
(),
drone
.
get
Air
Speed
(),
drone
.
get
3D
Speed
(),
this
.
getMaxPitchAngle
()
);
}
else
{
verticalSpeed
=
-
this
.
_computeVerticalSpeed
(
Math
.
abs
(
altitudeDiff
),
this
.
getMaxSinkRate
(),
drone
.
get
Air
Speed
(),
drone
.
get
3D
Speed
(),
-
this
.
getMinPitchAngle
()
);
}
return
verticalSpeed
;
};
FixedWingDroneAPI
.
prototype
.
setRotation
=
function
(
drone
,
x
,
y
,
z
)
{
//TODO rotation
drone
.
_rotationTarget
=
new
BABYLON
.
Vector3
(
x
,
z
,
y
);
};
FixedWingDroneAPI
.
prototype
.
setRotationBy
=
function
(
drone
,
x
,
y
,
z
)
{
//TODO rotation
drone
.
_rotationTarget
=
new
BABYLON
.
Vector3
(
drone
.
rotation
.
x
+
x
,
drone
.
rotation
.
y
+
z
,
drone
.
rotation
.
z
+
y
);
};
FixedWingDroneAPI
.
prototype
.
setSpeed
=
function
(
drone
,
speed
)
{
this
.
_targetSpeed
=
Math
.
max
(
Math
.
min
(
speed
,
this
.
getMaxSpeed
()),
this
.
getMinSpeed
()
);
drone
.
_acceleration
=
(
this
.
_targetSpeed
>
drone
.
get
Air
Speed
())
drone
.
_acceleration
=
(
this
.
_targetSpeed
>
drone
.
get
3D
Speed
())
?
this
.
getMaxAcceleration
()
:
-
this
.
getMaxDeceleration
();
};
...
...
@@ -448,14 +408,10 @@ var FixedWingDroneAPI = /** @class */ (function () {
FixedWingDroneAPI
.
prototype
.
getMaxClimbRate
=
function
()
{
return
this
.
_flight_parameters
.
drone
.
maxClimbRate
;
};
FixedWingDroneAPI
.
prototype
.
getMaxOrientation
=
function
()
{
//TODO should be a game parameter (but how to force value to PI quarters?)
return
Math
.
PI
/
4
;
};
FixedWingDroneAPI
.
prototype
.
getYawVelocity
=
function
(
drone
)
{
return
360
*
EARTH_GRAVITY
*
Math
.
tan
(
this
.
_toRad
(
this
.
getMaxRollAngle
()))
/
(
2
*
Math
.
PI
*
drone
.
get
Air
Speed
());
/
(
2
*
Math
.
PI
*
drone
.
get
3D
Speed
());
};
FixedWingDroneAPI
.
prototype
.
getYaw
=
function
(
drone
)
{
var
direction
=
drone
.
worldDirection
;
...
...
@@ -492,30 +448,34 @@ var FixedWingDroneAPI = /** @class */ (function () {
return
angle
*
180
/
Math
.
PI
;
};
FixedWingDroneAPI
.
prototype
.
getClimbRate
=
function
(
drone
)
{
return
drone
.
worldDirection
.
y
*
drone
.
get
Air
Speed
();
return
drone
.
worldDirection
.
y
*
drone
.
get
3D
Speed
();
};
FixedWingDroneAPI
.
prototype
.
get
Ground
Speed
=
function
(
drone
)
{
FixedWingDroneAPI
.
prototype
.
getSpeed
=
function
(
drone
)
{
var
direction
=
drone
.
worldDirection
;
return
Math
.
sqrt
(
Math
.
pow
(
direction
.
x
*
drone
.
get
Air
Speed
(),
2
)
+
Math
.
pow
(
direction
.
z
*
drone
.
get
Air
Speed
(),
2
)
Math
.
pow
(
direction
.
x
*
drone
.
get
3D
Speed
(),
2
)
+
Math
.
pow
(
direction
.
z
*
drone
.
get
3D
Speed
(),
2
)
);
};
FixedWingDroneAPI
.
prototype
.
triggerParachute
=
function
(
drone
)
{
FixedWingDroneAPI
.
prototype
.
takeOff
=
function
()
{
return
console
.
log
(
"
Fixed-wing drones can only be taken off manually.
"
);
};
FixedWingDroneAPI
.
prototype
.
land
=
function
(
drone
)
{
var
drone_pos
=
drone
.
getCurrentPosition
();
drone
.
setTargetCoordinates
(
drone_pos
.
latitude
,
drone_pos
.
longitude
,
5
,
drone
.
get
Air
Speed
()
0
,
drone
.
get
3D
Speed
()
);
this
.
_is_ready_to_fly
=
false
;
this
.
_is_landing
=
true
;
};
FixedWingDroneAPI
.
prototype
.
landed
=
function
(
drone
)
{
var
drone_pos
=
drone
.
getCurrentPosition
();
return
Math
.
floor
(
drone_pos
.
altitude
)
<
10
;
FixedWingDroneAPI
.
prototype
.
isReadyToFly
=
function
()
{
return
this
.
_is_ready_to_fly
;
};
FixedWingDroneAPI
.
prototype
.
exit
=
function
()
{
return
;
FixedWingDroneAPI
.
prototype
.
isLanding
=
function
()
{
return
this
.
_is_landing
;
};
FixedWingDroneAPI
.
prototype
.
getInitialAltitude
=
function
()
{
return
this
.
_map_dict
.
start_AMSL
;
...
...
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_fixedwingdrone_js.xml
View file @
d63ec839
...
...
@@ -240,7 +240,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1014.1
1751.44914.51968
</string>
</value>
<value>
<string>
1014.1
2067.27492.45397
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>
17065
23358.41
</float>
<float>
17065
42739.07
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_logic_js.js
View file @
d63ec839
...
...
@@ -25,11 +25,9 @@ var DroneManager = /** @class */ (function () {
this
.
_maxRollAngle
=
0
;
this
.
_maxSinkRate
=
0
;
this
.
_maxClimbRate
=
0
;
this
.
_maxOrientation
=
0
;
this
.
_speed
=
0
;
this
.
_acceleration
=
0
;
this
.
_direction
=
new
BABYLON
.
Vector3
(
0
,
0
,
1
);
// North
this
.
_rotationSpeed
=
0.4
;
this
.
_scene
=
scene
;
this
.
_canUpdate
=
true
;
this
.
_id
=
id
;
...
...
@@ -141,7 +139,7 @@ var DroneManager = /** @class */ (function () {
};
DroneManager
.
prototype
.
_internal_setTargetCoordinates
=
function
(
latitude
,
longitude
,
altitude
,
speed
,
radius
)
{
if
(
!
this
.
_canPlay
)
{
if
(
!
this
.
_canPlay
||
!
this
.
isReadyToFly
()
)
{
return
;
}
//convert real geo-coordinates to virtual x-y coordinates
...
...
@@ -209,20 +207,6 @@ var DroneManager = /** @class */ (function () {
this
.
_direction
=
new
BABYLON
.
Vector3
(
x
,
z
,
y
).
normalize
();
};
//TODO rotation
DroneManager
.
prototype
.
setRotation
=
function
(
x
,
y
,
z
)
{
if
(
!
this
.
_canPlay
)
{
return
;
}
return
this
.
_API
.
setRotation
(
this
,
x
,
y
,
z
);
};
DroneManager
.
prototype
.
setRotationBy
=
function
(
x
,
y
,
z
)
{
if
(
!
this
.
_canPlay
)
{
return
;
}
return
this
.
_API
.
setRotation
(
this
,
x
,
y
,
z
);
};
/**
* Send a message to drones
* @param msg The message to send
...
...
@@ -309,27 +293,29 @@ var DroneManager = /** @class */ (function () {
DroneManager
.
prototype
.
getYaw
=
function
()
{
return
this
.
_API
.
getYaw
(
this
);
};
DroneManager
.
prototype
.
get
Air
Speed
=
function
()
{
DroneManager
.
prototype
.
get
3D
Speed
=
function
()
{
return
this
.
_speed
;
};
DroneManager
.
prototype
.
get
Ground
Speed
=
function
()
{
return
this
.
_API
.
get
Ground
Speed
(
this
);
DroneManager
.
prototype
.
getSpeed
=
function
()
{
return
this
.
_API
.
getSpeed
(
this
);
};
DroneManager
.
prototype
.
getClimbRate
=
function
()
{
return
this
.
_API
.
getClimbRate
(
this
);
};
DroneManager
.
prototype
.
getSinkRate
=
function
()
{
return
this
.
_API
.
getSinkRate
();
DroneManager
.
prototype
.
takeOff
=
function
()
{
return
this
.
_API
.
takeOff
();
};
DroneManager
.
prototype
.
triggerParachute
=
function
()
{
return
this
.
_API
.
triggerParachute
(
this
);
DroneManager
.
prototype
.
land
=
function
()
{
return
this
.
_API
.
land
(
this
);
};
DroneManager
.
prototype
.
exit
=
function
()
{
this
.
_internal_crash
();
return
this
.
_API
.
exit
();
return
this
.
_internal_crash
();
};
DroneManager
.
prototype
.
landed
=
function
()
{
return
this
.
_API
.
landed
(
this
);
DroneManager
.
prototype
.
isReadyToFly
=
function
()
{
return
this
.
_API
.
isReadyToFly
();
};
DroneManager
.
prototype
.
isLanding
=
function
()
{
return
this
.
_API
.
isLanding
();
};
/**
* Set the drone last checkpoint reached
...
...
@@ -347,7 +333,7 @@ var DroneManager = /** @class */ (function () {
* Function called on game update
* @param timestamp The tic value
*/
DroneManager
.
prototype
.
onUpdate
=
function
()
{
return
;
};
DroneManager
.
prototype
.
onUpdate
=
function
(
timestamp
)
{
return
;
};
/**
* Function called when drone crashes
*/
...
...
@@ -668,8 +654,12 @@ var GameManager = /** @class */ (function () {
drone
.
_tick
+=
1
;
if
(
drone
.
_API
.
isCollidable
&&
drone
.
can_play
)
{
if
(
drone
.
getCurrentPosition
().
altitude
<=
0
)
{
drone
.
_internal_crash
(
new
Error
(
'
Drone
'
+
drone
.
id
+
'
touched the floor.
'
));
if
(
!
drone
.
isLanding
())
{
drone
.
_internal_crash
(
new
Error
(
'
Drone
'
+
drone
.
id
+
'
touched the floor.
'
));
}
else
{
drone
.
_internal_crash
();
}
}
else
{
_this
.
_droneList
.
forEach
(
function
(
other
)
{
if
(
other
.
can_play
&&
drone
.
id
!==
other
.
id
)
{
...
...
@@ -722,7 +712,7 @@ var GameManager = /** @class */ (function () {
game_manager
.
_game_duration
,
geo_coordinates
.
latitude
,
geo_coordinates
.
longitude
,
map_info
.
start_AMSL
+
drone_position
.
z
,
drone_position
.
z
,
drone
.
getYaw
(),
drone
.
get
Ground
Speed
(),
drone_position
.
z
,
drone
.
getYaw
(),
drone
.
getSpeed
(),
drone
.
getClimbRate
()
]);
}
...
...
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_logic_js.xml
View file @
d63ec839
...
...
@@ -240,7 +240,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1014.1
1746.34243.61149
</string>
</value>
<value>
<string>
1014.1
2072.47950.5358
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>
17065
23386.8
</float>
<float>
17065
42965.82
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/ojs_drone_simulator_script_page_js.xml
View file @
d63ec839
...
...
@@ -246,7 +246,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1014.
54902.15254.29337
</string>
</value>
<value>
<string>
1014.
11755.64575.41864
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>
170
9130323.68
</float>
<float>
170
6525997.75
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_simulator_test/PathTemplateItem/web_page_module/test_drone_simulator_flight_js.js
View file @
d63ec839
...
...
@@ -57,7 +57,7 @@
'
}
\n
'
+
'
\n
'
+
'
me.onStart = function () {
\n
'
+
'
assert(me.get
Air
Speed(),
'
+
DEFAULT_SPEED
+
'
, "Initial speed");
\n
'
+
'
assert(me.getSpeed(),
'
+
DEFAULT_SPEED
+
'
, "Initial speed");
\n
'
+
'
assert(me.getYaw(), 0, "Yaw angle")
\n
'
+
'
me.initialPosition = me.getCurrentPosition();
\n
'
+
'
me.setTargetCoordinates(
\n
'
+
...
...
@@ -76,7 +76,7 @@
'
me.getCurrentPosition().latitude,
\n
'
+
'
me.getCurrentPosition().longitude
\n
'
+
'
).toFixed(8),
\n
'
+
'
expectedDistance = (me.get
Air
Speed() * timestamp / 1000).toFixed(8);
\n
'
+
'
expectedDistance = (me.getSpeed() * timestamp / 1000).toFixed(8);
\n
'
+
'
assert(timestamp, 1000 / 60, "Timestamp");
\n
'
+
'
assert(realDistance, expectedDistance, "Distance");
\n
'
+
'
current_position.latitude = current_position.latitude.toFixed(7);
\n
'
+
...
...
@@ -85,7 +85,7 @@
'
longitude: me.initialPosition.longitude,
\n
'
+
'
altitude: me.initialPosition.altitude
\n
'
+
'
});
\n
'
+
'
me.exit(me.
triggerParachute
());
\n
'
+
'
me.exit(me.
land
());
\n
'
+
'
};
'
,
DRAW
=
true
,
LOG
=
true
,
...
...
bt5/erp5_officejs_drone_simulator_test/PathTemplateItem/web_page_module/test_drone_simulator_flight_js.xml
View file @
d63ec839
...
...
@@ -246,7 +246,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1014.552
02.15664.53026
</string>
</value>
<value>
<string>
1014.552
87.25371.8430
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>
170913
0383.65
</float>
<float>
170913
6309.62
</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