Maneuver Node Editor does irreversible changes
mmithril opened this issue · 12 comments
After upgrade to 1.4, Maneuver Node Editor does irreversible changes to the trajectory. Both CKAN version and latest DEV
Steps to reproduce:
- Launch a vehicle with MechJeb on board
- Use Advanced Transfer... tool to create injection to Moho
- Focus on Moho and display periapsis details
- Open Maneuver Node Editor and click Update several times
- Adjust Prograde by +0.01 & -0.01
- Add maneuver node to periapsis
Expected:
- (4) Periapsis height does not change with each click to Update
- (5) Periapsis height changes there and back to the same value when adjusted
- (6) Trajectory is not changed, new node is added,
Actual:
- (4) Periapsis height changes with each click to Update
- (5) Periapsis height rises twice
- (6) Trajectory completely disappears from SOI of Moho
Which logs should I provide?
- KSP.log is empty
- Link provided in forum gives The page you requested does not exist to me
I re-read the code and I don't see how the stock code does not do the same thing.... I ll try to investigate it more in the coming days
I've seen this in at least 1.3.1 as well, i don't think its 1.4.x specific, dunno how long it has been around.
I thought it might have been that somehow the dV vector in the maneuver node was being converted to world coordinates, been edited for a few seconds while the "world rotated" and then being written back but I couldn't see where a bug like that might be happening. When I looked at the code the math seemed to be in the maneuver node coordinate basis which should be non-rotating from frame-to-frame, so IDK.
I wonder if it has something to do with the code changes to be able to merge/add two maneuver nodes together?
Could you test with Precise Node to see if it has the same problem ?
If not then it may be some weird interaction with the EditableDouble
The only mods that do things differently is Better_Maneuvering and I do not understand why he does it...
https://github.com/DMagic1/KSP_Better_Maneuvering/blob/master/Source/BetterManeuvering/ManeuverController.cs#L1055
So... all the mods exhibits the same problem. It seems there is an instability somewhere in the stock intercept code and I can't do much about it.
At best I could make sure the update button do nothing when the value did not change...
Other ideas ?
I'm pretty certain that the problem is more trivially reproducible:
- have a transfer to another planet
- focus on the planet
- open the maneuver node editor
- save the node with no changes
- watch the orbit bounce around
And MJ is saving the node with the same Vector3d and UT values that it read off the node.
So we don't round-trip through the Burn vector and keep everything in the frenet frame, so the errors are likely just from the loss of precision packing into and out of the Quaternion.
This is likely just due to loss of precision due to the KSP ManeuverNode object using a Quaternion instead of a QuaternionD.
For the editor, if we try to stay in the Frenet frame and not round-trip through the Burn vector frame (which rotates with the inverse rotation of the universe) then we might at least be able to make the node editor idempotent.