add Config.Debug global config variable and added some debug print statements that the variable controls

This commit is contained in:
2026-06-26 10:55:26 -05:00
parent da937b7771
commit f34a2c0dc3

View File

@@ -56,6 +56,7 @@ TransmissionTypes = {
Config = {}
Config.ConfigPath = "/caero-attitude-control/config/config.txt"
Config.Debug = false -- this controls debug prints
-- File serializatino and deserialization
-- taken from https://gist.github.com/yuhanz/6688d474a3c391daa6d6
@@ -462,18 +463,24 @@ function PollVelocity()
-- Velocity Sensors
VelocityVectors = {}
local next = next
if next(velSensors) == nil then
if next(velSensors) == nil then -- verify table is not empty
SensorData.Velocity = {}
for vsindex, velsensor in pairs(velSensors) do
for _, velsensor in pairs(velSensors) do
local vsAxis = velsensor.getAxis()
local vsVelocity = velsensor.getVelocity()
VelocityVectors[vsAxis] = vsVelocity
SensorData.Velocity.Raw = VelocityVectors
if Config.Debug then
print("DEBUG: PollVelocity fetched sensor data: "..SensorData.Velocity)
end
end
end
@@ -494,6 +501,10 @@ function PollAltitude()
SensorData.Altitude.Altitude = Altitude
SensorData.Altitude.AirPressure = AirPressure
SensorData.Altitude.VerticalSpeed = VerticalSpeed
if Config.Debug then
print("DEBUG: PollAltitude fetched sensor data: "..SensorData.Altitude)
end
end
end
@@ -559,6 +570,10 @@ function PollGimbal()
SensorData.Gimbal.Angles = Angles
SensorData.Gimbal.AngularRates = AngularRates
SensorData.Gimbal.LinearAcceleration = LinearAcceleration
if Config.Debug then
print("DEBUG: PollGimbaal fetched sensor data: "..SensorData.Gimbal)
end
end
end
@@ -689,7 +704,7 @@ function Init()
if configChunk then
Thrusters = configChunk()
else
print("Error loading thruster config string: "..err)
print("ERROR: Error loading thruster config string: "..err)
end
thrusterConfigFile:close()
else
@@ -839,15 +854,7 @@ function Main()
if keys.getName(key) == "q" then
print("Quit Input Received")
print("Writing to thruster config file.")
local thrusterConfigFile = fs.open(Config.thrusterConfigPath, "w+")
thrusterConfigFile.write(tableToString(Thrusters))
thrusterConfigFile.close()
print("Writing to config file")
local configFile = fs.open(Config.ConfigPath, "w+")
configFile.write(tableToString(Config))
configFile.close()
WriteConfigFiles()
sentinel = false
else