MuMech / MechJeb2

MechJeb2 - KSP mod
Other
989 stars 251 forks source link

Rover Speed Control too jumpy #524

Open Schnobs opened 9 years ago

Schnobs commented 9 years ago

Mechjeb's rover controls usually make my rovers move in fits and starts. After having written my own cruise control in kOS, I suspect that Mechjeb is too smart for it's own good.

My solution only controls the wheelthrottle (putting the lever in reverse to slow down) and I found that this is wholly sufficient, even when going down the steepest slope: as long as the wheels have traction, speed control by throttle will work -- and if they don't, brakes won't do you any good either.

The other speciality is a forced smoothness: kOS' wheelthrottle can be set from -1 to 1, and I only allow a maximum change of 0.05 per 0.2 seconds; that is, it will take the controller two seconds to go from zero to full throttle.

The whole thing is incredibly simple, literally my first PID controller, and yet it's vastly superior to Mechjebs' speed control in every way. It won't tip or flip my rovers, for all it's simplicity it holds the set speed very well, and as a side benefit it consumes less power.

Here it is, in it's entirety. I kindly suggest that you try this approach for mechjeb's controller:

// v = surface velocity
// tv = target velocity
// do this every 0.2 seconds
 set dv to (v - oldv).
 set ddv to v + dv*3.
 if ddv > tv set t to t + min(-0.05,(tv-ddv)*0.1).
 if ddv < tv set t to t + max(0.05,(tv-ddv)*0.1).
 set t to round(max(-1,min(1,t)),2).
 set oldv to v.
BloodyRain2k commented 9 years ago

That's already implemented, Waypoint Window -> Settings -> Rover Settings -> Limit Acceleration. It's off by default because I had at most a need for it when I had unreasonable designs that were either horribly balanced and or just overpowered with too much grip, for all other cases did it just kill reaction time of the speed PID.

I'll throw Sarbian a new pull though with a slightly faster reacting limiter and hopefully better PID defaults.

Schnobs commented 9 years ago

MJ regularly exceeds the speed limit by a fair bit. It also often goes much slower than desired, but that, of course, isn't as problematic. Both situations can go on for several seconds until MJ all of a sudden applies a huge correction. "Limit Acceleration" helps with the suddenness, but may also prevent MJ from doing the right thing while there is still time. Chose your poison.

When I'm in for a long ride (and when else would one use the autopilot?) I like to set a safe speed, crank up phyiscs warp, and go do something else while MJ does the work. I can use kOS for speed and MJ for waypoints if I push the buttons in just the right order. Using my own speed controller, I can go twice as fast as using the mechjeb one.

Which is the reason why I opened this issue: if my simple controller outperforms MJ, something is very very wrong. If it isn't the forced gentleness, then it maybe it's alertness? MJ often behaves as if it was asleep at the wheel.