Board index FlightGear Support Interfacing

Python implementation of fgpanel

Connecting two computers, using generic protocol, connecting with Matlab?

Python implementation of fgpanel

Postby dhudach » Wed Jul 24, 2019 6:54 pm

I've looked at some of the documentation, guides and information on how to build fgpanel on Raspberry Pi. So I spent a few days trying and pretty much got nowhere. So I called a time out to give it some more thought. And then it occurred to me that fgpanel really doesn't care that it's animating a flight simulator. The basic mechanism of fgpanel is to display images, move certain images based on data. That's it. So I wondered if it would be possible to write a standalone utility in python that does essentially what fgpanel does. And that's what I've done. I tried to keep the format and use of the xml files consistent with how they are used in flightgear and fgpanel, but I changed a few things to make the python implementation a bit easier.

I have NOT yet run this on Raspberry Pi, that will be the next attempt. For now, this is a youtube clip (SenecaII) that I created that shows flightgear on the left and the right panel contains a clock (the time is off a bit, I need to fix the animation), manifold pressure and vacuum gauge. There is no audio, just video capture. I can use most of the flightgear instrument images, converting the rgb format to png using GIMP.

dhudach
 
Posts: 75
Joined: Mon Apr 13, 2015 11:46 pm

Re: Python implementation of fgpanel

Postby dhudach » Tue Aug 06, 2019 12:21 pm

The python implementation of fgpanel is about as complete as I need at this point. It even handles the 'condition' elements that determine if instrument component images are to be visible. I created three individual panels that render numerous instruments. I still need to adjust the clock time and I need to take a look at the engine amp gauges. This clip shows each panel operating during a brief SenecaII flight. The python script uses the python pygame module to display the graphics. The reason I wrote this is because my initial plan was to use Raspberry Pi to run fgpanel but I spent two days trying to build fgpanel on Pi with no luck. So I decided to give this a try. I have not yet run this on Pi. I managed to acquire a couple cheap laptops that I'll use instead. I'll simply install some form of linux on them to run these python panel scripts.

dhudach
 
Posts: 75
Joined: Mon Apr 13, 2015 11:46 pm

Re: Python implementation of fgpanel

Postby SurferTim » Tue Aug 06, 2019 12:54 pm

Sweet! If you wouldn't mind sharing, I have several RPis here that I can try them on.. They seem to hold their own with Python and Pygame.

I already have Python and Pygame installed.

Edit: I also have Tinker Board and nVidia Jetson Nano.
Fly low, fly slow, land on a dime. Twin Otter.
SurferTim
 
Posts: 378
Joined: Sun Dec 09, 2018 5:49 pm
Location: Miramar Beach, FL
Callsign: Pirate
Version: 2019.2.0
OS: Ubuntu 18.04

Re: Python implementation of fgpanel

Postby dhudach » Tue Aug 06, 2019 1:03 pm

Thanks. Let's think about how I could get the source code and samples to you. I've been planning to test them on my Raspberry Pi but just haven't gotten around to it yet. I don't want to just post the entire code in a post here, it might be a bit too much.
dhudach
 
Posts: 75
Joined: Mon Apr 13, 2015 11:46 pm

Re: Python implementation of fgpanel

Postby SurferTim » Tue Aug 06, 2019 1:06 pm

I used several types of flight panels when designing a drone, and the RPi3 held up just fine.

As I recall Python is installed by default, and Pygame is
Code: Select all
sudo apt-get install python-pygame

Insure your version of Raspian is up-to-date.

Edit: I forgot one important thing I discovered about the RPi3. If you run it with Pygame graphics, the processor is gonna get hot, and if it gets too hot, it auto-thottles. Stuff slows way down. Heat sink and fan highly recommended.
Fly low, fly slow, land on a dime. Twin Otter.
SurferTim
 
Posts: 378
Joined: Sun Dec 09, 2018 5:49 pm
Location: Miramar Beach, FL
Callsign: Pirate
Version: 2019.2.0
OS: Ubuntu 18.04

Re: Python implementation of fgpanel

Postby dhudach » Tue Aug 06, 2019 1:32 pm

That's good information to know about Pi. If there is an interest, I would like to contribute my python project to Flightgear. But I'm not sure how to do that. Yes, I think your apt-get snippet is what I used to install pygame. I had never programmed in python, but it wasn't too bad. My goal as always in the early stages of a project like this is to keep it simple. The code uses a handful of classes.
dhudach
 
Posts: 75
Joined: Mon Apr 13, 2015 11:46 pm

Re: Python implementation of fgpanel

