Closed Patrykz94 closed 7 years ago
~Yep, what PEGAS is not good at is doing many things at once. If you separate, wait a few seconds, separate something else, wait again, switch phases etc - everything should work well. But try to separate and switch guidance at the same time and it's hard to predict what will happen.~ I will look into this.
I thought about it a bit deeper. The very idea of upfgConvergenceDelay
is to give the algorithm some time to spin up before the actual moment we switch to it (so the user can be sure that if they requested UPFG to activate at a given time (upfgActivation
), it will engage at that time: not just theoretically, but actually take the wheel). The assumption that turns out to be untrue is that the whole information about the vehicle will be available. We can of course recalculate later, but the whole purpose of the delay is defeated, because the initial guidance is not right (as it was calculated with the assumption that we had more fuel than we actually have).
Having said that, I still came up with a little hack to force recalculation of the stage mass - check out separation-recalc
branch, the latest commit. It's just an ugly proof of concept, and I haven't tested it myself. Could I ask you to test it and see if it solves the issue? If it's the way to go, I will wrap it in a nicer form and properly document it.
I did some testing and the issue is still there (and another one is introduced).
I added a few lines of debug code that just print the fuel mass before and after recalculation. Looks like fuel is recalculated correctly but UPFG still seems to use the old mass.
And the other issue that happens when using this new code is that right after the upper stage separates, it flips the opposite direction to where it is supposed to be going. If I turn SAS on, manually turn it around and turn SAS off again, it locks into the right direction again.
Here is a video example of separating the boosters using sequence
at 146 seconds, and activating UPFG 6 seconds later. Here, jettison
is set to FALSE
.
And here is a video of activating UPFG at separation with the masses printed at the bottom. Settings are the same except jettison
is TRUE
, waitBeforeJettison
is 1 second, no staging entry in sequence and upfgActivation
is 146. Also had to move fairing jettisoning by 20 seconds so it doesn't interfere with anything.
Thank you for this thorough feedback. The problem is more tricky than I thought. Mass recalculation is good, and UPFG knows what it's doing as well (it does know the correct mass) - what doesn't know about the update is staging event. It has been set (stageEventHandler::setNextEvent
) basing on the old maxT
. I simply forgot about adjusting this.
Let's continue this conversation under #20.
This happens when you try to combine a upfg activation and separation of side boosters for a sustainer stage.
Since the mass calculations for sustainer stages are done around 5 seconds before the specified upfg actiavtion time (
upfgConvergenceDelay
), if you try to combine side boosters separation and activating the sustainer stage, pegas will include the mass of the still attached side boosters and treat it as extra fuel mass. This messes up the deltaV and burn duration of that stage.Detecting those situations is quite easy, you can check if
ignition
isFALSE
andjettison
isTRUE
. As for fixing this, maybe re-calculate the masses again after separation?