Incorrect Relative Velocity value
Keniamin opened this issue ยท 6 comments
Thanks I'll take a look, the code that calculates all that changed significantly, not surprised a few are bugged.
OK so I wasn't sure what the original intention of 'velocity' vs ' speed' was in this case. The original code was
RelativeVelocity = FlightGlobals.ship_tgtSpeed;
RelativeSpeed = FlightGlobals.ship_obtSpeed - targetOrbit.orbitalSpeed;
You'd think those would be the same but I guess not.
The code in my version is
RelativeSpeed = originOrbit.orbitalSpeed - targetOrbit.orbitalSpeed;
RelativeVelocity = RelativeSpeed;
So both my values should be the same as the old speed, and the old velocity is missing. Still dunno what that's actually calculating. What was your orbital speed in that screenshot? any idea?
Any suggestions for renaming these readouts to be clearer as to what they are? I personally never used them.
Well, in-game description gives following help strings for these readouts.
RelativeVelocity: Shows the relative velocity between your vessel and the target object.
RelativeSpeed: Shows the difference in orbital speed between your vessel and the target object.
RelativeVelocity indeed was showed the same value as stock velocity gauge does in the "target" mode. But stock value is always formatted as m/s with 1 digit after dot, so when you see 0.0 m/s it may be both 0.049 and 0.001. KER readouts switch to mm/s at low values, so it's precision is much better. I used this readout when I needed to park vessels in the same orbit for a while without docking. Better precision allowed me to achive much more stable relative position (~50 meters difference per orbit period, compare with ~400 meters with stock gauges).
What about RelativeSpeed, I suppose it must give the same value on the orbits with equal inclination, but may be different in other cases. I mean for example two exact circle orbits with the same height. Orbital speed will be the same (RelativeSpeed = 0), but if inclination is different you would have RelativeVelocity != 0 wherever your vessels are. Although, I didn't use this readout too and cannot imagine proper use case for it.
I agree the readout should show the stock target speed, the mm/s precision does sound useful. I'm looking at the code and still cannot figure out where the -111 m/s in your screenshot is coming from. You obviously have the same inclination as your target.
I will put rel. velocity back like it was (although it needs to be in a tracking station compatible manner) and investigate what the heck that speed value is and try to make it meaningful.
See if this solves both your issues.
KerbalEngineer 11410test.zip
It seems like that weird value is some kind of timing issue. I parked 2 ships next to each other like you did and got the same large values, but after timewarping for a bit it... went away and read near 0 like it should... so maybe the value I was grabbing only updates once an orbit, or something?
In any case it's better now. I renamed Relative Speed to Relative Orbital Speed just for clarity. Rel Velocity is now magnitude(myV - theirV) and Rel Speed is magnitude(myV) - magnitude(thierV), which is what I think the intention was.