MechJeb2

MechJeb2

4M Downloads

corrective steering makes rockets wobble a lot more than previously

xchgrbprsp opened this issue ยท 10 comments

commented

Almost all of my rockets start to wobble violently (mostly yaw and roll) upon reaching an altitude of roughly 30 km or a speed of roughly 1000 m/s. It tends to get worse and worse and may end up swinging left and right for more than 60 degrees. Turning off corrective steering fixes the issue instantly. This happens every time with dev build 653 but not at all with previous releases like 2.5.8. Previously only space planes or rockets with SSME tend to do this but now everything seems to behave this way.

commented

believe you can find old issues where sarbian tells people to just turn off corrective steering.

commented

"just turn off corrective steering" is a workaround, not a fix.
Workarounds are like painkillers. They treat the effects, but not the root cause.

commented

i read that as sarbian implying that it was a deprecated feature and would not be getting fixed.

commented

It's a fantastic feature when it works and I don't think it should ever be deprecated. With it turned on, I don't need to worry about adjusting the turn shape for every rocket. I just set the turn shape to 40% and watch. It's going to fix the course by itself no matter if I'm launching a high TWR rocket or a low TWR one and the trajectory will look almost perfect each time. Even with this feature semi broken right now, I still use it a lot and only turn it off when I absolutely have to before the wobbling gets too excessive.

commented

Just did some tests and I think the problem lies within the gain value. First of all the constant gain "Kp" of 5 is probably too high for most engines, especially the SSME. Secondly the "difficulty" scale doesn't work very well. It is the main contributor to the wobbling I believe. It increases as the speed increases, which is logical. But it has a max value of 5, which is also too high. So as the speed increases the combined gain get as high as 25, which nobody would ever need. (The correction angle is later clamped to 10 deg at most. While this somewhat prevents it from flipping out of control all of a sudden, it doesn't stop the wobbling.)

commented

I rewrote part of the code as such and now it seems to be a lot more stable even with SSMEs.

const double Kp = 0.6;
double difficulty = vesselState.surfaceVelocity.magnitude * 0.02
	/ vesselState.ThrustAccel(core.thrust.targetThrottle);
if (difficulty < 0.1) difficulty = 0.1;
if (difficulty > 1) difficulty = 1;
Vector3d steerOffset = Kp * difficulty * velocityError;
commented

FWIW some testing that I did with an algorithm wrapped around repetitive launches found that pitching up significantly killed DV performance, and you were much better off raising your initial launch apoapsis up to 65k or so rather than pitching up at 45k to compensate for low-TWR -- steering losses really started to eat up DV.

Anyway you can difficulty = MuUtils.Clamp(difficulty, 0.1, 1.0) to clean that up a bit and try submitting a PR.

commented

@lamont-granquist Sorry to jump in, but how did that test suite of yours work? Was it able to programatically start KSP and run a save file of a launch at T+1 seconds? Could you, in theory, run a few dozen instances of this on an AWS compute cluster?

commented

I think part of the problem is that 1.2 changed something about what PID settings you need for MJ to be not drunken in the first place. Atleast it was for me.
I've spent a looot of time of finding rather all-round settings for the PIDs and 1.2 broken them completely and only recently did I find new good values but these were vastly different from the old ones.

So by default MJ sets the PIDs as follows: 0.1 - 0.5 for "Tf", 0.5 for "/ Tf", kp 3 and ki 6.
Now these values are I think actually my ideal all-rounds from 1.0 (1.1?) times, but for 1.2 I found that
0.25 - 0.75 Tf
2.0 / Tf
kp 4 and ki 12
work much better for a similar rocket I've used in the past too for adjusting the values.

Atleast for my heavy test rocket is launching no longer a problem even with corrective on and no 'modded' MJ.

commented

I pushed @megastupidmonkey code with a field to edit the gain. I ll close this and we can open new bugs for the PID if needed.