Hello All
During my so called "gamification" efforts I have run into a strange effect, which occurs, when I try to reposition objects with Lua script.
I have attached two files below: the scenario and the script, to describe the problem.
Normally the script after 9 seconds should attach the cargo which is visible initially, to the ship, which appears in the second 7. Then, after another 2 seconds of simulation time, the cargo is detached and should fall onto the ground.
Instead it is "teleported" somewhere in the vicinity.
It looks like Orbiter is taking into account the ship position from different frame than the script. The effect can be observed with or without any modules running and under the DX9 or standard DX (Orbiter2016 of course). The effect can be bypassed by running the script not from the line in scenario file, but manually, from the Lua console.
I wonder: am I doing something wrong with my script, or is this behavior a bug?
Scenario:
Script:
During my so called "gamification" efforts I have run into a strange effect, which occurs, when I try to reposition objects with Lua script.
I have attached two files below: the scenario and the script, to describe the problem.
Normally the script after 9 seconds should attach the cargo which is visible initially, to the ship, which appears in the second 7. Then, after another 2 seconds of simulation time, the cargo is detached and should fall onto the ground.
Instead it is "teleported" somewhere in the vicinity.
It looks like Orbiter is taking into account the ship position from different frame than the script. The effect can be observed with or without any modules running and under the DX9 or standard DX (Orbiter2016 of course). The effect can be bypassed by running the script not from the line in scenario file, but manually, from the Lua console.
I wonder: am I doing something wrong with my script, or is this behavior a bug?
Scenario:
Code:
BEGIN_DESC
END_DESC
BEGIN_ENVIRONMENT
System Sol
Date MJD 52086.1637776680
Script floater/background_test
Help CurrentState_img
END_ENVIRONMENT
BEGIN_FOCUS
Ship Zeus-5
END_FOCUS
BEGIN_CAMERA
TARGET Cera
MODE Extern
POS 8.513000 99.017724 -21.629157
TRACKMODE TargetRelative
FOV 50.00
END_CAMERA
BEGIN_HUD
TYPE Surface
END_HUD
BEGIN_MFD Left
TYPE Map
REF Mars
ZOOM 128
END_MFD
BEGIN_MFD Right
TYPE Launch
NAV 0
END_MFD
BEGIN_PANEL
END_PANEL
BEGIN_SHIPS
ISS:ProjectAlpha_ISS
STATUS Orbiting Earth
RPOS -2324945.833 -5588804.851 2958998.910
RVEL -6569.7301 3620.8117 1687.0005
AROT -167.228 -9.248 89.142
VROT -0.0419 0.0449 0.0237
AFCMODE 7
PRPLEVEL 0:1.000000
IDS 0:588 100 1:586 100 2:584 100 3:582 100 4:580 100
NAVFREQ 0 0
XPDR 466
END
Mir:Mir
STATUS Orbiting Earth
RPOS -5201772.380 -1010008.255 4043991.104
RVEL -4590.8801 -1060.9609 -6137.0081
AROT 163.895 -27.910 12.738
VROT 0.0067 -0.0907 -0.0348
AFCMODE 7
IDS 0:540 100 1:542 100 2:544 100
XPDR 482
END
Luna-OB1:Wheel
STATUS Orbiting Moon
RPOS 749108.645 2110024.287 1312.471
RVEL -1394.5452 495.0261 0.0934
AROT -0.030 0.012 35.919
VROT -0.0000 0.0000 10.0000
AFCMODE 7
IDS 0:560 100 1:564 100
XPDR 494
END
SH-03:ShuttleA
STATUS Landed Earth
BASE Habana:4
POS -82.3982414 23.0005396
HEADING 70.00
ALT 2.912
AROT 50.119 -65.937 19.478
AFCMODE 7
PRPLEVEL 0:1.000000 1:1.000000
NAVFREQ 0 0
XPDR 0
PODANGLE 0.0000 0.0000
DOCKSTATE 0 0.0000
GEAR 0 0.0000
PAYLOAD MASS 0.0 0
ATTREF 0 0 0
ADI_LAYOUT 0
END
PB-01:ShuttlePB
STATUS Landed Earth
BASE Habana:1
POS -82.4000000 22.9994604
HEADING 22.00
ALT 1.287
AROT 62.913 -18.678 7.875
AFCMODE 7
PRPLEVEL 0:1.000000
NAVFREQ 0 0
END
GL-02:DeltaGlider
STATUS Landed Mars
BASE Olympus:3
POS -135.4300000 12.7366196
HEADING 0.00
ALT 2.532
AROT 81.111 -8.915 -44.736
AFCMODE 7
PRPLEVEL 0:1.000000 1:1.000000
NAVFREQ 0 0 0 0
XPDR 0
HOVERHOLD 0 1 0.0000e+000 0.0000e+000
GEAR 1.0000 0.0000
AAP 0:0 0:0 0:0
END
SH-01:ShuttleA
STATUS Landed Moon
BASE Brighton Beach:1
POS -33.4375000 41.1184067
HEADING 0.00
ALT 3.027
AROT 64.274 33.319 48.978
AFCMODE 7
PRPLEVEL 0:1.000000 1:1.000000
NAVFREQ 0 0
XPDR 0
PODANGLE 0.0000 0.0000
DOCKSTATE 0 0.0000
GEAR 0 0.0000
PAYLOAD MASS 0.0 0
ATTREF 0 0 0
ADI_LAYOUT 0
END
XR2-01_Bay:XRPayloadBay
STATUS Orbiting Sun
RPOS -17118686473337200.000 -23386565924229444.000 -41869506182307512.000
RVEL -5711405305192.0850 -7802592686486.5488 -13969090995760.2680
AROT -31.448 47.710 157.457
VROT -17895.4775 -1243.8074 -519.2598
AFCMODE 7
END
Zeus-5:DeltagliderIV
STATUS Landed Mars
POS -110.9352260 29.0828980
HEADING 199.32
ALT 2.367
AROT -111.263 28.434 -159.552
RCSMODE 2
PRPLEVEL 0:0.537326 1:0.834993
IDS 0:45 100
NAVFREQ 50 0
XPDR 0
;-------------------------- Skin parameters must contain directory name of skin (without space)
MeshSkin mining
;-------------------------- Cargo payload must contain name of config file or "none".(see doc)
CargoPayload none
NOSECONE 0 0.00
GEAR 1 1.00
AllDoorsState 0 0.00 0 0.00 0 0.00 0 0.00 0 0.00 0 0.00 0 1 1.00
But1Cockpit 0 0 0 2 2 2 0 2 2 2 2 2 2 2 2 1 1 2 0 1 1 3
But2Cockpit 0 0 0 0 0 0 0 0 2 2 2 2 2 0 50 0 0 0 2 2 0 0
TransEffect 0
LifeBut1State 0 2 1 2 1 2 2 2 2 2 2 2 2 0 0
LevelBatt 100.0000
Emergency_power 10000.0000
VoltageStartBus 0.0000
VoltageGen1 96.2800
VoltageGen2 96.2800
VoltageGenBus 96.0000
O2tankALevel 94.4574
N2tankALevel 100.0000
O2tankBLevel 100.0000
N2tankBLevel 100.0000
CabinO2Level 21.3951
CabinCO2Level 600.0000
CabinTempLevel 21.2000
CabinPressure 14.7000
CabinMoistLevel 36.0000
CabinDustLevel 0.0001
CabinO2Setting 21.4000
CabinTempSetting 21.2000
CabinPressSetting 14.7000
AntennaTarget no_target
O2ConsumptionSetting 1
FuelConsumptionSetting 1
MainenginePower 1
;------------------Crew parameters UMMUCREW Function-Name-Age-CardiacPulse-WeightKg (fonction of Pilot must be: Capt)
NoOneOnBoard 0
NoPilotOnBoard 0
UMMUCREW Capt-Francois_Bowman-41-65-80
UMMUCREW -Peter_Dawson-35-69-94
FailGearFailure 0
FailGearCollapse 0
FailLeftMainEngine 0
FailRightMainEngine 0
FailHoverEngine 0
FailRcs 0
FailSurfaceControl 0
FailComputer 0
FailComputerBlueScreen 0
FailAutopilot 0
FailExtRadiator 0
FailAirbrake 0
FailNoseCone 0
FailCanopy 0
FailAntenna 0
FailLeftTurbo 0
FailRightTurbo 0
FailCargoDoor 0
SpacesuitTimer 0
UCGO @@0,1,0,0,@@1,1,0,0,@@2,1,0,0,@@3,1,0,0,
END
Floatax-3:Deltaglider
STATUS Landed Mars
BASE Ganges South:1
POS -51.3399831 -12.0299970
HEADING 259.34
ALT 2.540
AROT -162.809 51.878 91.651
RCSMODE 2
AFCMODE 7
PRPLEVEL 0:0.539880 1:0.859881
NAVFREQ 180 500 0 0
XPDR 0
RCOVER 1.0000 0.0000
HOVERHOLD 0 2 2.7760e-006 -2.8920e-001
TRIM -0.013554
GEAR 1.0000 0.0000
RADIATOR 1.0000 0.0000
INSTRLIGHT 1 0 0.50
FLOODLIGHT 0 0.00
AAP 0:0 0:0 0:0
END
Cera-001:UCGO\Cargos\CargoBaseModule
STATUS Landed Mars
POS -110.9356220 29.0820500
HEADING 66.56
ALT 0.001
AROT 112.919 -67.840 -55.771
AFCMODE 56
CargoUnpacked 1
END
Cera-00:UCGO\Cargos\CargoBaseModule
STATUS Landed Mars
POS -110.9355720 29.0819300
HEADING 66.56
ALT 0.001
AROT 112.918 -67.840 -55.769
AFCMODE 56
CargoUnpacked 1
END
Cera:DGIVCargoB38
STATUS Orbiting Mars
RPOS 625249.732 1712173.635 2862448.801
RVEL -188.0107 92.6074 -14.3338
AROT 120.718 -4.036 170.189
VROT -0.0015 -0.0139 0.0034
AFCMODE 7
IDS 0:543 100
NAVFREQ 0 0
END
Floatax-4:XR2Ravenstar
STATUS Landed Mars
BASE Olympus:1
POS -135.4299859 12.7399939
HEADING 345.55
ALT 2.555
AROT 70.933 1.374 -44.732
RCSMODE 2
PRPLEVEL 0:0.999793 1:0.995918 2:1.000000
IDS 0:203 100
NAVFREQ 0 0 0 0
XPDR 201
SECONDARY_HUD 3
LAST_ACTIVE_SECONDARY_HUD 0
ADCTRL_MODE 0
TAKEOFF_LANDING_CALLOUTS 0.000000 0.000000 0.000000 0.000000 0.000000
APU_FUEL_QTY 0.953417
LOX_QTY 0.999697
CABIN_O2_LEVEL 0.209000
CREW_STATE 0
INTERNAL_SYSTEMS_FAILURE 0
COGSHIFT_MODES 0 0 0
MWS_ACTIVE 0
COOLANT_TEMP 31.200000
DMG_0 1.000000 Left Wing
DMG_1 1.000000 Right Wing
DMG_2 1.000000 Left Aileron
DMG_3 1.000000 Right Aileron
DMG_4 1.000000 Landing Gear
DMG_5 1.000000 Nosecone
DMG_6 1.000000 Retro Doors
DMG_7 1.000000 Top Hatch
DMG_8 1.000000 Radiator
DMG_9 1.000000 Airbrake
DMG_10 1.000000 Left Main Engine
DMG_11 1.000000 Right Main Engine
DMG_12 1.000000 Left SCRAM Engine
DMG_13 1.000000 Right SCRAM Engine
DMG_14 1.000000 Fore Hover Engine
DMG_15 1.000000 Aft Hover Engine
DMG_16 1.000000 Left Retro Engine
DMG_17 1.000000 Right Retro Engine
DMG_18 1.000000 Forward Lower RCS
DMG_19 1.000000 Aft Upper RCS
DMG_20 1.000000 Forward Upper RCS
DMG_21 1.000000 Aft Lower RCS
DMG_22 1.000000 Forward Star. RCS
DMG_23 1.000000 Aft Port RCS
DMG_24 1.000000 Forward Port RCS
DMG_25 1.000000 Aft Star. RCS
DMG_26 1.000000 Outboard Upper Port RCS
DMG_27 1.000000 Outboard Lower Star. RCS
DMG_28 1.000000 Outboard Upper Star. RCS
DMG_29 1.000000 Outboard Lower Port RCS
DMG_30 1.000000 Aft RCS
DMG_31 1.000000 Forward RCS
DMG_32 1.000000 Bay Doors
IS_CRASHED 0
MET_STARTING_MJD 52086.129385
INTERVAL1_ELAPSED_TIME -1.000000
INTERVAL2_ELAPSED_TIME -1.000000
MET_RUNNING 1
INTERVAL1_RUNNING 0
INTERVAL2_RUNNING 0
ACTIVE_MDM 3
TEMP_SCALE 2
CUSTOM_AUTOPILOT_MODE 0
AIRSPEED_HOLD_ENGAGED 0
SCRAM0DIR 0.000000 0.000000 1.000000
SCRAM1DIR 0.000000 0.000000 1.000000
HOVER_BALANCE 0.000000
MAIN0DIR 0.000000 0.000000 1.000000
MAIN1DIR 0.000000 0.000000 1.000000
GIMBAL_BUTTON_STATES 0 0 0 0 0 0
ATTITUDE_HOLD_DATA 0.000000 0.000000 0 0 0.000000
DESCENT_HOLD_DATA 0.000000 -3.000000 0
AIRSPEED_HOLD_DATA 0.000000
OVERRIDE_INTERLOCKS 0 0
TERTIARY_HUD_ON 1
CREW_DISPLAY_INDEX 0
GEAR 1 1.0000
RCOVER 1 1.0000
NOSECONE 0 0.0000
AIRLOCK 0 0.0000
IAIRLOCK 0 0.0000
CHAMBER 0 0.0000
AIRBRAKE 0 0.0000
RADIATOR 1 1.0000
LADDER 0 0.0000
HATCH 0 0.0000
SCRAM_DOORS 0 0.0000
HOVER_DOORS 0 0.0000
APU_STATUS 0
EXTCOOLING_STATUS 0
TRIM 0.000000
LIGHTS 0 0 0
PARKING_BRAKES 0
XR1UMMU_CREW_DATA_VALID 1
UMMUCREW XI0-Lee_Nash-39-65-78
UMMUCREW XI1-Kara_Miller-32-65-58
PAYLOAD_SCREENS_DATA 0.2 0 1 2
GRAPPLE_TARGET XR2PayloadCHM-01-1
PAYLOAD_BAY_DOORS 1 1.0000
END
Floatax-4_Bay:XRPayloadBay
STATUS Landed Mars
POS -135.4299733 12.7399451
HEADING 345.55
ALT 3.618
AROT 0.000 -0.000 0.000
ATTACHED 0:3,Floatax-4
AFCMODE 7
END
XR2PayloadCHM-01-1:XR2PayloadCHM
STATUS Landed Mars
POS -135.4299950 12.7400278
HEADING 345.55
ALT 3.331
AROT 128.769 -34.996 159.105
ATTACHED 0:0,Floatax-4
AFCMODE 7
NAVFREQ 0 0
END
Cera-0:UCGO\Cars\CarLunarRover
STATUS Landed Mars
POS -110.9357820 29.0820500
HEADING 21.56
ALT 0.935
AROT 69.836 -30.471 -20.968
AFCMODE 7
NAVFREQ 0 0
AIInFonction 0
CurrentWpt 0
EngineStarted 1.0000000000
FlashLightState 0
SAVEVAR00 2§0,5§0,8§0,11§0,14§0,17§0,20§0,23§0,26§0,29§0,32§0,35§0,38§0,41§0,44§0,47§0,50§0,53§0,56§0,59§0,200§0,301§0,400§1,401§1,403§1,405§1,407§1,
END
Cera-AZ-1:UCGO\Cars\CarAzure
STATUS Landed Mars
POS -110.3031220 34.0439300
HEADING 67.56
ALT 0.935
AROT 110.135 -70.590 -57.525
AFCMODE 7
NAVFREQ 0 0
AIInFonction 0
CurrentWpt 0
EngineStarted 1.0000000000
FlashLightState 0
SAVEVAR00 2§0,5§0,8§0,11§0,14§0,17§0,20§0,23§0,26§0,29§0,32§0,35§0,38§0,41§0,44§0,47§0,50§0,53§0,56§0,59§0,200§0,301§0,400§1,401§1,403§1,405§1,407§1,
UCGO @@0,1,0,0,@@1,1,0,0,
END
Ceraunius_B:UCGO\Cargos\CargoLandingBeacon
STATUS Landed Mars
POS -109.5940220 30.4002300
HEADING 90.00
ALT 0.005
AROT -179.999 -70.406 -120.401
AFCMODE 16
CargoUnpacked 0
END
END_SHIPS
BEGIN_ReFuelMFD
SCENARIO_TREE
NAMED Computers
END_NODE
END_NODE
END
Script:
Code:
proc.wait_simdt(7.0)
oapi.set_cameratarget(vessel.get_focushandle(), 2)
local camera_mode = {}
camera_mode.mode = 'track'
camera_mode.trackmode = 'RELATIVE'
camera_mode.reldist = 2.7
camera_mode.phi = 2.0
camera_mode.tht = -0.5
oapi.set_cameramode(camera_mode)
proc.wait_simdt(2.0)
local my_vessel = vessel.get_focusinterface()
local cargo_vessel_interface = vessel.get_interface('Cera')
local cargo_vessel_handle = oapi.get_objhandle('Cera')
local att = my_vessel:get_attachmenthandle(false, 0)
local att1 = cargo_vessel_interface:get_attachmenthandle(true, 0)
local att_pos = {x = 0.0, y = 3.0, z = -1.5}
-- local att_pos = {x = pos_x, y = pos_y, z = pos_z}
local att_dir = {x = 0.0, y = 0.0, z = -1.0}
local att_rot = {x = 0.0, y = -1.0, z = 0.0}
local att_pos1 = {x = 0.0, y = 0.9, z = 0.0}
local att_dir1 = {x = 0.0, y = 0.0, z = -1.0}
local att_rot1 = {x = 0.0, y = -1.0, z = 0.0}
my_vessel:set_attachmentparams(att, att_pos, att_dir, att_rot)
cargo_vessel_interface:set_attachmentparams(att1, att_pos1, att_dir1, att_rot1)
my_vessel:attach_child(cargo_vessel_handle, att, att1)
proc.wait_simdt(2.0)
local my_vessel = vessel.get_focusinterface()
local att = my_vessel:get_attachmenthandle(false, 0)
my_vessel:detach_child(att)