Noiredd / PEGAS

Powered Explicit Guidance Ascent System - a KSP & RO autopilot using the Space Shuttle guidance algorithm, UPFG
http://forum.kerbalspaceprogram.com/index.php?/topic/142213-pegas-powered-explicit-guidance-ascent-system-devlog
MIT License
114 stars 31 forks source link

TestFlight/TestLite support #31

Closed Patrykz94 closed 3 years ago

Patrykz94 commented 4 years ago

TestFlight and TestLite mods add in-flight engine failures like ignition failure (engine fails to start), loss of thrust (thrust is roughly halved so stage will burn for longer than planned), loss of performance (ISP is reduced and therefore thrust too), engine shutdown and engine explosion.

There are some cases where PEGAS could either complete the mission by automatically adjusting some parameters or trigger an abort if it knows it can't do anything.

Some examples:

This could be a separate module, kind of like comms that only works if TestFlight/TestLite mods are used. I'll play around with it to see what's possible.

Noiredd commented 4 years ago

Maybe PEGAS should support addons? I don't know if that is technically feasible using kOS but I'm thinking about a pretty convenient solution in which the user can just paste a file (like, pegas_testflight_addon.ks) somewhere in the scripts folder, and the system would automatically detect that and RUN the file, which would contain some standard mechanism, like a hook or something. I can imagine that would require either heavy monkey-patching on the addon-side, or implementing something like an API on PEGAS side. If that worked, we could start a library of PEGAS addons, under this repository or as a separate one.

Whether it's even possible to implement such addons without heavily modifying the core system, that is. I'm not even talking about the automatic loading at this point, but just about adding anything to PEGAS without changing its modules.

One direction that I wouldn't want to go would be adding different non-essential functionalities to the core version of PEGAS. The system is large and slow as it is, so a modular design would be way better. On the other hand though, it hasn't really been thought of as a modular thing. Lots to think about here :)

Patrykz94 commented 4 years ago

Yes, that actually sounds like a good idea. I was wondering if this could be made an optional feature as many people don't use TestFlight (to be fair, after 4 failed launches in a row in career mode I was questioning my decisions too).

The only thing is, in kOS you can only really run one script at once on a single CPU. So that would mean that PEGAS would need to call a function every iteration? Not sure if there's a better way to do it so yeah, a lot to think about.

For my current career I'm thinking about writing a script for manned launches that would sit on the capsule CPU and just keep checking the engines and flight path. If it sees anything too far off nominal it would set the capsule as the controllable part and trigger the abort action group but the issue with this solution is it required two CPUs so that wouldn't be very useful as a general solution.

Noiredd commented 4 years ago

in kOS you can only really run one script at once on a single CPU

Many systems have this limitation, e.g. microcontrollers. The typical solution in this case is to run an interrupt system. This could be emulated in kOS by periodically running a very lightweight function that only checks for some condition. If that condition is met, "interrupt" is raised, i.e. a dedicated handler is called which does the work (e.g. recalculating the vehicle params and reconverging guidance).

I'll put this issue on hold for now. Let's instead discuss the addons idea in a dedicated thread (#33). To be honest, I would rather spend 20 hours on implementing a more abstract system that could handle anything, rather than 5 hours on integrating one mod and suit one user.

Noiredd commented 3 years ago

Since I've implemented addons, @Patrykz94 you can feel free to implement this (if you wish) as an addon and submit this as a PR to the addon sharing repo - I'd accept as soon as it's ready :)

However, I decided this will not be a part of main PEGAS; therefore I'm closing this as a suggestion.