Nivekk / KOS

Fully programmable autopilot mod for KSP.
Other
80 stars 30 forks source link

lock steering overreacts when loading from mission center #62

Open clemensm opened 10 years ago

clemensm commented 10 years ago

After putting a small probe into orbit (core + fuel tank + engine + kos + solar panels), then quit to space center and finally go back to the probe via the mission center, the steering completely overreacts when being locked to some direction.

Interestingly this does not happen if you lock the steering directly after the payload separation, in this case the steering finds the desired direction quickly and accurately.

Nivekk commented 10 years ago

This is something I tried to fix in 0.6 by putting the part of mechjeb back in that accounts for slowing down when approaching the target. It did fix the problem for orbital craft but then caused a catastrophic understeering during launches.

clemensm commented 10 years ago

Ok, so I took a closer look at the code and the way this is implemented in MechJeb for Comparison. After that I first thought it might be a problem with the missing PID Controller in the kOS Code, but after some more testing I believe it is actually some kind of bug in KSP itself.

The reason to believe so is that I put a small probe into orbit using Hyperedit and then directly locked the steering. This works fine just as you would expect it too, so currently I'm assuming that the code in kOS works as intended. However I believe that after loading from the Mission Center KSP for some reason reports other values for ship mass etc. I'd like to test that out next.

Simple question here, as I have not yet done any KSP plugin development, is it possible to run the dll in a debugger somehow? Or do I need to make print debugging?

clemensm commented 10 years ago

Ok, so I did a lot of debugging and testing of the current situation. What I've found is that it is not actually the reported values (MoI, rotation etc) that are behaving differently, but the FlightControlState. Once you are up in orbit and reload the game, the input for some reason has different results.

You can even try that out manually if you like: Put a small probe in orbit using HyperEdit, then immediately save before doing anything else. Usually your craft should then be oriented so that yawing follow exactly one of the lines on the navball, e.g. the 90° line from the north pole to the south pole. If you then reload the game and try to do the same maneuver, it will actually divert from this line and move on a slightly different path, but not directly across the line.

So I'm not sure if this is a bug in KSP or not, but anyway I think it's the reason why steering is not working after reload.

However given that MechJeb is in fact working all the time, I'm going to have another look at the code and try to find out where the differences are and add them to kOS if at all possible.