nil verification in UpdateGlobalThrust for required SensorData fields

This commit is contained in:
2026-06-27 17:48:30 -05:00
parent 633e2c11d5
commit 621c27e551

View File

@@ -710,6 +710,14 @@ function UpdateGlobalThrust()
-- depending on the desired thrust vectors, some counteractive desired thrust vectors will be ignored
-- lateral thrust
-- verify that SensorData.Velocity.Raw is not nil
if SensorData.Velocity.Raw == nil then
if Config.Debug then
print("DEBUG: SensorData.Velocity.Raw is nil, skipping UpdateGlobalThrust")
end
return
end
local desiredLateralThrustVectors = {}
for f, v in pairs(SensorData.Velocity.Raw) do
@@ -739,6 +747,14 @@ function UpdateGlobalThrust()
end
-- angular thrust
-- verify that SensorData.Gimbal.AngularRates is not nil
if SensorData.Gimbal.AngularRates == nil then
if Config.Debug then
print("DEBUG: SensorData.Gimbal.AngularRates is nil, skipping UpdateGlobalThrust")
end
return
end
local desiredAngularThrustVectors = {}
for f, v in pairs(SensorData.Gimbal.AngularRates) do
@@ -933,6 +949,11 @@ function Main()
print("Mainloop starting. Press 'q' to stop the loop and save configuration changes.")
while sentinel do
PollSensors()
UpdateStabilization()
UpdateGlobalThrust()
-- Update monitor displays
if Config.Monitors.InstrumentPanelMonitor then
displayInstrumentPanel(Config.Monitors.InstrumentPanelMonitor, SensorData)
@@ -947,10 +968,6 @@ function Main()
partiallyUpdateThrusters(unindexedThrusters)
end
PollSensors()
UpdateGlobalThrust()
UpdateStabilization()
local function getTerminateEvent()
local event, key, is_held = os.pullEventRaw("key")
if keys.getName(key) == "q" then