MOARdV / AvionicsSystems

MOARdV's Avionics Systems for Kerbal Space Program - a new generation of IVA enhancement.
Other
53 stars 26 forks source link

Airplane Autopilot functions / interface #303

Open theonegalen opened 4 years ago

theonegalen commented 4 years ago

Is it possible to be able to input a target attitude, altitude, heading, and speed and have MAS point an aircraft in that direction would be very helpful to the plane autopilot prop / prop constellation I want to put together. From that point, I have an idea on how to create flight plans and autopilot. I figure it would be a pain to code this natively in MAS, is it at all possible to construct a bridge to Atmosphere Autopilot, the way RPM used to work with PilotAssistant? Atmosphere Autopilot does use hotkeys, and I wonder if that would make it possible to give instructions to AA from MAS. I really don't know enough coding to figure it out quickly.

Honestly, this is the biggest thing holding me back from jumping into MAS right now. Having to have the Atmosphere Autopilot window separately from the IVA instruments goes against exactly what I want IVA flight for at all. :-/

https://forum.kerbalspaceprogram.com/index.php?/topic/124417-180-1101-atmosphereautopilot-1516/

These are the functions that I think would be useful for the prop I'd like to create:

MOARdV commented 4 years ago

I'll venture a guess that a MAS interface is possible, since the first post for that mod includes a link to a kOS interface. I think there are two major issues with adding an AA interface - first, I don't use the mod (so I'll need to learn enough about it to be able to implement and test it), and second, I'd have to maintain compatibility with it (which, since I don't use it, means extra effort). Then again, I'd really like to fly some aircraft, so maybe I should spend some time learning the mod. :)

I can't say when I'll get to this. I'm freezing major features right now, since my top priority is to suck it up and get the ASET Props MAS conversion done. If I can finish that, I think there'll be more eyes on MAS, since being able to tell RPM players that the IVAs they like to use will magically work in MAS would be a Big Deal for MAS use.

theonegalen commented 4 years ago

Is there any way I can help you with the conversions? I'm not as familiar with the MAS functions as you are, but I at least used to know RPM rather well.

MOARdV commented 4 years ago

I'm always happy to accept help. :)

Issue 277 has the master list of all of the ASET prop directories that contain RPM-enabled props, although I need to tidy it up a little bit. Other than the sheer number of props, the secondary issue is finding IVAs that make use of the props, so they can be checked out. I'm currently using the ALCOR lander, and picking prop categories based on what's in it. but there will still be a lot of space props even after that. I figure some of your aircraft IVAs will be helpful for getting through the Avionics pack.

Actually, if you want to take a look at some of the avionics stuff, I can help you get started with it. I think a lot of those might be easier to convert, or at least they won't have so many variants (ASET_Props/Misc/SmallLabelPlate had 62 props in it...). Although we should move the discussion to 277, or PM in the KSP forum, so this issue can stay focused on AA stuff.

sovetskysoyuz commented 1 year ago

I am working on this on a personal fork but haven't managed to construction the AA-MAS interface in a way that doesn't create a hard dependency on AA. I have working props to control the Cruise mode of AA.

MOARdV commented 1 year ago

If you take a look at the various interface modules, you'll see examples of how MAS interfaces with other mods (such as MASIMechJeb.cs for MechJeb, or MASIKerbalEngineer.cs for Kerbal Engineer. It's not difficult to do, but it is tedious getting it set up, and it requires the other mod to have a sufficient public interface to control what you want. I'm pretty sure AA has it, since I recall doing it for RPM years ago.

sovetskysoyuz commented 1 year ago

@MOARdV I think I've got it figured out after using the existing mod interfaces as an example. It did require a bridge .dll with a hard dependency because some of the important parameters in AtmosphereAutopilot are held in mutable structs, and from what I understand those don't play nicely with the reflection approach.

The main remaining issue is that, if an AtmosphereAutopilot GUI window that contains the Speed Control panel is open, the value displayed in the speed target field will override a value entered via the MAS IVA. Fixing this will require a patch to AtmosphereAvionics as the field in question has no public interface. There is no issue so long as the AA GUI and MAS IVA controls are not both used at the same time.

JonnyOThan commented 1 year ago

@sovetskysoyuz have you considered making a new dll? You can have a hard dependency on AA if you use the kspassemblydependencyattribute. This is far less tedious and more performant than reflection.

you can also use krafs publicizer to get access to private fields. Again more performant and less tedious.