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
dfdc82bc
Commit
dfdc82bc
authored
Sep 29, 2022
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_drone_simulator: get rid of rescue swarm dependency
- move script to web page module
parent
32942581
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
605 additions
and
5 deletions
+605
-5
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_page_js.js
...hTemplateItem/web_page_module/drone_web_worker_page_js.js
+5
-3
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_page_js.xml
...TemplateItem/web_page_module/drone_web_worker_page_js.xml
+2
-2
erp5_drone_simulator/PathTemplateItem/web_page_module/loiter_flight_script.txt
...PathTemplateItem/web_page_module/loiter_flight_script.txt
+256
-0
erp5_drone_simulator/PathTemplateItem/web_page_module/loiter_flight_script.xml
...PathTemplateItem/web_page_module/loiter_flight_script.xml
+342
-0
No files found.
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_page_js.js
View file @
dfdc82bc
...
@@ -273,6 +273,7 @@
...
@@ -273,6 +273,7 @@
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
.
declareAcquiredMethod
(
"
updateHeader
"
,
"
updateHeader
"
)
.
declareAcquiredMethod
(
"
updateHeader
"
,
"
updateHeader
"
)
.
declareAcquiredMethod
(
"
jio_get
"
,
"
jio_get
"
)
.
declareAcquiredMethod
(
"
jio_get
"
,
"
jio_get
"
)
.
declareAcquiredMethod
(
"
jio_allDocs
"
,
"
jio_allDocs
"
)
.
declareMethod
(
'
render
'
,
function
renderHeader
()
{
.
declareMethod
(
'
render
'
,
function
renderHeader
()
{
var
gadget
=
this
,
var
gadget
=
this
,
...
@@ -293,10 +294,11 @@
...
@@ -293,10 +294,11 @@
var
script_content
,
game_parameters_json
,
log_content
;
var
script_content
,
game_parameters_json
,
log_content
;
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
gadget
.
jio_get
(
"
rescue_swarm_script_module/
"
+
"
web_worker
"
);
var
query
=
'
(portal_type:"Web Script") AND (reference:"loiter_flight_script")
'
;
return
gadget
.
jio_allDocs
({
query
:
query
,
select_list
:
[
"
text_content
"
]});
})
})
.
push
(
function
(
scrip
t
)
{
.
push
(
function
(
resul
t
)
{
script_content
=
script
.
text_content
;
script_content
=
result
.
data
.
rows
[
0
].
value
.
text_content
;
return
gadget
.
jio_get
(
"
rescue_swarm_map_module/
"
+
"
compare_map
"
);
return
gadget
.
jio_get
(
"
rescue_swarm_map_module/
"
+
"
compare_map
"
);
})
})
.
push
(
function
(
parameters_doc
)
{
.
push
(
function
(
parameters_doc
)
{
...
...
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_page_js.xml
View file @
dfdc82bc
...
@@ -244,7 +244,7 @@
...
@@ -244,7 +244,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1003.1
5820.63775.27392
</string>
</value>
<value>
<string>
1003.1
8656.63783.5546
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -262,7 +262,7 @@
...
@@ -262,7 +262,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1664
374475.4
</float>
<float>
1664
461530.27
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
erp5_drone_simulator/PathTemplateItem/web_page_module/loiter_flight_script.txt
0 → 100644
View file @
dfdc82bc
const ALTITUDE_DIFF = 30,
FLIGH_ALTITUDE = 100,
PARACHUTE_ALTITUDE = 35,
EPSILON = 105,
EPSILON_YAW = 6,
EPSILON_ALTITUDE = 5,
TARGET_YAW = 0,
checkpoint_list = [
{
"latitude": 45.64492790560583,
"longitude": 14.25334942966329,
"altitude": 585.1806861589965
},
{
"latitude": 45.64316335436476,
"longitude": 14.26332880184475,
"altitude": 589.8802607573035
},
{
"latitude": 45.64911917196595,
"longitude": 14.26214792790128,
"altitude": 608.6648153348965
},
{
"latitude": 45.64122685351364,
"longitude": 14.26590493128597,
"altitude": 606.1448368129072
},
{
"latitude": 45.64543355564817,
"longitude": 14.27242391207985,
"altitude": 630.0829598206344
},
{
"latitude": 45.6372792927328,
"longitude": 14.27533492411138,
"altitude": 616.1839898415284
},
{
"latitude": 45.64061299543953,
"longitude": 14.26161958465814,
"altitude": 598.0603137354178
},
{
"latitude": 45.64032340702919,
"longitude": 14.2682896662383,
"altitude": 607.1243119862851
}
],
landing_point = [
{
"latitude": 45.6398451,
"longitude": 14.2699217
}
],
LEADER_ID = 0,
IS_LEADER = me.id === LEADER_ID;
function altitudeReached(altitude, target_altitude) {
//console.log(`[DEMO] Waiting for altitude... (${altitude} , ${target_altitude})`);
return Math.abs(altitude - target_altitude) < EPSILON_ALTITUDE;
}
function distance(lat1, lon1, lat2, lon2) {
const R = 6371e3, // meters
la1 = lat1 * Math.PI/180, // la, lo in radians
la2 = lat2 * Math.PI/180,
lo1 = lon1 * Math.PI/180,
lo2 = lon2 * Math.PI/180;
//haversine formula
const sin_lat = Math.sin((la2 - la1)/2),
sin_lon = Math.sin((lo2 - lo1)/2),
h = sin_lat*sin_lat + Math.cos(la1)*Math.cos(la2)*sin_lon*sin_lon;
return 2*R*Math.asin(Math.sqrt(h));
}
function exit_on_fail(ret, msg) {
if (ret) {
console.log(msg);
me.exit(1);
}
}
function mustWait(timestamp) {
if(me.timestamp === 0) {
me.timestamp = timestamp;
}
return timestamp - me.timestamp < me.must_wait;
}
me.onStart = function() {
console.log("[WEB SCRIPT] WEB WORKER DRONE START!");
/*console.log("distance from 1st point at start:", distance(me.getCurrentPosition().x, me.getCurrentPosition().y,
checkpoint_list[0].latitude,
checkpoint_list[0].longitude));*/
me.direction_set = false;
me.init_alt_reached = false;
me.landing = false;
me.landing_alt_reached = false;
me.must_wait = 3000;
me.next_checkpoint = 0;
me.parachute_triggered = false;
me.start_altitude = me.getInitialAltitude() + FLIGH_ALTITUDE;
me.timestamp = 0;
if (!IS_LEADER) {
me.follow_leader = true;
me.leader_init_alt_reached = false;
me.start_altitude += ALTITUDE_DIFF;
me.must_wait = 0;
}
exit_on_fail(
me.setAltitude(me.start_altitude + 1, true),
"Failed to set start altitude");
};
me.onUpdate = function(timestamp) {
if (!me.init_alt_reached) {
me.init_alt_reached = altitudeReached(me.getAltitudeAbs(), me.start_altitude);
return;
}
if (me.must_wait > 0) {
if (!mustWait(timestamp)) {
me.must_wait = 0;
me.timestamp = 0;
}
return;
}
if (!IS_LEADER && me.follow_leader) {
if (me.drone_dict[LEADER_ID].altitudeAbs === 0) {
return console.log("[DEMO] Waiting for leader to send its altitude");
}
if (!me.leader_init_alt_reached) {
me.leader_init_alt_reached = me.drone_dict[LEADER_ID].altitudeAbs >= me.start_altitude - ALTITUDE_DIFF;
return console.log(`[DEMO] Waiting for leader to reach altitude ${me.start_altitude - ALTITUDE_DIFF} (currently ${me.drone_dict[LEADER_ID].altitudeAbs})`);
}
if (me.drone_dict[LEADER_ID].altitudeRel > PARACHUTE_ALTITUDE) {
exit_on_fail(
me.setTargetCoordinates(
me.drone_dict[LEADER_ID].latitude,
me.drone_dict[LEADER_ID].longitude,
me.drone_dict[LEADER_ID].altitudeAbs + ALTITUDE_DIFF,
30.001
),
"Failed to follow leader");
} else {
me.follow_leader = false;
me.next_checkpoint = me.drone_dict[LEADER_ID].lastCheckpoint + 1;
console.log("[DEMO] Stop following...\n");
}
return;
}
if (!me.direction_set) {
if (me.next_checkpoint < checkpoint_list.length) {
var current_position = me.getCurrentPosition();
var dist = distance(current_position.x, current_position.y,
checkpoint_list[me.next_checkpoint].latitude,
checkpoint_list[me.next_checkpoint].longitude);
/*console.log("---------------------------------------------");
console.log("[SCRIPT] current_position:", current_position);
console.log("[SCRIPT] next_checkpoint:", checkpoint_list[me.next_checkpoint]);
console.log("[SCRIPT] distance:", dist);*/
exit_on_fail(
me.setTargetCoordinates(
checkpoint_list[me.next_checkpoint].latitude,
checkpoint_list[me.next_checkpoint].longitude,
checkpoint_list[me.next_checkpoint].altitude + FLIGH_ALTITUDE,
100
),
"Failed to set checkpoint coordinates");
//console.log(`[DEMO] Going to Checkpoint ${me.next_checkpoint}\n`)
} else {
console.log("[DEMO] Setting landing coordinates...\n");
me.landing_altitude = me.getAltitudeAbs() - me.getCurrentPosition().z + PARACHUTE_ALTITUDE;
exit_on_fail(
/*me.setTargetCoordinates(
checkpoint_list[checkpoint_list.length - 1].latitude,
checkpoint_list[checkpoint_list.length - 1].longitude,
me.landing_altitude,
100
),*/
me.setAltitude(me.landing_altitude, true),
"Failed to set landing coordinates");
}
me.direction_set = true;
return;
}
if (me.next_checkpoint < checkpoint_list.length) {
me.current_position = me.getCurrentPosition();
me.distance = distance(me.current_position.x, me.current_position.y,
checkpoint_list[me.next_checkpoint].latitude,
checkpoint_list[me.next_checkpoint].longitude);
if (me.distance > EPSILON) {
//console.log(`Waiting for drone to get to destination (${me.distance} m)`);
} else {
/*console.log(`[DEMO] Reached Checkpoint ${me.next_checkpoint}\n`);
console.log("[SCRIPT] current_position:", me.current_position);*/
var loiter_center = checkpoint_list[me.next_checkpoint];
/*console.log("[SCRIPT] next_checkpoint:", checkpoint_list[me.next_checkpoint]);
console.log("[SCRIPT] drone-checkpoint distance:", me.distance);*/
me.next_checkpoint += 1;
me.sendMsg(JSON.stringify({ next_checkpoint: me.next_checkpoint }));
me.direction_set = false;
me.must_wait = 30000;
me.loiter();
}
return;
}
if (!me.landing_alt_reached) {
me.landing_alt_reached = altitudeReached(me.getAltitudeAbs(), me.landing_altitude);
return;
}
if (!me.landing) {
me.current_position = me.getCurrentPosition();
me.distance = distance(me.current_position.x, me.current_position.y,
landing_point.latitude, landing_point.longitude);
if (me.distance > 20) {
//console.log(`[DEMO] Waiting to reach landing point (current distance is ${me.distance})`);
} else {
console.log("[DEMO] Landing...\n");
me.landing = true;
}
return;
}
if (!me.parachute_triggered) {
if (Math.abs(me.getYaw() - TARGET_YAW) < EPSILON_YAW) {
console.log("[DEMO] Deploying parachute...");
exit_on_fail(me.doParachute(2), "Failed to deploy parachute");
me.parachute_triggered = true;
} else {
return console.log(`[DEMO] Waiting for yaw...`);
}
}
if (me.landed()) {
console.log("calling me.exit(0) when me.landed");
me.exit(0);
}
};
me.onGetMsg = function(msg) {
me.msgDict = JSON.parse(msg);
if (me.follow_leader && me.msgDict.hasOwnProperty("next_checkpoint")) {
me.next_checkpoint = me.msgDict.next_checkpoint;
}
};
erp5_drone_simulator/PathTemplateItem/web_page_module/loiter_flight_script.xml
0 → 100644
View file @
dfdc82bc
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Web Script"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_Access_contents_information_Permission
</string>
</key>
<value>
<tuple>
<string>
Anonymous
</string>
<string>
Assignee
</string>
<string>
Assignor
</string>
<string>
Associate
</string>
<string>
Auditor
</string>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
_Add_portal_content_Permission
</string>
</key>
<value>
<tuple>
<string>
Assignee
</string>
<string>
Assignor
</string>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
_Change_local_roles_Permission
</string>
</key>
<value>
<tuple>
<string>
Assignor
</string>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
_Modify_portal_content_Permission
</string>
</key>
<value>
<tuple>
<string>
Assignee
</string>
<string>
Assignor
</string>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
_View_Permission
</string>
</key>
<value>
<tuple>
<string>
Anonymous
</string>
<string>
Assignee
</string>
<string>
Assignor
</string>
<string>
Associate
</string>
<string>
Auditor
</string>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
content_md5
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
content_type
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
loiter_flight_script
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
loiter_flight_script
</string>
</value>
</item>
<item>
<key>
<string>
language
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Web Script
</string>
</value>
</item>
<item>
<key>
<string>
short_title
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Loiter flight script
</string>
</value>
</item>
<item>
<key>
<string>
version
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
document_publication_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
edit_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAQ=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
processing_status_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAU=
</string>
</persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_log
</string>
</key>
<value>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
publish_alive
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<global
name=
"DateTime"
module=
"DateTime.DateTime"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1664459507.81
</float>
<string>
UTC
</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
published_alive
</string>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_log
</string>
</key>
<value>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
edit
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1003.18623.52236.6348
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
<value>
<string>
current
</string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<global
name=
"DateTime"
module=
"DateTime.DateTime"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1664460051.36
</float>
<string>
UTC
</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"5"
aka=
"AAAAAAAAAAU="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_log
</string>
</key>
<value>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
external_processing_state
</string>
</key>
<value>
<string>
empty
</string>
</value>
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
0.0.0.0
</string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<global
name=
"DateTime"
module=
"DateTime.DateTime"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1664387279.94
</float>
<string>
UTC
</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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