Board index FlightGear Development

Virtual Panel/Control from Web Browser

FlightGear is opensource, so you can be the developer. In the need for help on anything? We are here to help you.
Forum rules
Core development is discussed on the official FlightGear-Devel development mailing list.

Bugs can be reported in the bug tracker.

Re: Virtual Panel/Control from Web Browser

Postby Hooray » Sat Dec 21, 2013 6:18 pm

like I said previously, you could basically "stream" the canvas image to the browser to display the instrument - interacting with it would be bit more difficult, but still possible.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11329
Joined: Tue Mar 25, 2008 8:40 am

Re: Virtual Panel/Control from Web Browser

Postby Kabuki » Thu Jan 09, 2014 9:53 pm

Hooray wrote in Sat Dec 21, 2013 6:18 pm:like I said previously, you could basically "stream" the canvas image to the browser to display the instrument - interacting with it would be bit more difficult, but still possible.


I built a proxy server in python that talks to flighgear via telnet, and to the browser via websockets. Basic 'set' and 'get' work, but I can't get flightgear's telnet 'subscribe' command to work. I posted on this issue a few days ago, and then thought I had it solved, but I didn't. I'm puzzled.

The thing I really would like, is to be able to subscribe to changes in a property, so that my browser would passively receive changes only, to properties I've subscribed to. If I'm reading the wiki article on Telnet correctly, this is how 'subscribe' is supposed to work. I've carefully avoided subscribing to 'tied' properties. :?:

Can anyone give a working example of using a telnet client to 'subscribe' to property changes?
This is a family-friendly saloon. No talk stink.
Kabuki
 
Posts: 587
Joined: Fri Oct 23, 2009 11:21 pm
Location: Usually on the ground, always in the sky, except when underwater.
Callsign: Kabuki
Version: 3.0.0
OS: Windows 7

Re: Virtual Panel/Control from Web Browser

Postby Hooray » Thu Jan 09, 2014 11:22 pm

I cannot currently check this, but last time I tested it did work properly, and as far as I'm aware, none of the code involved here has been touched in YEARS - so I would be very surprised if subscribing no longer works - I suggest basic troubleshooting, i.e. exclude your program and try running things via telnet directly - if that doesn't work, then you have found a bug (use the issue tracker), if it does work, then the problem is in your code.

</Troubleshooting101>
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11329
Joined: Tue Mar 25, 2008 8:40 am

Re: Virtual Panel/Control from Web Browser

Postby Kabuki » Fri Jan 10, 2014 10:13 pm

Hooray wrote in Thu Jan 09, 2014 11:22 pm: suggest basic troubleshooting, i.e. exclude your program and try running things via telnet directly - if that doesn't work, then you have found a bug (use the issue tracker), if it does work, then the problem is in your code.

</Troubleshooting101>


Well, sure. :roll: I failed to mention that I had been using a telnet client. It seems like whenever some problem comes along that's got me stumped, and I post a question to a forum, I get the answer on my own before anyone replies. Hey, it works.

The problem was that unlike the 'get' command, the 'subscribe' command needs its argument to be the path from the root.

This works:
Code: Select all
> cd /sim/time/real
> get seconds


But you can not:
Code: Select all
> cd /sim/time/real
> subscribe seconds


Instead, you must use
Code: Select all
> subscribe /sim/time/real/seconds


This difference in the syntax wasn't obvious to me. :mrgreen:

Thanks for the advice.
This is a family-friendly saloon. No talk stink.
Kabuki
 
Posts: 587
Joined: Fri Oct 23, 2009 11:21 pm
Location: Usually on the ground, always in the sky, except when underwater.
Callsign: Kabuki
Version: 3.0.0
OS: Windows 7

Re: Virtual Panel/Control from Web Browser

Postby Hooray » Sat Jan 11, 2014 12:26 am

sorry to be so blunt, but this should have been obvious - either by seeing the docs, or just by running "help" - but please do feel free to extend the docs accordingly.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11329
Joined: Tue Mar 25, 2008 8:40 am

Re: Virtual Panel/Control from Web Browser

Postby Johan G » Sat Jan 11, 2014 3:16 pm

Kabuki wrote in Fri Jan 10, 2014 10:13 pm:This works:
Code: Select all
> cd /sim/time/real
> get seconds


