Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
erp5
Commits
532546ea
Commit
532546ea
authored
Jan 29, 2024
by
Léo-Paul Géneau
👾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_officejs_drone_simulator: use multicopter API
parent
ef735f9b
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
861 additions
and
48 deletions
+861
-48
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_fixedwingdrone_js.js
...Item/web_page_module/drone_simulator_fixedwingdrone_js.js
+7
-4
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
+21
-19
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/drone_simulator_multicopterdrone_js.js
...em/web_page_module/drone_simulator_multicopterdrone_js.js
+465
-0
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_multicopterdrone_js.xml
...m/web_page_module/drone_simulator_multicopterdrone_js.xml
+346
-0
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
+11
-15
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
-2
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_simulator/PathTemplateItem/web_page_module/drone_simulator_fixedwingdrone_js.js
View file @
532546ea
...
...
@@ -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
,
...
...
@@ -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
)
{
...
...
@@ -465,16 +464,20 @@ var FixedWingDroneAPI = /** @class */ (function () {
+
Math
.
pow
(
direction
.
z
*
drone
.
get3DSpeed
(),
2
)
);
};
FixedWingDroneAPI
.
prototype
.
takeOff
=
function
()
{
FixedWingDroneAPI
.
prototype
.
takeOff
=
function
(
drone
)
{
return
console
.
log
(
"
Fixed-wing drones can only be taken off manually.
"
);
};
FixedWingDroneAPI
.
prototype
.
land
=
function
(
drone
)
{
var
drone_pos
=
drone
.
getCurrentPosition
();
drone
.
_speed
=
0
;
drone
.
_acceleration
=
EARTH_GRAVITY
;
this
.
_flight_parameters
.
drone
.
maxSinkRate
=
PARACHUTE_SPEED
;
this
.
_flight_parameters
.
drone
.
minPitchAngle
=
-
90
;
drone
.
setTargetCoordinates
(
drone_pos
.
latitude
,
drone_pos
.
longitude
,
0
,
drone
.
get3DSpeed
()
PARACHUTE_SPEED
);
this
.
_is_ready_to_fly
=
false
;
this
.
_is_landing
=
true
;
...
...
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_fixedwingdrone_js.xml
View file @
532546ea
...
...
@@ -240,7 +240,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
101
4.60733.7318.44953
</string>
</value>
<value>
<string>
101
5.14195.32960.20019
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>
17
09562449.93
</float>
<float>
17
10429600.19
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_logic_js.js
View file @
532546ea
...
...
@@ -130,23 +130,32 @@ var DroneManager = /** @class */ (function () {
this
.
_internal_crash
(
error
);
}
};
DroneManager
.
prototype
.
_callSetTargetCommand
=
function
(
latitude
,
longitude
,
altitude
,
speed
,
radius
)
{
if
(
!
this
.
isReadyToFly
())
{
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
'
));
}
this
.
_internal_setTargetCoordinates
(
latitude
,
longitude
,
altitude
,
speed
,
radius
);
this
.
_last_command_timestamp
=
this
.
_API
.
_gameManager
.
_game_duration
;
};
/**
* 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,7 +165,6 @@ 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
;
...
...
@@ -284,13 +292,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
)
{
...
...
@@ -311,7 +313,7 @@ var DroneManager = /** @class */ (function () {
return
this
.
_API
.
getClimbRate
(
this
);
};
DroneManager
.
prototype
.
takeOff
=
function
()
{
return
this
.
_API
.
takeOff
();
return
this
.
_API
.
takeOff
(
this
);
};
DroneManager
.
prototype
.
land
=
function
()
{
return
this
.
_API
.
land
(
this
);
...
...
@@ -544,6 +546,7 @@ var GameManager = /** @class */ (function () {
}
this
.
APIs_dict
=
{
FixedWingDroneAPI
:
FixedWingDroneAPI
,
MulticopterDroneAPI
:
MulticopterDroneAPI
,
DroneLogAPI
:
DroneLogAPI
};
if
(
this
.
_game_parameters_json
.
debug_test_mode
)
{
...
...
@@ -763,8 +766,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
()
{
...
...
@@ -904,7 +906,7 @@ var GameManager = /** @class */ (function () {
_this
.
finish_deferred
=
RSVP
.
defer
();
console
.
log
(
"
Simulation started.
"
);
this
.
_game_duration
=
Date
.
now
();
this
.
_totalTime
=
GAMEPARAMETERS
.
gameTime
+
this
.
_game_duration
;
this
.
_totalTime
=
GAMEPARAMETERS
.
gameTime
*
1000
+
this
.
_game_duration
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
...
...
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_logic_js.xml
View file @
532546ea
...
...
@@ -240,7 +240,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
101
4.65027.38618.31573
</string>
</value>
<value>
<string>
101
5.15360.8933.15121
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>
17
09560536.57
</float>
<float>
17
10499343.13
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_multicopterdrone_js.js
0 → 100644
View file @
532546ea
This diff is collapsed.
Click to expand it.
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/drone_simulator_multicopterdrone_js.xml
0 → 100644
View file @
532546ea
This diff is collapsed.
Click to expand it.
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/ojs_drone_simulator_script_page_js.js
View file @
532546ea
...
...
@@ -12,11 +12,11 @@
max_lon
=
14.2766
,
map_height
=
100
,
start_AMSL
=
595
,
DEFAULT_SPEED
=
16
,
DEFAULT_SPEED
=
5
,
MAX_ACCELERATION
=
6
,
MAX_DECELERATION
=
1
,
MIN_SPEED
=
12
,
MAX_SPEED
=
2
6
,
MIN_SPEED
=
0
,
MAX_SPEED
=
6
,
MAX_ROLL
=
35
,
MIN_PITCH
=
-
20
,
MAX_PITCH
=
25
,
...
...
@@ -26,7 +26,7 @@
INITIAL_POSITION
=
{
"
latitude
"
:
45.6412
,
"
longitude
"
:
14.2658
,
"
altitude
"
:
15
"
altitude
"
:
0
},
NUMBER_OF_DRONES
=
2
,
// Non-inputs parameters
...
...
@@ -35,42 +35,34 @@
'
EPSILON = 9,
\n
'
+
'
CHECKPOINT_LIST = [
\n
'
+
'
{
\n
'
+
'
altitude: 585.1806861589965,
\n
'
+
'
latitude: 45.64492790560583,
\n
'
+
'
longitude: 14.25334942966329
\n
'
+
'
},
\n
'
+
'
{
\n
'
+
'
altitude: 589.8802607573035,
\n
'
+
'
latitude: 45.64316335436476,
\n
'
+
'
longitude: 14.26332880184475
\n
'
+
'
},
\n
'
+
'
{
\n
'
+
'
altitude: 608.6648153348965,
\n
'
+
'
latitude: 45.64911917196595,
\n
'
+
'
longitude: 14.26214792790128
\n
'
+
'
},
\n
'
+
'
{
\n
'
+
'
altitude: 606.1448368129072,
\n
'
+
'
latitude: 45.64122685351364,
\n
'
+
'
longitude: 14.26590493128597
\n
'
+
'
},
\n
'
+
'
{
\n
'
+
'
altitude: 630.0829598206344,
\n
'
+
'
latitude: 45.64543355564817,
\n
'
+
'
longitude: 14.27242391207985
\n
'
+
'
},
\n
'
+
'
{
\n
'
+
'
altitude: 616.1839898415284,
\n
'
+
'
latitude: 45.6372792927328,
\n
'
+
'
longitude: 14.27533492411138
\n
'
+
'
},
\n
'
+
'
{
\n
'
+
'
altitude: 598.0603137354178,
\n
'
+
'
latitude: 45.64061299543953,
\n
'
+
'
longitude: 14.26161958465814
\n
'
+
'
},
\n
'
+
'
{
\n
'
+
'
altitude: 607.1243119862851,
\n
'
+
'
latitude: 45.64032340702919,
\n
'
+
'
longitude: 14.2682896662383
\n
'
+
'
}
\n
'
+
...
...
@@ -91,15 +83,17 @@
'
me.onStart = function (timestamp) {
\n
'
+
'
me.direction_set = false;
\n
'
+
'
me.next_checkpoint = 0;
\n
'
+
'
me.takeOff();
\n
'
+
'
};
\n
'
+
'
\n
'
+
'
me.onUpdate = function (timestamp) {
\n
'
+
'
if (!me.isReadyToFly()) { return; }
\n
'
+
'
if (!me.direction_set) {
\n
'
+
'
if (me.next_checkpoint < CHECKPOINT_LIST.length) {
\n
'
+
'
me.setTargetCoordinates(
\n
'
+
'
CHECKPOINT_LIST[me.next_checkpoint].latitude,
\n
'
+
'
CHECKPOINT_LIST[me.next_checkpoint].longitude,
\n
'
+
'
CHECKPOINT_LIST[me.next_checkpoint].altitude +
ALTITUDE + ALTITUDE * me.id,
\n
'
+
'
ALTITUDE + ALTITUDE * me.id,
\n
'
+
'
'
+
DEFAULT_SPEED
+
'
\n
'
+
'
);
\n
'
+
'
console.log("[DEMO] Going to Checkpoint %d", me.next_checkpoint);
\n
'
+
...
...
@@ -122,7 +116,8 @@
'
}
\n
'
+
'
return;
\n
'
+
'
}
\n
'
+
'
me.exit(0);
\n
'
+
'
if (!me.isLanding()) { return me.land(); }
\n
'
+
'
if (me.getCurrentPosition().altitude <= 0) { return me.exit(0); }
\n
'
+
'
};
'
,
DRAW
=
true
,
LOG
=
true
,
...
...
@@ -133,6 +128,7 @@
LOGIC_FILE_LIST
=
[
'
gadget_erp5_page_drone_simulator_logic.js
'
,
'
gadget_erp5_page_drone_simulator_fixedwingdrone.js
'
,
'
gadget_erp5_page_drone_simulator_multicopterdrone.js
'
,
'
gadget_erp5_page_drone_simulator_dronelogfollower.js
'
];
...
...
@@ -479,7 +475,7 @@
[
domsugar
(
'
div
'
)]).
firstElementChild
;
DRONE_LIST
=
[];
for
(
i
=
0
;
i
<
options
.
number_of_drones
;
i
+=
1
)
{
DRONE_LIST
[
i
]
=
{
"
id
"
:
i
,
"
type
"
:
"
FixedWing
DroneAPI
"
,
DRONE_LIST
[
i
]
=
{
"
id
"
:
i
,
"
type
"
:
"
Multicopter
DroneAPI
"
,
"
script_content
"
:
options
.
script
};
}
game_parameters_json
=
{
...
...
bt5/erp5_officejs_drone_simulator/PathTemplateItem/web_page_module/ojs_drone_simulator_script_page_js.xml
View file @
532546ea
...
...
@@ -246,7 +246,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
101
4.60725.60577.24917
</string>
</value>
<value>
<string>
101
5.14198.34281.16981
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>
17
09289017.41
</float>
<float>
17
10429546.73
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs_drone_simulator_test/PathTemplateItem/web_page_module/test_drone_simulator_flight_js.js
View file @
532546ea
...
...
@@ -11,7 +11,7 @@
DEFAULT_SPEED
=
16
,
MAX_ACCELERATION
=
6
,
MAX_DECELERATION
=
1
,
MIN_SPEED
=
12
,
MIN_SPEED
=
0
,
MAX_SPEED
=
26
,
MAX_ROLL
=
35
,
MIN_PITCH
=
-
20
,
...
...
@@ -97,6 +97,7 @@
LOGIC_FILE_LIST
=
[
'
gadget_erp5_page_drone_simulator_logic.js
'
,
'
gadget_erp5_page_drone_simulator_fixedwingdrone.js
'
,
'
gadget_erp5_page_drone_simulator_multicopterdrone.js
'
,
'
gadget_erp5_page_drone_simulator_dronelogfollower.js
'
];
...
...
@@ -169,7 +170,7 @@
fragment
=
domsugar
(
gadget
.
element
.
querySelector
(
'
.simulator_div
'
),
[
domsugar
(
'
div
'
)]).
firstElementChild
;
for
(
i
=
0
;
i
<
NUMBER_OF_DRONES
;
i
+=
1
)
{
DRONE_LIST
[
i
]
=
{
"
id
"
:
i
,
"
type
"
:
"
FixedWing
DroneAPI
"
,
DRONE_LIST
[
i
]
=
{
"
id
"
:
i
,
"
type
"
:
"
Multicopter
DroneAPI
"
,
"
script_content
"
:
options
.
script
};
}
game_parameters_json
=
{
...
...
bt5/erp5_officejs_drone_simulator_test/PathTemplateItem/web_page_module/test_drone_simulator_flight_js.xml
View file @
532546ea
...
...
@@ -246,7 +246,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
101
4.60681.20667.37171
</string>
</value>
<value>
<string>
101
2.50927.52040.41233
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>
170
9286436.53
</float>
<float>
170
1096005.31
</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