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
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
...
@@ -10,8 +10,8 @@ parts = qjs-wrapper
recipe = slapos.recipe.cmmi
recipe = slapos.recipe.cmmi
shared = true
shared = true
configure-command = true
configure-command = true
url = https://lab.nexedi.com/nexedi/qjs-wrapper/-/archive/v0.
1/qjs-wrapper-v0.1
.tar.gz
url = https://lab.nexedi.com/nexedi/qjs-wrapper/-/archive/v0.
2/qjs-wrapper-v0.2
.tar.gz
md5sum =
4f0eb6f3bc5719a8ec043ce4f4d20747
md5sum =
fa78424e5314d6d3f76e9b0ec28f7878
environment =
environment =
C_INCLUDE_PATH=include:${open62541:location}/include:${open62541:location}/deps:${open62541:location}/src/pubsub:${quickjs:location}/include
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
CPLUS_INCLUDE_PATH=include:${mavsdk:location}/include:${mavsdk:location}/include/mavsdk
...
...
software/js-drone/README.md
View file @
98ebaa5c
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
## Presentation ##
## 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
*
Compile all required libraries to run flight scripts
...
@@ -18,6 +18,8 @@
...
@@ -18,6 +18,8 @@
*
multicast-ipv6: IPv6 of the multicast group of the swarm
*
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)
*
drone-id-list: Comma seperated list of the drone IDs of the swarm (recommanded to add the current drone ID)
## How it works ##
## How it works ##
...
...
software/js-drone/buildout.hash.cfg
View file @
98ebaa5c
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
# not need these here).
# not need these here).
[instance-profile]
[instance-profile]
filename = instance.cfg
filename = instance.cfg
md5sum = 9
9017d061d3be30746f6daef3a7bd8c4
md5sum = 9
c754abbc80f795229c3e79a8ede534b
[cli]
[cli]
filename = cli.js
filename = cli.js
...
@@ -22,7 +22,7 @@ md5sum = 33271aeec124301604fdd406f0b339d1
...
@@ -22,7 +22,7 @@ md5sum = 33271aeec124301604fdd406f0b339d1
[common]
[common]
filename = common.js
filename = common.js
md5sum =
bacc70f2683c279ba4e0751de616d4ff
md5sum =
1a43f5cf3db1256fee985f82d88930a0
[demo]
[demo]
filename = demo.js
filename = demo.js
...
@@ -34,4 +34,8 @@ md5sum = 175813fc8b2f19f91dae27ad4e14ab03
...
@@ -34,4 +34,8 @@ md5sum = 175813fc8b2f19f91dae27ad4e14ab03
[pubsub]
[pubsub]
filename = pubsub.js
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() {
...
@@ -162,7 +162,7 @@ export function startPubsub() {
droneDict
[
id
].
init
(
i
);
droneDict
[
id
].
init
(
i
);
}
}
pubsubWorker
.
postMessage
({
action
:
"
run
"
});
pubsubWorker
.
postMessage
({
action
:
"
run
"
,
publish
:
true
});
pubsubRunning
=
true
;
pubsubRunning
=
true
;
return
droneDict
;
return
droneDict
;
}
}
...
...
software/js-drone/instance.cfg
View file @
98ebaa5c
...
@@ -3,6 +3,7 @@ parts =
...
@@ -3,6 +3,7 @@ parts =
cli
cli
demo
demo
manual-flight
manual-flight
subscribe
eggs-directory = ${buildout:eggs-directory}
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
...
@@ -33,11 +34,12 @@ init =
...
@@ -33,11 +34,12 @@ init =
options['leader-id'] = options['slapparameter-dict'].get('leader_id', '1')
options['leader-id'] = options['slapparameter-dict'].get('leader_id', '1')
options['is-leader'] = 'true' if options['id'] == options['leader-id'] else 'false'
options['is-leader'] = 'true' if options['id'] == options['leader-id'] else 'false'
options['multicast-ipv6'] = options['slapparameter-dict'].get('multicast_ip', 'ff15::1111')
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', '')
options['drone-id-list'] = options['slapparameter-dict'].get('drone_id_list', '')
[js-dynamic-template]
[js-dynamic-template]
recipe = slapos.recipe.template:jinja2
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
template = ${buildout:directory}/$${:_buildout_section_name_}.js
extra-context =
extra-context =
context =
context =
...
@@ -75,3 +77,10 @@ extra-context =
...
@@ -75,3 +77,10 @@ extra-context =
extra-context =
extra-context =
key id drone:id
key id drone:id
key ipv6 drone:multicast-ipv6
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;
...
@@ -9,7 +9,7 @@ var parent = Worker.parent;
function
handle_msg
(
e
)
{
function
handle_msg
(
e
)
{
switch
(
e
.
data
.
action
)
{
switch
(
e
.
data
.
action
)
{
case
"
run
"
:
case
"
run
"
:
runPubsub
(
IPV6
,
PORT
,
"
eth0
"
,
{{
id
}}
);
runPubsub
(
IPV6
,
PORT
,
"
{{ net_if }}
"
,
{{
id
}},
e
.
data
.
publish
);
parent
.
postMessage
({
running
:
false
});
parent
.
postMessage
({
running
:
false
});
parent
.
onmessage
=
null
;
parent
.
onmessage
=
null
;
break
;
break
;
...
...
software/js-drone/software.cfg
View file @
98ebaa5c
...
@@ -11,6 +11,7 @@ parts =
...
@@ -11,6 +11,7 @@ parts =
demo
demo
manual-flight
manual-flight
pubsub
pubsub
subscribe
slapos-cookbook
slapos-cookbook
[download-file-base]
[download-file-base]
...
@@ -37,3 +38,6 @@ output = ${buildout:directory}/template.cfg
...
@@ -37,3 +38,6 @@ output = ${buildout:directory}/template.cfg
[pubsub]
[pubsub]
<= download-file-base
<= 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