MechJeb2

MechJeb2

4M Downloads

Staging Doesn't Start New Engine Dev 740

Opened this issue · 18 comments

commented

When staging, Mechjeb correctly activates decoupler, but next stage engine never starts. Tested with fresh install of unmodded KSP. [email protected]

commented
commented

Built simple rocket with multiple stages. New engine will start if I do manual staging. This may have originated with 728, but my ability to interpret code is SUPER minimal.

commented

This is on the dev build. The release build works fine. I just did a FRESH INSTALL of KSP 1.31 with no mod except Mechjeb dev 742. Everything stock. Engine start and launch clamps release fine. Then when the lower stage is complete, the decoupler works fine, but the upper stage engine never autostarts. As I noted, they started doing stuff with the staging code on dev 728. I reverted to dev 727 and all is well.

commented

Sorry - I apparently was not on a dev build... I can reproduce the bug now.

It's caused by f956290 (MechJeb2/MechJebModuleStagingController.cs, line 82). After staging the decoupler CurrentStage and StageCount are equal, hence it returns from the function. When I change the line back to previous version, the staging works properly.

I am reluctant to revert it myself since I don't know why the call to vessel.LiftedOff() was removed. I'll put a note on the diff, so the author can chime in.

commented

Thank-you SO MUCH. I had seen other people note the problem and although it was easy to work around with manual staging it puzzled me quite a bit. I cannot tell you how much time I spent making sure that it was not something I was doing or my install.

commented

Is this on a dev build or release build? I'm on a dev build here and the staging seems to be fine.

commented

Issue still present on DEV build 743

commented

Sorry guys. That was part of PR #920, which among other things added the ability for autostaging to release launch clamps (very nice for RO where engines take time to ramp up and you want to wait till the rocket will actually lift off), hence that logic needed to be relaxed to allow staging even if the vessel is on the ground.

I'm not totally surprised by this bug, since we were uncertain at the time about the change to that logic that you identified. But we still need to do that check -- has the player staged at least once? -- correctly, or else the feature breaks.

@tekinozbek if you can figure that out, that should fix this issue.

cc @sarbian @lamont-granquist who reviewed the code originally and might have ideas.

commented

What is "the MET bug" mentioned in #920?

We could use FlightLogger.LiftOff to check stage status, or if that API has the same behavior as vessel.LiftedOff(), then we could traverse the FlightLogger.eventLog to check if we have staged at any point during the flight.

commented

The "MET bug" is when mission time (aka MET) starts ticking due to physics wobble when the scene loads (very common KSP bug that would also screw up some logic that used to be in the PEG code as well, even without autostaging). When autostaging was enabled that result in some very lolwut autostaging of everything so MechJeb would burn through all your stages right on the launch pad.

You can replicate it fairly easily by using the sphere hucking thing in the debug menu. You have to tone it down a lot so it doesn't cause any damage, but just plonk the vehicle on the launch pad and make it wiggle enough that MET starts ticking. Then have auto-staging enabled and try to launch. I have not tried that recently (and haven't been playing KSP for the past couple of week, been taking a break).

commented

(also i got nothing tonight on this bug -- bit too much insomnia last night)

commented

Gotcha, I'll take a look at this tonight.

commented

Ah also note that the original comment in that bug mentions "Also fixes unreported bug in autostaging where bouncing vehicle will trigger staging unexpectedly" which is exactly what i meant by "the MET bug" => vehicle bouncing around on the pad triggers MET to start running.

commented

And I'm reasonably certain FlightLogger.LiftOff has the same behavior as vessel.LiftedOff() from when I looked into that when I was wrangling the PEG code.

commented

Here's what I wound up doing with the PEG code:

074b3da

commented

FlightLogger.LiftOff seems to have the same behavior, yes.

Using the sphere hucking thing, I was able to get the MET to start without launching and see that FlightLogger.eventLog doesn't contain a "Liftoff!" event until the first stage is engaged.

commented

What's weird though is that I've been launching rockets with this patch, just fine. So I think I'm missing something in the conditions to exercise this bug. I'm playing RO/RSS on 1.2.2 still though.

commented

Build a rocket such that you have engines, decoupler, engines, in successive stages. Once the first stage engine fuel is depleted, auto stage will decouple but won't fire the third stage engines (i.e. auto stage will trigger only once instead of twice).