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
Xavier Thompson
slapos
Commits
e5ef7b00
Commit
e5ef7b00
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
51fbcbb8
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
12 deletions
+23
-12
software/js-drone/README.md
software/js-drone/README.md
+1
-0
software/js-drone/buildout.hash.cfg
software/js-drone/buildout.hash.cfg
+3
-3
software/js-drone/drone-scripts/main.js.jinja2
software/js-drone/drone-scripts/main.js.jinja2
+8
-8
software/js-drone/instance-input-schema.json
software/js-drone/instance-input-schema.json
+6
-0
software/js-drone/instance-root.cfg.jinja2
software/js-drone/instance-root.cfg.jinja2
+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
+2
-0
No files found.
software/js-drone/README.md
View file @
e5ef7b00
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
*
debug: Must be set to 'true' to send drone logs through OPC-UA
*
debug: Must be set to 'true' to send drone logs through OPC-UA
*
multicastIp: IPv6 of the multicast group of the swarm
*
multicastIp: IPv6 of the multicast group of the swarm
*
flightScript: URL of user's script to execute to fly drone swarm
*
flightScript: URL of user's script to execute to fly drone swarm
*
loopPeriod: Minimal period (in milliseconds) between 2 executions of the flight script loop
*
subscriberGuidList: List of computer id on which a GUI must be deployed
*
subscriberGuidList: List of computer id on which a GUI must be deployed
*
subscriberNetIf: Subscriber network interface used for multicast traffic
*
subscriberNetIf: Subscriber network interface used for multicast traffic
...
...
software/js-drone/buildout.hash.cfg
View file @
e5ef7b00
...
@@ -22,11 +22,11 @@ md5sum = 01425a1c77e79788e1948398b9136724
...
@@ -22,11 +22,11 @@ md5sum = 01425a1c77e79788e1948398b9136724
[instance-profile]
[instance-profile]
filename = instance.cfg.in
filename = instance.cfg.in
md5sum =
9c99b9b11e886eee41210e83be239a78
md5sum =
4733c63573e6812c124b356dc146ffcc
[instance-root]
[instance-root]
filename = instance-root.cfg.jinja2
filename = instance-root.cfg.jinja2
md5sum =
626a93a93c89e0fdcab5c25eec1343da
md5sum =
316f77c655540226f22dc7a6322624f1
[instance-subscriber]
[instance-subscriber]
filename = instance-subscriber.cfg.in
filename = instance-subscriber.cfg.in
...
@@ -34,7 +34,7 @@ md5sum = 8559dc8c95e9232060be6db3e0af4379
...
@@ -34,7 +34,7 @@ md5sum = 8559dc8c95e9232060be6db3e0af4379
[main]
[main]
_update_hash_filename_ = drone-scripts/main.js.jinja2
_update_hash_filename_ = drone-scripts/main.js.jinja2
md5sum =
cfdb011b995e976b750fc2c707fbec78
md5sum =
60146505ec8ea50d881d033f63b6725c
[pubsub]
[pubsub]
_update_hash_filename_ = drone-scripts/pubsub.js.jinja2
_update_hash_filename_ = drone-scripts/pubsub.js.jinja2
...
...
software/js-drone/drone-scripts/main.js.jinja2
View file @
e5ef7b00
...
@@ -49,7 +49,7 @@ import { err, exit, open, out } from "std";
...
@@ -49,7 +49,7 @@ import { err, exit, open, out } from "std";
pubsubWorker,
pubsubWorker,
worker,
worker,
user_script = scriptArgs[1],
user_script = scriptArgs[1],
FPS = 200, // Minimum value to not overflow radio network
LOOP_EXECUTION_PERIOD = configuration.loopPeriod,
previous_timestamp,
previous_timestamp,
can_update = false;
can_update = false;
...
@@ -154,23 +154,23 @@ import { err, exit, open, out } from "std";
...
@@ -154,23 +154,23 @@ import { err, exit, open, out } from "std";
var timestamp = Date.now(),
var timestamp = Date.now(),
timeout;
timeout;
if (can_update) {
if (can_update) {
if (
FPS
<= (timestamp - previous_timestamp)) {
if (
LOOP_EXECUTION_PERIOD
<= (timestamp - previous_timestamp)) {
// Expected timeout between every update
// Expected timeout between every update
can_update = false;
can_update = false;
worker.postMessage({
worker.postMessage({
type: "update",
type: "update",
timestamp: timestamp
timestamp: timestamp
});
});
// Try to stick to the expected
FPS
// Try to stick to the expected
LOOP_EXECUTION_PERIOD
timeout =
FPS - (timestamp - previous_timestamp - FPS
);
timeout =
LOOP_EXECUTION_PERIOD - (timestamp - previous_timestamp - LOOP_EXECUTION_PERIOD
);
previous_timestamp = timestamp;
previous_timestamp = timestamp;
} else {
} else {
timeout =
FPS
- (timestamp - previous_timestamp);
timeout =
LOOP_EXECUTION_PERIOD
- (timestamp - previous_timestamp);
}
}
} else {
} else {
// If timeout occurs, but update is not yet finished
// If timeout occurs, but update is not yet finished
// wait a bit
// wait a bit
timeout =
FPS
/ 4;
timeout =
LOOP_EXECUTION_PERIOD
/ 4;
}
}
// Ensure loop is not done with timeout < 1ms
// Ensure loop is not done with timeout < 1ms
setTimeout(loop, Math.max(1, timeout));
setTimeout(loop, Math.max(1, timeout));
...
@@ -182,12 +182,12 @@ import { err, exit, open, out } from "std";
...
@@ -182,12 +182,12 @@ import { err, exit, open, out } from "std";
pubsubWorker.postMessage({
pubsubWorker.postMessage({
action: "run",
action: "run",
id: configuration.id,
id: configuration.id,
interval:
FPS
,
interval:
LOOP_EXECUTION_PERIOD
,
publish: configuration.isADrone
publish: configuration.isADrone
});
});
load();
load();
} else if (type === 'loaded') {
} else if (type === 'loaded') {
previous_timestamp = -
FPS
;
previous_timestamp = -
LOOP_EXECUTION_PERIOD
;
can_update = true;
can_update = true;
// Start the update loop
// Start the update loop
loop();
loop();
...
...
software/js-drone/instance-input-schema.json
View file @
e5ef7b00
...
@@ -62,6 +62,12 @@
...
@@ -62,6 +62,12 @@
"type"
:
"string"
,
"type"
:
"string"
,
"default"
:
"https://lab.nexedi.com/nexedi/flight-scripts/-/raw/v2.0/default.js"
"default"
:
"https://lab.nexedi.com/nexedi/flight-scripts/-/raw/v2.0/default.js"
},
},
"loopPeriod"
:
{
"title"
:
"Loop execution period"
,
"description"
:
"Minimal period between 2 executions of flight script loop"
,
"type"
:
"integer"
,
"default"
:
200
},
"subscriberGuidList"
:
{
"subscriberGuidList"
:
{
"title"
:
"List of subscribers computer ID"
,
"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)"
,
"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.jinja2
View file @
e5ef7b00
...
@@ -27,6 +27,7 @@ config-numberOfSubscribers = {{ dumps(len(parameter_dict['subscriberGuidList']))
...
@@ -27,6 +27,7 @@ config-numberOfSubscribers = {{ dumps(len(parameter_dict['subscriberGuidList']))
config-id = {{ dumps(id) }}
config-id = {{ dumps(id) }}
config-isASimulation = {{ dumps(parameter_dict['isASimulation']) }}
config-isASimulation = {{ dumps(parameter_dict['isASimulation']) }}
config-debug = {{ dumps(parameter_dict['debug']) }}
config-debug = {{ dumps(parameter_dict['debug']) }}
config-loopPeriod = {{ dumps(parameter_dict['loopPeriod']) }}
{% if id < len(parameter_dict['droneGuidList']) -%}
{% if id < len(parameter_dict['droneGuidList']) -%}
{% do drone_id_list.append(id) %}
{% do drone_id_list.append(id) %}
config-isADrone = {{ dumps(True) }}
config-isADrone = {{ dumps(True) }}
...
...
software/js-drone/instance.cfg.in
View file @
e5ef7b00
...
@@ -35,11 +35,12 @@ default-parameters =
...
@@ -35,11 +35,12 @@ default-parameters =
"autopilotIp": "192.168.27.1",
"autopilotIp": "192.168.27.1",
"autopilotPort": 7909,
"autopilotPort": 7909,
"debug": false,
"debug": false,
"droneGuidList": [],
"droneNetIf": "eth0",
"droneNetIf": "eth0",
"flightScript": "https://lab.nexedi.com/nexedi/flight-scripts/-/raw/v2.0/default.js",
"flightScript": "https://lab.nexedi.com/nexedi/flight-scripts/-/raw/v2.0/default.js",
"isASimulation": false,
"isASimulation": false,
"loopPeriod": 200,
"multicastIp": "ff15::1111",
"multicastIp": "ff15::1111",
"droneGuidList": [],
"subscriberGuidList":[],
"subscriberGuidList":[],
"subscriberNetIf": "eth0"
"subscriberNetIf": "eth0"
}
}
software/js-drone/test/test.py
View file @
e5ef7b00
...
@@ -54,6 +54,7 @@ MONITORED_ITEM_NB = 4
...
@@ -54,6 +54,7 @@ MONITORED_ITEM_NB = 4
OPC_UA_PORT
=
4840
OPC_UA_PORT
=
4840
OPC_UA_NET_IF
=
'lo'
OPC_UA_NET_IF
=
'lo'
MCAST_GRP
=
'ff15::1111'
MCAST_GRP
=
'ff15::1111'
LOOP_PERIOD
=
200
# OPC UA Pub/Sub related constants
# OPC UA Pub/Sub related constants
VERSION
=
1
VERSION
=
1
...
@@ -280,6 +281,7 @@ class SubscriberTestCase(SlapOSInstanceTestCase):
...
@@ -280,6 +281,7 @@ class SubscriberTestCase(SlapOSInstanceTestCase):
'id'
:
1
,
'id'
:
1
,
'debug'
:
False
,
'debug'
:
False
,
'isASimulation'
:
False
,
'isASimulation'
:
False
,
'loopPeriod'
:
LOOP_PERIOD
,
'isADrone'
:
False
,
'isADrone'
:
False
,
'flightScript'
:
'https://lab.nexedi.com/nexedi/flight-scripts/-/raw/v2.0/subscribe.js'
,
'flightScript'
:
'https://lab.nexedi.com/nexedi/flight-scripts/-/raw/v2.0/subscribe.js'
,
'netIf'
:
OPC_UA_NET_IF
,
'netIf'
:
OPC_UA_NET_IF
,
...
...
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