But you can not:
Code: Select all
> cd /sim/time/real
> subscribe seconds


Instead, you must use
Code: Select all
> subscribe /sim/time/real/seconds

I would say it is time to send in a feature request. A lot more people will do the same, whether it is documented or not. That non-orthogonality is as near a bug as it can be without being an actual bug. :wink:
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Johan G
Moderator
 
Posts: 5513
Joined: Fri Aug 06, 2010 5:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 3.0.0
OS: Windows 7, 32 bit

Re: Virtual Panel/Control from Web Browser

Postby Hooray » Sat Jan 11, 2014 3:44 pm

Not sure if I agree here - I consider the telnet/props interface the real problem here, working with "relative" paths and CWDs is asking for trouble in my opinion, I have never used the interface like this - I would rather suggest to fix the help message to read "absolute path" instead - otherwise, I'm the one who originally added those subscribe/unsubscribe commands, so I am probably not in the best position to judge usability :D
Extending the code to support relative paths would only require 3-5 lines of code, i.e. is straightforward to do - I just don't believe in the usage pattern very much.
Also, we've been planning on re-implementing the telnet interface using Nasal either way, that would provide the possibility for others to implement such things.
Adding even more stuff to this exceptionally messy part of the code is probably not a good idea.
But yes, please do feel free to file a feature request - it should at least get some more people involved, i.e. more feedback.

Overall, support for "subscriptions" via telnet is a hack, nothing more - it should have been deprecated by HLA, but so far HLA isn't yet quite ready for showtime unfortunately.
I feel it would be better to teach people how to use HLA to do such things, than adding even more stuff to messy, and conceptually-broken, features like the telnet/props code, or even the multiplayer code for that matter.
The underlying code contains some really weird assumptions and lots of hard-coded restrictions, adding stuff to it is always going to be a compromise.
Also, some "important people" in the developer community are fairly opposed to seeing it touched - so it is better to start off with an approach that is more open for contributions, and thus, also more future-proof
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11329
Joined: Tue Mar 25, 2008 8:40 am

Re: Virtual Panel/Control from Web Browser

Postby Kabuki » Sun Jan 12, 2014 1:17 am

@Hooray, I wasn't complaining, just explaining. I just needed to know how it worked, because it is useful, in that it eliminates the need for the client to constantly check for changes in a property.. etc. You wrote it, so you probably know all that.

Definitely it would be nice to be able to use nasal to talk to a socket, and/or (especially) websockets.

In the meantime, I'm just using what I think I can use to make a proxy server that can connect to a browser via websockets, and to flightgear via telnet. I'm using telnet only because it's the least opaque to me, and is more flexible than a generic protocol. Hopefully, I can use this kludge to gain some insight into how a built-in nasal communication channel might be used.

Python is weird. But it is pretty neat to be able to communicate with flightgear via a browser without using the httpd server.

Keep up the good work,
This is a family-friendly saloon. No talk stink.
Kabuki
 
Posts: 587
Joined: Fri Oct 23, 2009 11:21 pm
Location: Usually on the ground, always in the sky, except when underwater.
Callsign: Kabuki
Version: 3.0.0
OS: Windows 7

Re: Virtual Panel/Control from Web Browser

Postby Hooray » Thu Mar 06, 2014 3:39 pm

Update: If this is just about getting some data out of FG via JSON, there's now a new method:
Torsten has simply taken and integrated a complete web server with built-in JSON support and is currently working towards replacing the old httpd code, see the upcoming newsletter (or the devel list) for details - this isn't as flexible or generic as the other methods that were discussed here, and it may also cause people to build stuff that ends up pulling in quite a few dependencies at some point (he even mentioned php ...), but it should at least get you going quickly - and there are a number of potential benefits here over cooking our own httpd implementation (like we used to do) - then again, modernizing stuff in this department has been attempted previously by some people (like mfranz), and that hit quite some resistance back then, so we'll see how this will turn out (hopefully better, this time there was no prior discussion, just the commits and an announcement on the devel list): http://wiki.flightgear.org/FlightGear_N ... pment_news
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11329
Joined: Tue Mar 25, 2008 8:40 am

Previous

Return to Development

Who is online

Users browsing this forum: No registered users and 35 guests