Live data from Hacker News

Creating an autopilot in X-Plane using Python

austinsnerdythings.com

21–30 of 34 posts

Re: Creating an autopilot in X-Plane using Python

#22
post #2

The Connect API for X-plane is a great toy. I wrote a "recover from upset" script some years ago after having a discussion on the best methods for upset recovery by human pilots. You can easily implement something that does what a human would do and then compare other options that may be possible. The one thing that does make it a bit "easy mode" is that all data is clean and exactly as you would expect mathematicall…

It also seems like the chance of having had sensor failure or disagreements is higher in cases where a human pilot (or autopilot) has lost control of the airplane or exceeded autopilot limits. (It’s by no means all cases, but some LoC incidents are initiated/contributed to by a sensor or avionics failure.)

Absolutely. I've had an instrument failure (invalid attitude indication) cause an autopilot issue that put the aircraft in an upset state in seconds. From there you're manually recovering based on limited data. Fortunately this is a key part of training and unlike the autopilot a human pilot knows to look at the backup instruments and make a judgement on what data is correct.

But that judgement is very hard to code into an automated system. Because there is also a bit of trial and error involved. If indications don't follow your inputs, you're going to assume those indications are wrong and put more weight on the others.

Re: Creating an autopilot in X-Plane using Python

#23

if you want more than just an autopilot I have a almost all 747 400 systems modelled in lua open sourced for xplane 12 at https://github.com/mSparks43/747-400 CBTs linked in an issues milestone.

> CBTs

I wasn't familiar with what that acronym meant in the context of X-Plane but it seems to be "Computer Based Training", and after watching one of them I'm thankful for the 2x playback rate on youtube because whew

Re: Creating an autopilot in X-Plane using Python

#24
O wow. I was not aware of the NASA plugin. I wanted to build a simple dashboard on a separate screen for a while (I run X-plane with a cheap projector which is good enough for the scenery but not for the 6 pack). Each time I explored this I end up with what seems to be windows-only solutions.

The NASA plugin supports a Mac version and it exposes a bidirectional interface to X-plane served up through UDP.... then they provide sample clients.

This worked out of the box, on the Mac I did have to run X-plane in Rosetta2 but I was able to wire this up in a Python web server (native) so now I can display flight data real time in a web browser, nice.

Thanks for getting me on track and good job on the autopilot, will check that out later.

Re: Creating an autopilot in X-Plane using Python

#25
post #3

Wow. Wouldn’t have guessed that a commercial game gets used in certified simulators

I wouldn't characterize it as a game, really. AFAICT (not (yet) a pilot) it's a really a simulator: https://www.x-plane.com/ https://en.wikipedia.org/wiki/X-Plane_(simulator)

Bonus: it supports Linux!

Re: Creating an autopilot in X-Plane using Python

#26
post #23

if you want more than just an autopilot I have a almost all 747 400 systems modelled in lua open sourced for xplane 12 at https://github.com/mSparks43/747-400 CBTs linked in an issues milestone.

> CBTs I wasn't familiar with what that acronym meant in the context of X-Plane but it seems to be "Computer Based Training", and after watching one of them I'm thankful for the 2x playback rate on youtube because whew

noted, I change the title to make that clearer.

CBTs are/should be the starting point to play with any of the "big planes" (anything that needs an ATPL licence to fly), because the systems are pretty complex and unique to the aircraft, they aren't like cars that when you've driven one you can drive them all (licences are actually specific to aircraft designs, known as type ratings)

Re: Creating an autopilot in X-Plane using Python

#28

Cool stuff, Austin! Really liked how you upgraded the X-Plane autopilot with Flask and Redis. Makes tweaking those set points way smoother. It’s neat to see Python take on complex tasks like this. Ever think of messing with this setup for other sims, or throwing in some trickier algorithms? Cheers for laying it all out there!

Yep, I've got plans. But other projects that compete for time, including raising a 1.5 and 3.5 year old. And working on a Tinder for Restaurants (https://monchmatch.com).

Plans include: Direct to, navigating from waypoint to waypoint, automated takeoff, and maybe tracking a ILS/LOC.

Re: Creating an autopilot in X-Plane using Python

#29
post #6
post #3

Wow. Wouldn’t have guessed that a commercial game gets used in certified simulators

Kind of makes sense that a company with relevant expert domain knowledge can double-dip making both pro and game stuff.

This extremely complex grand strategy game is used by some military: https://command.matrixgames.com/

Re: Creating an autopilot in X-Plane using Python

#30
post #11
post #10

You can also do this for Kerbal Space Program using the kRPC mod: https://forum.kerbalspaceprogram.com/topic/130742-18x-to-112... . It's a much less polished experience, but you get more of the experience of an actual avionics/robotics project doing it this way - multiple sensors that may not necessarily agree with each other (for example, IIRC accelerometers installed at different ends of the ship will register diff…

If you want a simpler intro into learning the math/logic behind rocket guidance systems, kOS is an alternative mod. The main difference is that it has a pretty good base autopilot, such that you can give it a direction vector to point to. The downside is that you have to learn a specific language for it, but you can also make your own language that transpiles as a fun project :) Example of what's possible: https://ww…

kOS is a very fun rabbithole, the language can strange at first, it's a reactive paradigm with a special flow. I started with the [PID tutorial](https://ksp-kos.github.io/KOS/tutorials/pidloops.html) to learn PID in a fun environnent. Then programming orbital maneuvers to dig into orbital mechanics.

The community is really active, with a lot of challenges like spaceX booster landing.

Post reply on HN