MAVlink and JavaScript (recommended way)

1,520 views
Skip to first unread message

anderluntermbiambam

unread,
Jun 24, 2015, 6:31:37 AM6/24/15
to mav...@googlegroups.com
Hi,

I want to use MAVlink in a webbrowser, using JavaScript. What is the recommended way to do so?

I saw that mavgenerate.py supports JavaScript. Is there any documentation on setting up and using the JavaScript sources? Are there any exmaples using MAVlink in JavaScript?

I tried to generate JavaScript using mavgenerate.py, however I get the following error:

Errors occoured in mavgen:
[Errno 2] No such file or directory:
'./javascript/lib/jspack/jspack.js'

Any ideas how to resolve that?

Kind regards
Andi

Andreas Antener

unread,
Jun 24, 2015, 6:40:49 AM6/24/15
to mav...@googlegroups.com
Hi Andi

It should basically work, but haven’t used it in a while. I think you only miss the submodule it depends on (jspack).

Try to init/update your git submodules:
git submodule init
git submodule update

Also, see the following readme for more information on the JS implementation:


Cheers
ada

--
UAVenture AG
http://www.uaventure.com

--
Sie erhalten diese Nachricht, weil Sie in Google Groups E-Mails von der Gruppe "MAVLink" abonniert haben.
Wenn Sie sich von dieser Gruppe abmelden und keine E-Mails mehr von dieser Gruppe erhalten möchten, senden Sie eine E-Mail an mavlink+u...@googlegroups.com.
Weitere Optionen finden Sie unter https://groups.google.com/d/optout.

anderluntermbiambam

unread,
Jun 24, 2015, 7:17:17 AM6/24/15
to mav...@googlegroups.com
Hi Ada,

thank you for the quick response. I did the git commands you posted. Now the jspack directory is not empty anymore. However I still get the same error about jspack.

By the way ... is this a node.js implementation or pure javascript?

Kind regards

Andreas Antener

unread,
Jun 24, 2015, 7:54:56 AM6/24/15
to mav...@googlegroups.com
Ok, I see the problem. The javascript generation assumes a certain run directory. Don’t worry about it, despite the error you should have the generated *.js file at the out location you specified. Just copy the jspack.js file from the submodule to the same location and it should work.

It depends on node.js. But I guess it should be possible to make it run in the browser with some effort. Most dependencies are easily replaced, the use of “Buffer" might need some work. You could try to use a nodejs Buffer replacement for browsers. I know those exist but I have never used/tried it.

I think the guy from Mavelous did something like that: https://github.com/wiseman/mavelous#readme

Cheers
ada

--
UAVenture AG
http://www.uaventure.com

Bruce Crevensten

unread,
Jun 25, 2015, 1:02:18 PM6/25/15
to mav...@googlegroups.com
Hi Andi,

I wrote the initial Javascript implementation of the MAVLink protocol and can help you with this off-list.  I've actually got a slightly-updated implementation that improves a few rough spots with the version currently in the master repository, and will get that into a pull request here today.

I've built a functioning (though pre-alpha) ground control station with pure Javascript (NodeJS / Express / Socket.io / Backbone), you can see that code here:


Hit me up off-list if you have more specific questions.
Bruce Crevensten

Senior Software Engineer
(SNAP) Scenarios Network for Alaska & Arctic Planning

Andreas Antener

unread,
Jun 25, 2015, 3:31:52 PM6/25/15
to mav...@googlegroups.com
Hi Bruce, looking forward to your PR.

But using NodeJS is not pure JS ;), as far I can see you’re still depending on the Buffer class.

- ada

--
UAVenture AG
http://www.uaventure.com

Bruce Crevensten

unread,
Jun 25, 2015, 4:30:13 PM6/25/15
to mav...@googlegroups.com
Oh, I see what you meant by that now, sorry.  Right, this MAVLink implementation is a NodeJS implementation, not pure Javascript!

So you're interesting in swapping in something along these lines:


?

Andreas Antener

unread,
Jun 29, 2015, 2:44:43 PM6/29/15
to mav...@googlegroups.com
Hi Bruce

That library sounds like a good fit if @Andi want’s to try it ;). If it works we could make this a generation option for JS MAVLink.

A while ago I was actually wondering my self if I should try it this way (i.e. sending MAVLink to the browser).. I also have written a small piece of ground control station in JS with Node and Primus (WS). It’s actually more a MAVLink proxy that has a very rudimentary web interface. (Still need to make it public..)

I figured, if you parse MAVLink on the server, you can just send the JSON representation to the browser which therefore doesn’t introduce a new protocol, and you can just read it without libraries. What’s you opinion on that? (for the case where you have a server anyway)

Cheers
ada

--
UAVenture AG
http://www.uaventure.com

phil cleaver

unread,
Feb 27, 2017, 5:56:13 AM2/27/17
to MAVLink
Hi,

Did you ever get this to work with straight JS?

Would love to see your work.

Giggles
Message has been deleted

Jay

unread,
Oct 28, 2017, 1:36:21 PM10/28/17
to MAVLink
Hi Ada

Where did you guys get to with your progress?
Reply all
Reply to author
Forward
0 new messages