Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
144
Merge Requests
144
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
fa3f86a7
Commit
fa3f86a7
authored
Nov 17, 2022
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_drone_simulator: refactor drone_dict
parent
f0d304c9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
32 deletions
+47
-32
bt5/erp5_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_droneaaailefixe_js.js
...tem/web_page_module/drone_simulator_droneaaailefixe_js.js
+26
-3
bt5/erp5_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_droneaaailefixe_js.xml
...em/web_page_module/drone_simulator_droneaaailefixe_js.xml
+2
-2
bt5/erp5_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_dronelogfollower_js.js
...em/web_page_module/drone_simulator_dronelogfollower_js.js
+2
-2
bt5/erp5_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_dronelogfollower_js.xml
...m/web_page_module/drone_simulator_dronelogfollower_js.xml
+2
-2
bt5/erp5_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_logic_js.js
...hTemplateItem/web_page_module/drone_simulator_logic_js.js
+13
-21
bt5/erp5_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_logic_js.xml
...TemplateItem/web_page_module/drone_simulator_logic_js.xml
+2
-2
No files found.
bt5/erp5_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_droneaaailefixe_js.js
View file @
fa3f86a7
...
...
@@ -11,17 +11,19 @@ var TAKEOFF_RADIUS = 60,
var
DroneAaileFixeAPI
=
/** @class */
(
function
()
{
"
use strict
"
;
//** CONSTRUCTOR
function
DroneAaileFixeAPI
(
gameManager
,
drone_info
,
flight_parameters
)
{
function
DroneAaileFixeAPI
(
gameManager
,
drone_info
,
flight_parameters
,
id
)
{
this
.
_gameManager
=
gameManager
;
this
.
_mapManager
=
this
.
_gameManager
.
_mapManager
;
this
.
_map_dict
=
this
.
_mapManager
.
getMapInfo
();
this
.
_flight_parameters
=
flight_parameters
;
this
.
_id
=
id
;
this
.
_drone_info
=
drone_info
;
this
.
_loiter_radius
=
0
;
this
.
_last_loiter_point_reached
=
-
1
;
//this._start_altitude = 0;
//this._last_altitude_point_reached = -1;
this
.
_loiter_mode
=
false
;
//this._start_altitude = 0
;
this
.
_drone_dict_list
=
[]
;
}
/*
** Function called on start phase of the drone, just before onStart AI script
...
...
@@ -38,6 +40,27 @@ var DroneAaileFixeAPI = /** @class */ (function () {
/*if (this._start_altitude > 0) { //TODO move start_altitude here
this.reachAltitude(drone);
}*/
var
_this
=
this
,
drone_position
=
drone
.
getCurrentPosition
(),
drone_info
;
if
(
drone_position
)
{
drone_info
=
{
'
altitudeRel
'
:
drone_position
.
z
,
'
altitudeAbs
'
:
this
.
_mapManager
.
getMapInfo
().
start_AMSL
+
drone_position
.
z
,
'
latitude
'
:
drone_position
.
x
,
'
longitude
'
:
drone_position
.
y
};
this
.
_drone_dict_list
[
this
.
_id
]
=
drone_info
;
//broadcast drone info using internal msg
this
.
_gameManager
.
_droneList
.
forEach
(
function
(
drone
)
{
if
(
drone
.
id
!==
_this
.
_id
)
{
drone
.
internal_getMsg
(
drone_info
,
_this
.
_id
);
}
});
}
};
DroneAaileFixeAPI
.
prototype
.
internal_getMsg
=
function
(
msg
,
id
)
{
this
.
_drone_dict_list
[
id
]
=
msg
;
};
DroneAaileFixeAPI
.
prototype
.
set_loiter_mode
=
function
(
radius
)
{
...
...
@@ -88,7 +111,7 @@ var DroneAaileFixeAPI = /** @class */ (function () {
return
;
};
DroneAaileFixeAPI
.
prototype
.
internal_
sendMsg
=
function
(
msg
,
to
)
{
DroneAaileFixeAPI
.
prototype
.
sendMsg
=
function
(
msg
,
to
)
{
var
_this
=
this
,
droneList
=
_this
.
_gameManager
.
_droneList
;
_this
.
_gameManager
.
delay
(
function
()
{
...
...
bt5/erp5_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_droneaaailefixe_js.xml
View file @
fa3f86a7
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1004.
13828.40056.62976
</string>
</value>
<value>
<string>
1004.
25224.30173.1314
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
1668
017844.98
</float>
<float>
1668
701317.95
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_dronelogfollower_js.js
View file @
fa3f86a7
...
...
@@ -6,7 +6,7 @@
var
DroneLogAPI
=
/** @class */
(
function
()
{
"
use strict
"
;
//** CONSTRUCTOR
function
DroneLogAPI
(
gameManager
,
drone_info
,
flight_parameters
)
{
function
DroneLogAPI
(
gameManager
,
drone_info
,
flight_parameters
,
id
)
{
this
.
_gameManager
=
gameManager
;
this
.
_mapManager
=
this
.
_gameManager
.
_mapManager
;
this
.
_drone_info
=
drone_info
;
...
...
@@ -85,7 +85,7 @@ var DroneLogAPI = /** @class */ (function () {
return
;
};
DroneLogAPI
.
prototype
.
internal_
sendMsg
=
function
(
msg
,
to
)
{
DroneLogAPI
.
prototype
.
sendMsg
=
function
(
msg
,
to
)
{
return
;
};
DroneLogAPI
.
prototype
.
log
=
function
(
msg
)
{
...
...
bt5/erp5_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_dronelogfollower_js.xml
View file @
fa3f86a7
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1004.
13789.44664.33126
</string>
</value>
<value>
<string>
1004.
25197.65379.45943
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
1668
015277.76
</float>
<float>
1668
699757.5
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_logic_js.js
View file @
fa3f86a7
...
...
@@ -24,7 +24,6 @@ var DroneManager = /** @class */ (function () {
this
.
_canUpdate
=
true
;
this
.
_id
=
id
;
this
.
_leader_id
=
0
;
this
.
_drone_dict
=
{};
this
.
_API
=
API
;
// var API created on AI evel
// Create the control mesh
this
.
_controlMesh
=
BABYLON
.
Mesh
.
CreateBox
(
...
...
@@ -56,8 +55,7 @@ var DroneManager = /** @class */ (function () {
configurable
:
true
});
Object
.
defineProperty
(
DroneManager
.
prototype
,
"
drone_dict
"
,
{
get
:
function
()
{
return
this
.
_drone_dict
;
},
set
:
function
(
value
)
{
this
.
_drone_dict
=
value
;
},
get
:
function
()
{
return
this
.
_API
.
_drone_dict_list
;
},
enumerable
:
true
,
configurable
:
true
});
...
...
@@ -217,7 +215,7 @@ var DroneManager = /** @class */ (function () {
this
.
_direction
=
new
BABYLON
.
Vector3
(
x
,
z
,
y
).
normalize
();
};
/**
* Send a message to
team
drones
* Send a message to drones
* @param msg The message to send
* @param id The targeted drone. -1 or nothing to broadcast
*/
...
...
@@ -231,9 +229,17 @@ var DroneManager = /** @class */ (function () {
id
=
-
1
;
}
if
(
_this
.
infosMesh
)
{
return
_this
.
_API
.
internal_
sendMsg
(
JSON
.
parse
(
JSON
.
stringify
(
msg
)),
id
);
return
_this
.
_API
.
sendMsg
(
JSON
.
parse
(
JSON
.
stringify
(
msg
)),
id
);
}
};
/**
* Handle internal get msg
* @param msg The message to send
* @param id of the sender
*/
DroneManager
.
prototype
.
internal_getMsg
=
function
(
msg
,
id
)
{
return
this
.
_API
.
internal_getMsg
(
msg
,
id
);
};
/** Perform a console.log with drone id + the message */
DroneManager
.
prototype
.
log
=
function
(
msg
)
{
return
msg
;
};
DroneManager
.
prototype
.
getMaxHeight
=
function
()
{
...
...
@@ -578,7 +584,7 @@ var GameManager = /** @class */ (function () {
GameManager
.
prototype
.
_update
=
function
(
delta_time
)
{
var
_this
=
this
,
queue
=
new
RSVP
.
Queue
(),
i
,
drone_
dict
=
[],
drone_
position
;
i
,
drone_position
;
this
.
_updateTimeAndLog
(
delta_time
);
// trigger all deferred calls if it is time
...
...
@@ -591,23 +597,9 @@ var GameManager = /** @class */ (function () {
}
}
this
.
_droneList
.
forEach
(
function
(
drone
)
{
drone_position
=
drone
.
getCurrentPosition
();
if
(
drone_position
)
{
drone_dict
.
push
({
'
altitudeRel
'
:
drone_position
.
z
,
'
altitudeAbs
'
:
_this
.
_mapManager
.
getMapInfo
().
start_AMSL
+
drone_position
.
z
,
'
latitude
'
:
drone_position
.
x
,
'
longitude
'
:
drone_position
.
y
});
}
});
this
.
_droneList
.
forEach
(
function
(
drone
)
{
queue
.
push
(
function
()
{
drone
.
_tick
+=
1
;
drone
.
drone_dict
=
drone_dict
;
return
drone
.
internal_update
(
delta_time
);
});
});
...
...
@@ -939,7 +931,7 @@ var GameManager = /** @class */ (function () {
else
{
position_list
.
push
(
position
);
api
=
new
this
.
APIs_dict
[
drone_list
[
i
].
type
](
this
,
drone_list
[
i
],
GAMEPARAMETERS
);
this
,
drone_list
[
i
],
GAMEPARAMETERS
,
i
);
spawnDrone
(
position
.
x
,
position
.
y
,
position
.
z
,
i
,
drone_list
[
i
],
api
);
}
...
...
bt5/erp5_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_logic_js.xml
View file @
fa3f86a7
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1004.25
069.55215.4428
8
</string>
</value>
<value>
<string>
1004.25
222.46703.1885
8
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
1668
692274.42
</float>
<float>
1668
701293.79
</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