kRPC: Control the game using C#, C++, Java, Lua, Python...

kRPC: Control the game using C#, C++, Java, Lua, Python...

7.8k Downloads

body mass and gravitational parameter return very wrong values

Spielopoly opened this issue ยท 4 comments

commented

What happened?

The values returned by vessel.orbit.body.mass and vessel.orbit.body.gravitational_parameter are very wrong by orders of magnitude and sometimes even negative.

How can someone else reproduce it?

Minimal python script to reproduce error:

import krpc

conn = krpc.connect(name='DEBUG')
vessel = conn.space_center.active_vessel

print(f"Body: {vessel.orbit.body.name}")
print(f"MU: {vessel.orbit.body.gravitational_parameter}")
print(f"Mass: {vessel.orbit.body.mass}")

If tested with a rocket somewhere (tested on launchpad, kerbin suborbital flight and on the mun), it gives this output:
Body: Kerbin
MU: 2.646977707734199e-22
Mass: -2.1207643280396482e-11

Body: Mun
MU: 4.3791301452123746e-18
Mass: -3.1153610247081076e-10

The values for a body seem constant even across different save files and game restarts.

What is your environment?

KSP: v1.12.5
KRPC: v0.5.4

No other mods installed

Anything else we need to know?

No response

commented

Thanks for the bug report. I'll take a look.

commented

I also tried it with a completely fresh install. This is what I get in a fresh install on the launchpad:

for name, body in conn.space_center.bodies.items():
    print(f"{name}: Gravitational Parameter: {body.gravitational_parameter}, Mass: {body.mass}")

Sun: Gravitational Parameter: 3.6210488913120944e+33, Mass: 1734299222016.0
Kerbin: Gravitational Parameter: 2.646977707734199e-22, Mass: -2.1207643280396482e-11
Mun: Gravitational Parameter: 4.3791301452123746e-18, Mass: -3.1153610247081076e-10
Minmus: Gravitational Parameter: 2.3910398689152156e-25, Mass: 32612.3828125
Moho: Gravitational Parameter: 2.8436708263024077e+34, Mass: -1.2389542032801886e-36
Eve: Gravitational Parameter: 3748363520.0, Mass: -2.5854540612279506e-28
Duna: Gravitational Parameter: 4.298321953475247e+26, Mass: 2.8144112578235924e+26
Ike: Gravitational Parameter: 31305.732421875, Mass: -2.3088527414277284e-14
Jool: Gravitational Parameter: -13732272930816.0, Mass: 4.900372472002301e+19
Laythe: Gravitational Parameter: 2.735481148855037e-33, Mass: -2.739273669788982e-30
Vall: Gravitational Parameter: 2.0131526980549097e-05, Mass: 0.007946106605231762
Bop: Gravitational Parameter: -4.072032517375394e+19, Mass: -3.656376165267931e+18
Tylo: Gravitational Parameter: -6.010578853160109e-38, Mass: -1.2180511583672539e-29
Gilly: Gravitational Parameter: 5.207277267664286e+31, Mass: -0.011455168016254902
Pol: Gravitational Parameter: 3.6893488147419103e+19, Mass: 3.075769979249885e+18
Dres: Gravitational Parameter: 1.1858461261560205e-20, Mass: -1358853504.0
Eeloo: Gravitational Parameter: -9.238590600715586e+26, Mass: 1.3494230377993329e-27

commented

I got this when I updated krpc server but forgot to update krpc C++ client. After rebuilding with the new client, all is good.

commented

Thanks that fixed it! I didn't notice that CKAN made an update to krpc (stupid me just selecting all available updates...) and forgot that I have to update the client side separately. Also my "clean install" previously only referred to KSP and krpc server...