In [4]:
%run -i '../Common.ipynb'
import krpc

In [5]:
conn = krpc.connect(name='laptop2', address='192.168.1.2')

ksc = conn.space_center
vessel = ksc.active_vessel
obt = vessel.orbit
ap = vessel.auto_pilot
con = vessel.control

In [27]:
def torque(vessel):
    surfs = vessel.parts.with_module('ModuleControlSurface')
    pitch,yaw,roll = 0,0,0
    for surf in surfs:
        modl = [x.fields for x in surf.modules if x.name == 'ModuleControlSurface'][0]
        print(surf.name)
        p = surf.position(vessel.reference_frame)
        d = surf.direction(vessel.reference_frame)
        r = surf.rotation(vessel.reference_frame)
        print('   ',p)
        print('   ',d)
        print('   ',r)
        if modl['Pitch']:
            pass
        if modl['Yaw']:
            pass
        if modl['Roll']:
            pass
torque(vessel)


R8winglet
    (0.9752424109102769, 0.6966314543805067, 0.11266144818241366)
    (-0.2254250208276105, 0.968436890965344, -0.1063651034220236)
    (0.25771580607272915, -0.7184982480622373, -0.3525488889668191, -0.5413428856211167)
R8winglet
    (-0.9749975012621168, 0.6966387576191593, 0.11266119615164502)
    (0.22543030614646375, 0.9684370137988104, -0.10635471814662928)
    (-0.408982289059854, 0.2988515789293464, -0.15216789167647693, -0.8486849990933978)
R8winglet
    (-4.141693843059577, -4.041600546602401, -0.6506278434170094)
    (-0.0016266915925681642, 0.999996314261699, 0.0021530903157734316)
    (0.45048228806278207, -0.8518395818412395, -0.15626357289122222, 0.21683361115753141)
elevon3
    (-1.4805175677897886, -3.9437237499323277, 0.18602895244510553)
    (-0.0016159697492387666, 0.9999965843942402, 0.0021494817017777557)
    (0.4289893370305759, -0.4488881556766335, 0.20811347689964654, 0.755748978901402)
elevon2
    (-3.2949551884840593, -3.9463147439470516, 0.03021437370988833)
    (-0.0016146124709196072, 0.9999964339035705, 0.0021543669561374656)
    (0.42899031376918495, -0.44888276933761423, 0.20811414319463345, 0.7557513237437934)
R8winglet
    (4.141187051361435, -4.04192532044547, -0.6545511761881959)
    (0.0016949663513351806, 0.9999964908705712, 0.002034416905614289)
    (0.4620270522653802, -0.8293327947262126, -0.11758627776821251, 0.2913959848850105)
elevon3
    (1.4808402830938192, -3.9437693203115183, 0.18477861166988108)
    (0.0016730268619717607, 0.9999965323688406, 0.002023343891929985)
    (0.24348776749286652, -0.7924019559404554, -0.40989173861535144, -0.38052803351636777)
elevon2
    (3.2951382662440905, -3.946488087242821, 0.027154174800872344)
    (0.0016770545553067631, 0.999996472953745, 0.0020344511640486562)
    (0.24348738533465464, -0.7924030243847306, -0.4098922987065023, -0.3805255171224551)

In [28]:
surf = vessel.parts.with_module('ModuleControlSurface')[0]

In [32]:
dir(surf.modules[0])


Out[32]:
['__class__',
 '__delattr__',
 '__dict__',
 '__dir__',
 '__doc__',
 '__eq__',
 '__format__',
 '__ge__',
 '__getattribute__',
 '__gt__',
 '__hash__',
 '__init__',
 '__le__',
 '__lt__',
 '__module__',
 '__ne__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__weakref__',
 '_add_method',
 '_add_property',
 '_add_static_method',
 '_class_name',
 '_client',
 '_object_id',
 '_service_name',
 'actions',
 'events',
 'fields',
 'get_field',
 'has_action',
 'has_event',
 'has_field',
 'name',
 'part',
 'set_action',
 'trigger_event']

In [2]:
vrf = vessel.reference_frame
srfrf = vessel.surface_reference_frame
vobtrf = vessel.orbital_reference_frame
obtrf = obt.body.reference_frame
obtorf = obt.body.orbital_reference_frame
obtnrrf = obt.body.non_rotating_reference_frame

flight = lambda rf: vessel.flight(rf)

In [3]:
compare(ksc)

In [4]:
t = ksc.ut
o = KeplerOrbit(obt)
print(o)

f = flight(obtorf)
print(f.longitude, f.speed)

f = flight(obtnrrf)
print(f.longitude, f.speed)

f = flight(obtrf)
print(f.longitude, f.speed)


e   = 0.0866 
α   = 741560 
i   = 0.1649
Ω   = 4.1811 
ω   = 3.2452
M0  = 1.5912
E   = 1.6773 
t0  = 803022
μ   = 3.532e+12 
body_equatorial_radius = 600000
body_rotational_speed = 0.0002909

n   = 0.0029
P   = 2135.0779
ϖ   = 7.4263
ν   = 1.3785
true_longitude = 8.8049
ϕ   = 0.0834
γ   = 1.4874
12.983598941572325 2162.274627170959
12.989604285901478 2162.263775277369
12.989604285901478 1948.4163507844235