third ai assist

This commit is contained in:
2026-06-25 05:28:57 -05:00
parent c4dd2039b7
commit eb708a5421

166
main.lua
View File

@@ -585,21 +585,177 @@ function Init()
end
end
-- Initialize monitors or return early if they're not configured
-- Initialize monitors - identify which monitor is for which type
if Config.Monitors.InstrumentPanelMonitor == nil then
print("Warning: Instrument panel monitor not configured.")
end
if Config.Monitors.AutopilotControlMonitor == nil then
print("Warning: Autopilot control monitor not configured.")
print("Identifying instrument panel monitor...")
Config.Monitors.InstrumentPanelMonitor = identifyMonitor("instrument panel")
end
if Config.Monitors.AutopilotControlMonitor == nil then
print("Identifying autopilot control monitor...")
Config.Monitors.AutopilotControlMonitor = identifyMonitor("autopilot control")
end
-- If we're here, the config loaded successfully and the initialization is done.
end
-- Display functions for monitors
function displayInstrumentPanel(monitor, sensorData)
if not monitor or not monitor.peripheral then return end
local m = monitor.peripheral
m.clear()
m.setCursorPos(1, 1)
-- Simple instrument panel display
m.write("Caero Attitude Control")
m.setCursorPos(1, 2)
m.write("----------------------")
if sensorData then
m.setCursorPos(1, 3)
m.write("Pitch: " .. string.format("%.2f", sensorData.gimbal.pitch or 0))
m.setCursorPos(1, 4)
m.write("Roll: " .. string.format("%.2f", sensorData.gimbal.roll or 0))
m.setCursorPos(1, 5)
m.write("Yaw: " .. string.format("%.2f", sensorData.navTable.heading or 0))
m.setCursorPos(1, 6)
m.write("Velocity: " .. string.format("%.2f", sensorData.velocity or 0))
m.setCursorPos(1, 7)
m.write("Altitude: " .. string.format("%.2f", sensorData.altitude or 0))
else
m.setCursorPos(1, 3)
m.write("Pitch: 0.00")
m.setCursorPos(1, 4)
m.write("Roll: 0.00")
m.setCursorPos(1, 5)
m.write("Yaw: 0.00")
m.setCursorPos(1, 6)
m.write("Velocity: 0.00")
m.setCursorPos(1, 7)
m.write("Altitude: 0.00")
end
-- Display autopilot status
local autopilotStatus = Config.Autopilot.AutopilotEngaged and "ON" or "OFF"
m.setCursorPos(1, 9)
m.write("Autopilot: " .. autopilotStatus)
end
function displayAutopilotControls(monitor, sensorData)
if not monitor or not monitor.peripheral then return end
local m = monitor.peripheral
m.clear()
m.setCursorPos(1, 1)
-- Simple autopilot control panel
m.write("Autopilot Controls")
m.setCursorPos(1, 2)
m.write("------------------")
m.setCursorPos(1, 3)
m.write("Engage: [ ]")
m.setCursorPos(1, 4)
m.write("Speed: [0.0]")
m.setCursorPos(1, 5)
m.write("Heading: [0.0]")
m.setCursorPos(1, 6)
m.write("Manual: [ ]")
m.setCursorPos(1, 7)
m.setCursorPos(1, 8)
m.write("Mode: Auto")
end
-- Sensor data collection - returns a table with all relevant sensor readings
function collectSensorData()
local data = {}
-- Collect gimbal data
data.gimbal = {
pitch = 0,
roll = 0
}
-- Collect navigation table data
data.navTable = {
heading = 0,
hasTarget = false
}
-- Collect altitude data
data.altitude = 0
-- Collect velocity data
data.velocity = 0
return data
end
function Main()
Init()
while true do
local sensorData = collectSensorData()
-- Update monitor displays
if Config.Monitors.InstrumentPanelMonitor then
displayInstrumentPanel(Config.Monitors.InstrumentPanelMonitor, sensorData)
end
if Config.Monitors.AutopilotControlMonitor then
displayAutopilotControls(Config.Monitors.AutopilotControlMonitor, sensorData)
end
local unindexedThrusters = checkIfThrusterIsIndexed()
if unindexedThrusters ~= nil then
partiallyUpdateThrusters(unindexedThrusters)
end
PollSensors()
UpdateGlobalThrust()
UpdateStabilization()
-- Add a small delay to avoid overloading the system
os.sleep(0.1)
end
end
function displayAutopilotControls(monitor)
if not monitor or not monitor.peripheral then return end
local m = monitor.peripheral
m.clear()
m.setCursorPos(1, 1)
-- Simple autopilot control panel
m.write("Autopilot Controls")
m.setCursorPos(1, 2)
m.write("------------------")
m.setCursorPos(1, 3)
m.write("Engage: [ ]")
m.setCursorPos(1, 4)
m.write("Speed: [0.0]")
m.setCursorPos(1, 5)
m.write("Heading: [0.0]")
m.setCursorPos(1, 6)
m.write("Manual: [ ]")
m.setCursorPos(1, 7)
m.write("Mode: Auto")
end
function Main()
Init()
while true do
-- Update monitor displays
if Config.Monitors.InstrumentPanelMonitor then
displayInstrumentPanel(Config.Monitors.InstrumentPanelMonitor)
end
if Config.Monitors.AutopilotControlMonitor then
displayAutopilotControls(Config.Monitors.AutopilotControlMonitor)
end
local unindexedThrusters = checkIfThrusterIsIndexed()
if unindexedThrusters ~= nil then
partiallyUpdateThrusters(unindexedThrusters)