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

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

7.8k Downloads

SimulateAerodynamicForceAt does not match real forces

BenChung opened this issue ยท 1 comments

commented

I've been trying to use SimualteAerodynamicForceAt, but its results seem to not match the observed forces. Here's a small example program to reproduce:

import krpc
import time
from numpy import linalg as LA

conn = krpc.connect()
vessel = conn.space_center.active_vessel
orbit = vessel.orbit
body = orbit.body
flight = vessel.flight()
simf = conn.add_stream(flight.simulate_aerodynamic_force_at, body, (0.0,0.0,0.0), (0.0,0.0,0.0))
rlf = conn.add_stream(getattr, flight, 'aerodynamic_force')

for i in range(1,100):
	print(LA.norm(simf())/LA.norm(rlf()))
	time.sleep(0.1)

While flying in the atmosphere, the program should produce 100 numbers that are approximately 1, since simf and rlf should be close. However, in practice, the following is generated (using stock, for example, and with one particular flight):

1554.0039554907517
1435.472604806441
1329.7652398232767
1213.2532054561232
1110.4037605124731
830.88258644209
632.6100156463447
482.0579114645459
393.5343486488601
342.45461101454947
314.9540597321577
328.2613660485298
339.11384711892987
336.96026157818574
319.1188626441916
280.12691691690463
238.17019226254743
200.37383833898457
169.4628823400775
144.74779783833387
123.83657233026487
105.46714422713299
88.88183373900789
73.12418028203454
58.27595262770394
43.82456774253942
30.70987726964664
19.680286067974397
11.171179998238577
6.280767252718115
6.441526362287639
11.739954529255485
20.605832332453243
31.584495209548287
43.60087236935531
54.020941554593314
61.53501416515854
64.2485022226316
60.75427063042319
49.148352029662774
42.950475669671526
41.454608617498195
42.707795113850544
47.75555903579524
59.27430791170954
63.83235500835512
56.430882592910216
40.97878915498093
23.95047609471901
10.462682218055013
4.123902656208831
12.057974457695279
37.73514299961489
115.3518971533685
1074.4264792404676
108.33848526038858
47.321969780684185
33.300655625512455
34.17935031060259
44.20535731926796
48.333513770235314
80.13663184789736
100.95519521063603
91.21469526170246
...

The same behavior is seen for both stock and FAR, though FAR's numbers are much smaller, as seen in the following:

0.002690312426378069
0.002166359070625888
0.00170477970616131
0.0013293303984720094
0.0010006224080575438
0.0007124896521427768
0.0004759171571844674
0.0002607491949556492
0.00015215538347085954
0.00012318354186972473
0.00015403040020650868
0.00022505389145583983
0.0003325751193784032
0.0005453699386142647
0.0007838874421031075
0.001511323773699685
0.002645728627235679
0.004411392452838271
0.006668212042904513
0.00896313089218942
0.010130051726878569
0.009669830436420978
0.008275728575952091
0.00643210222362261
0.0051950374006720515
0.004347277747416342
0.003228134449456129
0.0022440925969104165
0.001551473179335489
0.0010955790695267005
....

This appears to indicate that SimulateAerodynamicForcesAt is not modelling the real aerodynamic force. The ratio between the real and simulated forces is highly inconsistent, so it seems unlikely to be a units problem.

commented

Is this fixed for stock ksp now? or is there some correct snippet? I still get wrong readings with SimualteAerodynamicForceAt @BenChung