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
Ivan Tyagov
slapos
Commits
98ebaa5c
Commit
98ebaa5c
authored
Jun 30, 2022
by
Léo-Paul Géneau
👾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/js-drone: add subscribe script
parent
00528782
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
68 additions
and
9 deletions
+68
-9
component/qjs-wrapper/buildout.cfg
component/qjs-wrapper/buildout.cfg
+2
-2
software/js-drone/README.md
software/js-drone/README.md
+3
-1
software/js-drone/buildout.hash.cfg
software/js-drone/buildout.hash.cfg
+7
-3
software/js-drone/common.js
software/js-drone/common.js
+1
-1
software/js-drone/instance.cfg
software/js-drone/instance.cfg
+10
-1
software/js-drone/pubsub.js
software/js-drone/pubsub.js
+1
-1
software/js-drone/software.cfg
software/js-drone/software.cfg
+4
-0
software/js-drone/subscribe.js
software/js-drone/subscribe.js
+40
-0
No files found.
component/qjs-wrapper/buildout.cfg
View file @
98ebaa5c
...
...
@@ -10,8 +10,8 @@ parts = qjs-wrapper
recipe = slapos.recipe.cmmi
shared = true
configure-command = true
url = https://lab.nexedi.com/nexedi/qjs-wrapper/-/archive/v0.
1/qjs-wrapper-v0.1
.tar.gz
md5sum =
4f0eb6f3bc5719a8ec043ce4f4d20747
url = https://lab.nexedi.com/nexedi/qjs-wrapper/-/archive/v0.
2/qjs-wrapper-v0.2
.tar.gz
md5sum =
fa78424e5314d6d3f76e9b0ec28f7878
environment =
C_INCLUDE_PATH=include:${open62541:location}/include:${open62541:location}/deps:${open62541:location}/src/pubsub:${quickjs:location}/include
CPLUS_INCLUDE_PATH=include:${mavsdk:location}/include:${mavsdk:location}/include/mavsdk
...
...
software/js-drone/README.md
View file @
98ebaa5c
...
...
@@ -2,7 +2,7 @@
## Presentation ##
*
Deploy
3 different scripts (
`cli.js`
,
`demo.js`
and
`manual-flight
.js`
) on a drone to fly it
*
Deploy
4 different scripts (
`cli.js`
,
`demo.js`
,
`manual-flight.js`
and
`subscribe
.js`
) on a drone to fly it
*
Compile all required libraries to run flight scripts
...
...
@@ -18,6 +18,8 @@
*
multicast-ipv6: IPv6 of the multicast group of the swarm
*
net-if: Network interface used for multicast traffic
*
drone-id-list: Comma seperated list of the drone IDs of the swarm (recommanded to add the current drone ID)
## How it works ##
...
...
software/js-drone/buildout.hash.cfg
View file @
98ebaa5c
...
...
@@ -14,7 +14,7 @@
# not need these here).
[instance-profile]
filename = instance.cfg
md5sum = 9
9017d061d3be30746f6daef3a7bd8c4
md5sum = 9
c754abbc80f795229c3e79a8ede534b
[cli]
filename = cli.js
...
...
@@ -22,7 +22,7 @@ md5sum = 33271aeec124301604fdd406f0b339d1
[common]
filename = common.js
md5sum =
bacc70f2683c279ba4e0751de616d4ff
md5sum =
1a43f5cf3db1256fee985f82d88930a0
[demo]
filename = demo.js
...
...
@@ -34,4 +34,8 @@ md5sum = 175813fc8b2f19f91dae27ad4e14ab03
[pubsub]
filename = pubsub.js
md5sum = d949c9a6cdaaa94e7bdd22df5e52fbf4
md5sum = 1d1a2be301d74a619b63a33c4b4039da
[subscribe]
filename = subscribe.js
md5sum = 772e84f5584fc66c976778bbd8ae6a65
software/js-drone/common.js
View file @
98ebaa5c
...
...
@@ -162,7 +162,7 @@ export function startPubsub() {
droneDict
[
id
].
init
(
i
);
}
pubsubWorker
.
postMessage
({
action
:
"
run
"
});
pubsubWorker
.
postMessage
({
action
:
"
run
"
,
publish
:
true
});
pubsubRunning
=
true
;
return
droneDict
;
}
...
...
software/js-drone/instance.cfg
View file @
98ebaa5c
...
...
@@ -3,6 +3,7 @@ parts =
cli
demo
manual-flight
subscribe
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
...
...
@@ -33,11 +34,12 @@ init =
options['leader-id'] = options['slapparameter-dict'].get('leader_id', '1')
options['is-leader'] = 'true' if options['id'] == options['leader-id'] else 'false'
options['multicast-ipv6'] = options['slapparameter-dict'].get('multicast_ip', 'ff15::1111')
options['net-if'] = options['slapparameter-dict'].get('net_if', 'eth0')
options['drone-id-list'] = options['slapparameter-dict'].get('drone_id_list', '')
[js-dynamic-template]
recipe = slapos.recipe.template:jinja2
rendered = $${directory:etc}/$${:_buildout_section_name_}
rendered = $${directory:etc}/$${:_buildout_section_name_}
.js
template = ${buildout:directory}/$${:_buildout_section_name_}.js
extra-context =
context =
...
...
@@ -75,3 +77,10 @@ extra-context =
extra-context =
key id drone:id
key ipv6 drone:multicast-ipv6
key net_if drone:net-if
[subscribe]
<= js-dynamic-template
extra-context =
key drone_id_list drone:drone-id-list
key pubsub_script pubsub:rendered
software/js-drone/pubsub.js
View file @
98ebaa5c
...
...
@@ -9,7 +9,7 @@ var parent = Worker.parent;
function
handle_msg
(
e
)
{
switch
(
e
.
data
.
action
)
{
case
"
run
"
:
runPubsub
(
IPV6
,
PORT
,
"
eth0
"
,
{{
id
}}
);
runPubsub
(
IPV6
,
PORT
,
"
{{ net_if }}
"
,
{{
id
}},
e
.
data
.
publish
);
parent
.
postMessage
({
running
:
false
});
parent
.
onmessage
=
null
;
break
;
...
...
software/js-drone/software.cfg
View file @
98ebaa5c
...
...
@@ -11,6 +11,7 @@ parts =
demo
manual-flight
pubsub
subscribe
slapos-cookbook
[download-file-base]
...
...
@@ -37,3 +38,6 @@ output = ${buildout:directory}/template.cfg
[pubsub]
<= download-file-base
[subscribe]
<= download-file-base
software/js-drone/subscribe.js
0 → 100644
View file @
98ebaa5c
/*jslint-disable*/
{
%
set
comma_separated_drone_id_list
=
'
,
'
.
join
(
drone_id_list
.
split
())
-%
}
/*jslint-enable*/
import
{
initPubsub
,
stopPubsub
,
Drone
}
from
"
{{ qjs_wrapper }}
"
;
//jslint-quiet
import
{
Worker
}
from
"
os
"
;
/*jslint-disable*/
import
*
as
std
from
"
std
"
;
/*jslint-enable*/
const
droneIdList
=
[{{
comma_separated_drone_id_list
}}];
const
droneDict
=
{};
var
pubsubWorker
=
new
Worker
(
"
{{ pubsub_script }}
"
);
pubsubWorker
.
onmessage
=
function
(
e
)
{
if
(
!
e
.
data
.
publishing
)
pubsubWorker
.
onmessage
=
null
;
}
initPubsub
(
droneIdList
.
length
);
for
(
let
i
=
0
;
i
<
droneIdList
.
length
;
i
++
)
{
let
id
=
droneIdList
[
i
]
droneDict
[
id
]
=
new
Drone
(
id
);
droneDict
[
id
].
init
(
i
);
}
pubsubWorker
.
postMessage
({
action
:
"
run
"
,
publish
:
false
});
const
f
=
std
.
fdopen
(
std
.
in
,
"
r
"
);
console
.
log
(
"
Use q to quit
"
);
while
(
f
.
getline
()
!=
"
q
"
)
{
continue
;
}
stopPubsub
();
f
.
close
();
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