Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
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
slapos
Commits
28e45b22
Commit
28e45b22
authored
Jan 24, 2024
by
Léo-Paul Géneau
👾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/js-drone: Set loop execution period as an instance parameter
parent
b7780cc1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
23 additions
and
13 deletions
+23
-13
software/js-drone/buildout.hash.cfg
software/js-drone/buildout.hash.cfg
+3
-3
software/js-drone/drone-scripts/main.js.jinja
software/js-drone/drone-scripts/main.js.jinja
+8
-8
software/js-drone/instance-input-schema.json
software/js-drone/instance-input-schema.json
+6
-0
software/js-drone/instance-root.cfg.jinja
software/js-drone/instance-root.cfg.jinja
+1
-0
software/js-drone/instance.cfg.in
software/js-drone/instance.cfg.in
+2
-1
software/js-drone/test/test.py
software/js-drone/test/test.py
+3
-1
No files found.
software/js-drone/buildout.hash.cfg
View file @
28e45b22
...
...
@@ -22,11 +22,11 @@ md5sum = 01425a1c77e79788e1948398b9136724
[instance-profile]
filename = instance.cfg.in
md5sum =
1fc2d0375dad559fe2dca4822bfa6f69
md5sum =
0a8bde4a885bd99ed9e591ef970bbaf4
[instance-root]
filename = instance-root.cfg.jinja
md5sum =
08cbb1ffc6625e02046f7e7185ff70ac
md5sum =
e22626f4465f9e696eb1b84900a150ff
[instance-subscriber]
filename = instance-subscriber.cfg.in
...
...
@@ -34,7 +34,7 @@ md5sum = 8559dc8c95e9232060be6db3e0af4379
[main]
_update_hash_filename_ = drone-scripts/main.js.jinja
md5sum =
089e84ebf7f0467c81728d8a69996fcf
md5sum =
85135842e42a1f48a474467508723c0c
[pubsub]
_update_hash_filename_ = drone-scripts/pubsub.js.jinja
...
...
software/js-drone/drone-scripts/main.js.jinja
View file @
28e45b22
...
...
@@ -61,7 +61,7 @@ import { err, exit, open, out } from "std";
tail_pid,
worker,
user_script = scriptArgs[1],
FPS = 200, // Minimum value to not overflow radio network
LOOP_EXECUTION_PERIOD = configuration.loopPeriod,
previous_timestamp,
can_update = false;
...
...
@@ -177,23 +177,23 @@ import { err, exit, open, out } from "std";
var timestamp = Date.now(),
timeout;
if (can_update) {
if (
FPS
<= (timestamp - previous_timestamp)) {
if (
LOOP_EXECUTION_PERIOD
<= (timestamp - previous_timestamp)) {
// Expected timeout between every update
can_update = false;
worker.postMessage({
type: "update",
timestamp: timestamp
});
// Try to stick to the expected
FPS
timeout =
FPS - (timestamp - previous_timestamp - FPS
);
// Try to stick to the expected
LOOP_EXECUTION_PERIOD
timeout =
LOOP_EXECUTION_PERIOD - (timestamp - previous_timestamp - LOOP_EXECUTION_PERIOD
);
previous_timestamp = timestamp;
} else {
timeout =
FPS
- (timestamp - previous_timestamp);
timeout =
LOOP_EXECUTION_PERIOD
- (timestamp - previous_timestamp);
}
} else {
// If timeout occurs, but update is not yet finished
// wait a bit
timeout =
FPS
/ 4;
timeout =
LOOP_EXECUTION_PERIOD
/ 4;
}
// Ensure loop is not done with timeout < 1ms
setTimeout(loop, Math.max(1, timeout));
...
...
@@ -205,12 +205,12 @@ import { err, exit, open, out } from "std";
pubsubWorker.postMessage({
action: "run",
id: configuration.id,
interval:
FPS
,
interval:
LOOP_EXECUTION_PERIOD
,
publish: configuration.isADrone
});
load();
} else if (type === 'loaded') {
previous_timestamp = -
FPS
;
previous_timestamp = -
LOOP_EXECUTION_PERIOD
;
can_update = true;
// Start the update loop
loop();
...
...
software/js-drone/instance-input-schema.json
View file @
28e45b22
...
...
@@ -56,6 +56,12 @@
"type"
:
"string"
,
"default"
:
"https://lab.nexedi.com/nexedi/flight-scripts/raw/master/default.js"
},
"loopPeriod"
:
{
"title"
:
"Loop execution period"
,
"description"
:
"Minimal period between 2 executions of flight script loop"
,
"type"
:
"integer"
,
"default"
:
200
},
"subscriberGuidList"
:
{
"title"
:
"List of subscribers computer ID"
,
"description"
:
"List of computer ID of swarms subscribers (entities able to listen/send OPC-UA messages from/to the swarm)"
,
...
...
software/js-drone/instance-root.cfg.jinja
View file @
28e45b22
...
...
@@ -26,6 +26,7 @@ config-numberOfDrones = {{ dumps(len(parameter_dict['droneGuidList'])) }}
config-numberOfSubscribers = {{ dumps(len(parameter_dict['subscriberGuidList'])) }}
config-id = {{ dumps(id) }}
config-debug = {{ dumps(parameter_dict['debug']) }}
config-loopPeriod = {{ dumps(parameter_dict['loopPeriod']) }}
{% if id < len(parameter_dict['droneGuidList']) -%}
{% do drone_id_list.append(id) %}
config-isADrone = {{ dumps(True) }}
...
...
software/js-drone/instance.cfg.in
View file @
28e45b22
...
...
@@ -35,10 +35,11 @@ default-parameters =
"autopilotIp": "192.168.27.1",
"autopilotPort": 7909,
"debug": false,
"droneGuidList": [],
"droneNetIf": "eth0",
"flightScript": "https://lab.nexedi.com/nexedi/flight-scripts/raw/master/default.js",
"loopPeriod": 200,
"multicastIp": "ff15::1111",
"droneGuidList": [],
"subscriberGuidList":[],
"subscriberNetIf": "eth0"
}
software/js-drone/test/test.py
View file @
28e45b22
...
...
@@ -52,6 +52,7 @@ MONITORED_ITEM_NB = 4
OPC_UA_PORT
=
4840
OPC_UA_NET_IF
=
'lo'
MCAST_GRP
=
'ff15::1111'
LOOP_PERIOD
=
200
# OPC UA Pub/Sub related constants
VERSION
=
1
...
...
@@ -262,6 +263,7 @@ class SubscriberTestCase(SlapOSInstanceTestCase):
'numberOfSubscribers'
:
1
,
'id'
:
1
,
'isADrone'
:
False
,
'loopPeriod'
:
LOOP_PERIOD
,
'flightScript'
:
'https://lab.nexedi.com/nexedi/flight-scripts/raw/api_update/subscribe.js'
,
'netIf'
:
OPC_UA_NET_IF
,
'multicastIp'
:
MCAST_GRP
...
...
@@ -302,7 +304,7 @@ class SubscriberTestCase(SlapOSInstanceTestCase):
)),
)
self
.
send_ua_networkMessage
()
time
.
sleep
(
0.1
)
time
.
sleep
(
100
)
self
.
assertEqual
(
ws
.
recv_frame
().
data
,
MESSAGE_CONTENT
.
replace
(
b'
\
\
'
,
b''
))
self
.
assertEqual
(
ws
.
recv_frame
().
data
,
...
...
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