MechJeb2

MechJeb2

4M Downloads

Docking AP cycling between states

blizzy78 opened this issue ยท 1 comments

commented

In my DockingTutorial plugin, I'm using the current dev branch code (as of 2014-03-11), and I've noticed something about the docking AP. Specifically, it cycles between these three states (starting on the wrong side of the target port):

  • Backing up to gain Z distance between the target and the docker.
  • Moving away from the docking axis to gain lateral distance.
  • Backup up to get to the correct side of the target.

So far so good. The problem now is that the last step - moving to the correct side of the target - actually decreases the lateral distance from the target (at least in my case.) This in turn has the effect that the cycle begins anew: It registers that it is too close laterally, so it first backs up, then backs up laterally, then tries to get to the correct side again. And so on and on.

Eventually it slowly drifts away laterally so much that it does not get too close, and it makes it to the correct side, completing the docking maneuver.

In the code, this seems to be quite simple to fix:

Instead of moving only safeDistance away from the docking axis, it should move away a little further. This way the move to the correct side of the target can be allowed to decrease the lateral distance, but not so much that it should matter.

I've made the following change here that works really well. Change this line

from:

else if (-zSep > safeDistance && lateralSep.magnitude <= safeDistance)

to:

else if (-zSep > safeDistance && lateralSep.magnitude <= safeDistance * 1.1)

So I simply increased the safe lateral distance to 1.1x the original safe distance, allowing for some leeway.

commented

One of the prototype had a similar change but it seems I lost it later. Thanks :)