Repository navigation
Conversation
With a minimum coast of zero, PSG can plan a coast of no length when burning straight through is better. Solution.WillCoast still counted it, so guidance's coast-during hold kept terminal guidance off for a coast that never came: every re-solve put the zero-length coast ahead again, and the stage burned until it was empty, far past the target orbit. WillCoast and CoastFollows now skip a coast shorter than a millionth of the trajectory. The burns either side of it are flown as one, with terminal guidance at the end of the second.
|
This should really get pruned in the SolutionBuilder. I thought I already did this, but there's already code there to prune out incredibly short burn segments. |
✅ Build Artifact 🚀MechJeb2-12262fd.zip (built from 0b8e2bc) |
|
nope AnalyzeStages() doesn't prune them out, it probably should, but the old Solution is required to warm start the optimizer on the next loop and keeping the phases in sync makes all that a bit more sane and realiable. |
|
Okay I still think what likely needs to happen is that AnalyzeStages() should mark the phase as "Skip" or "Prune" for coasts and burns that don't have enough time to be meaningful because the optimizer shrunk them. Then the Solution only needs to be responsible for skipping those phases, and it needs to 'know' a lot less about trajectory rules. |
|
This should hopefully be fixed by #2777 |
PSG can plan a coast of no length. When that coast is a coast-during, guidance then burns the stage until it's empty instead of stopping at the target orbit.
What happened
Seen in MechJeb2_UI Spike 106 (run
rework_during): Kerbal XI to 145 km with a coast during stage 2, flown on the PC. The ascent lofted early, and from the pad onward every solve gave the coast a length of 0 (bt: 0 <= 0.0000 <= 1.0). Burning straight through was the optimum, so that much is legitimate with a minimum coast of 0.Guidance then never left BURNING.
Solution.WillCoastcounts any coast phase ahead, including one of no length. The coast-during hold inHandleTerminalkeeps terminal guidance off whileWillCoastis true, and every re-solve put the zero-length coast ahead again. Stage 2 burned to empty and guidance went BURNING → FINISHED at −1167 × 10,947 km.The fix
WillCoastandCoastFollowsskip a coast shorter than a millionth of the trajectory (Solution.FlownCoast). The burns either side of it are flown as one:TgoForKSPStagealready sums both burns;TerminalDonedoesn't start a coast after the shutdown.Coast(t)never landed in a zero-length phase (IndexForskips it), so it's unchanged.Tests
SolutionTests.ZeroLengthCoastIsNoCoast: a burn, a coast of no length and a burn in one KSP stage.Coast,WillCoastandCoastFollowsare false throughout, and the stage's burn time left counts both burns. It fails without the fix ("Expected false, but was true").Not flown: a zero-length coast-during can't be set up on demand in game.