Postby SurferTim » Tue Aug 06, 2019 1:40 pm

Did you get the Pygame code to run on the RPi?

For sharing, Github isn't too bad. I have my own domain/server.

I'm sure we can help you share your code, as I will mine. Not nearly as complex as yours, but it is all I needed for the Citation X.
Fly low, fly slow, land on a dime. Twin Otter.
SurferTim
 
Posts: 378
Joined: Sun Dec 09, 2018 5:49 pm
Location: Miramar Beach, FL
Callsign: Pirate
Version: 2019.2.0
OS: Ubuntu 18.04

Re: Python implementation of fgpanel

Postby dhudach » Tue Aug 06, 2019 1:56 pm

I didn't even try to run this on Pi. After I threw in the towel trying to build fgpanel on Pi, I tried to come up with another solution. It's then that it occurred to me that fgpanel in its essence doesn't care that it's a flight simulator. All it is really doing is displaying and 'moving' images based on incoming data. So I thought about simple graphics scripting languages and python was the first that I saw. I have written some short python scripts that run between FG and Arduino so I gave python/pygame a try. So I built a simple proof of concept. When that worked, I decided to write the entire implementation in python. At each step when I wanted to try it on Pi, I decided to continue building all of the instruments and that meant adding features, fixes and enhancements to the python code. So that's where I am. I may not have a need for Pi at this point. A friend donated a couple old laptops and I'm going to try to boot each into persistent linux on a usb flash drive and try running the python panels (that I call pypanel). That's the next step. So for now, I'm going to set aside Pi with python for the panels.
dhudach
 
Posts: 75
Joined: Mon Apr 13, 2015 11:46 pm

Re: Python implementation of fgpanel

Postby wkitty42 » Wed Aug 07, 2019 2:31 pm

dhudach wrote in Tue Aug 06, 2019 1:03 pm:I don't want to just post the entire code in a post here, it might be a bit too much.

put it in a git repo so others can access it from there... then the repo can keep up with your updates and fixes to the code, too...

you should figure out what license you want to release the code with, too... github, gitlab, and SF are three git repo hosts that i know of immediately... there are others, i'm sure... and you could host your own git repo if you have your own server running somewhere...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 5707
Joined: Fri Feb 20, 2015 3:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 14.04.5

Re: Python implementation of fgpanel

Postby dhudach » Wed Aug 07, 2019 2:47 pm

Let me give some thought to all of this. I have to digest the information you have provided!! I'm sure I'll have a question or .... 50 when I decide to 'release' the project.

Thanks for the information,

Dave
dhudach
 
Posts: 75
Joined: Mon Apr 13, 2015 11:46 pm

Re: Python implementation of fgpanel

Postby daweed » Thu Aug 08, 2019 8:02 am

Hello, i can be interested too in this "fgpanel" for RPI, plus that is in python as my interface code, that could be fit perfectly

Regards

Daweed
Linux Mint 18.3
AMD FX 4300 Quad-Core Black Edition|20 Go RAMGeForce GTX 750 Ti
FG Interface
Lyon Saint Exupery Scenery

ATC on LFLL on Friday 19:00 UTC => 22:00 UTC
daweed
 
Posts: 328
Joined: Thu Dec 11, 2014 10:45 am
Location: LFKP LFLL
Callsign: daweed
OS: Linux Mint 19.2

Re: Python implementation of fgpanel

Postby dhudach » Thu Aug 08, 2019 9:44 am

Thanks for the interest. I'm doing some code clean up. I need to think about how I want to contribute this project.
dhudach
 
Posts: 75
Joined: Mon Apr 13, 2015 11:46 pm

Re: Python implementation of fgpanel

Postby dhudach » Sat Aug 31, 2019 9:36 am

I was somewhat concerned about performance and responsiveness of the python panels. On a decently fast PC things were fine. But on an older, small laptop, there was some lag. They were kind of ok below about 15 protocol output lines per second from FG. But above that, things got choppy. Python had a difficult time keeping up with the rate of the incoming data.

So I decided to look into writing essentially the same python program but in C++. In my research I found that SDL could be used to render the graphics. So I wrote what I'm calling cppanel. It's basically the same python code design but written in C++ using SDL. I have not built it or run it on the smaller laptops, but performance seems really good on my main laptop. The next steps will be to get it built and running on the small laptops that I plan on using to display various instruments in a cockpit configuration.

I'll get some videos together in the coming days and I'll post them in this forum.
dhudach
 
Posts: 75
Joined: Mon Apr 13, 2015 11:46 pm


Return to Interfacing

Who is online

Users browsing this forum: No registered users and 2 guests