Compare commits

...

127 Commits

Author SHA1 Message Date
eb8faa9c10 adjust PID kp values 2026-06-30 00:21:25 -05:00
165c0cefa9 adjust PID maxOutput 2026-06-30 00:19:05 -05:00
131bbd9f0a adjust PID update function return value 2026-06-30 00:16:39 -05:00
dd70e5ddb2 comment out SetThrusterPower debug print 2026-06-30 00:10:43 -05:00
a65299be26 fix an issue with populateThrusterValues? idk how this regression happened... 2026-06-30 00:09:40 -05:00
7174c16628 add debug print to new section 2026-06-30 00:04:59 -05:00
fa96b2f59f add aformentioned simplified stabilization for vessels with thrusters with the field populated correctly 2026-06-30 00:03:07 -05:00
f816761e0f add extra field in Thrusters for simplifying quadricopter-like stabilization systems 2026-06-29 23:57:13 -05:00
056c10c346 add a debug print to the PID update function 2026-06-29 23:47:45 -05:00
908a2153fa comment out primary UpdateGlobalThrust debug print for testing 2026-06-29 23:43:58 -05:00
7bcabcbbe6 edit debug prints and add new ones 2026-06-29 23:42:58 -05:00
1aa391f56c adjust PID max output 2026-06-29 23:40:09 -05:00
e7831845a8 edit UpdateGlobalThrust debug print 2026-06-29 23:39:40 -05:00
d228666c87 remove normalized thrust reference in UpdateGlobalThrust debug print 2026-06-29 23:38:07 -05:00
b8b22f29b1 fix number boolean comparison in PIDs 2026-06-29 23:37:14 -05:00
46c04bf646 fix out-of-scope issue with the D variable in PIDs 2026-06-29 23:35:43 -05:00
61c8f88d40 edit PIDs to output normalized data and changed how UpdatGlobalThrust works 2026-06-29 23:34:18 -05:00
cb7b9490bf make max thrust for normalization 50 2026-06-29 23:11:04 -05:00
600a683a12 make minimum thrust for normalization 0 2026-06-29 23:08:50 -05:00
373089d374 try to fix normalization again 2026-06-29 23:05:23 -05:00
23644f7072 switch signs around for correction values in poll functions 2026-06-29 22:50:29 -05:00
e11c6483f9 change thrust nomalization 2026-06-29 22:36:06 -05:00
7c0cd566b1 change the UpdateGlobalThrust thrust nomalization to actually have a contiguous range of values 2026-06-29 22:15:01 -05:00
aab62f51cc remove actualpower print statement from SetThrusterPower 2026-06-29 22:11:28 -05:00
12cad05ed6 convert ms to seconds in UpdateGlobalThrust 2026-06-29 22:09:03 -05:00
92988ac4f5 chage altitude PIDs 2026-06-29 22:02:52 -05:00
68a3f4589b continued from last commit 2026-06-29 21:58:00 -05:00
ed25934cb7 hopefully fix SetThrusterPower for rotators with analog transmissions 2026-06-29 21:56:04 -05:00
d2bacd30bb add another debug print and change position of debug print in SetThrusterPower 2026-06-29 21:52:47 -05:00
f38c765c40 add debug print to UpdateGlobalThrust 2026-06-29 21:49:07 -05:00
91c1723a9e add debug statement to SetThrusterPower 2026-06-29 21:46:22 -05:00
406cc966ec adjust kp values 2026-06-29 21:44:21 -05:00
d07b952d66 add heading correction to other sensor poll functions 2026-06-29 21:42:26 -05:00
85fd1d0d85 correct errors and slight code cleanup 2026-06-29 21:23:10 -05:00
0766e4ce5a maybe fix UpdateGlobalThrust? 2026-06-29 21:19:45 -05:00
a408dd9f34 adjust kp values for currently used PIDs (testing) 2026-06-29 21:08:48 -05:00
c80855dc2f continued from last commit 2026-06-29 21:02:07 -05:00
1ab0510826 have UpdateGlobalThrust attempt to counteract the actual pitch/roll instead of the pitch/roll rates 2026-06-29 21:01:46 -05:00
485c2eac37 fix displayInstrumentPanel pitch/roll incorrect references 2026-06-29 20:54:32 -05:00
996c49f5a3 moved PollVelocity debug print outside of loop to avoid redundant terminal output 2026-06-29 20:52:34 -05:00
1de102e132 move post-quit code outside of mainloop 2026-06-29 20:49:41 -05:00
06a10ff0f9 lower pause back to normal value 2026-06-29 20:48:24 -05:00
9b397337da i'm stupd 2026-06-29 20:47:53 -05:00
39a8b0ba88 set thruster power to 0 (and release control of transmission if applicable) on quit 2026-06-29 20:46:52 -05:00
3ab9bc411f attempt a different approach at finding transmissions 2026-06-29 20:41:46 -05:00
a508fbad58 added a break in populateThrusterValues to break out of loop when transmission is found 2026-06-29 20:31:33 -05:00
b431e1a0a6 added even more debug prints 2026-06-29 20:26:46 -05:00
13f970af76 added some more debug prints to populateThrusterValues 2026-06-29 20:17:52 -05:00
1f27dc0cda attempt another fix at transmission nil value population 2026-06-29 20:07:03 -05:00
b712a38006 increased pause between init and mainloop so that i can actually read debug prints 2026-06-29 20:04:31 -05:00
ce11e77d7c change some ordering and add some debug prints to thruster init functions 2026-06-29 20:03:05 -05:00
19c423ecfa added short pause before mainloop to display initialization changes 2026-06-29 19:55:14 -05:00
2d6e142eb6 remove unindexed thruster checking from mainloop for now 2026-06-29 19:53:51 -05:00
aff1a45a58 add nil checking for thruster init functions 2026-06-29 19:51:53 -05:00
ab8d65f477 added nil check for transmission list in populateThrusterValues 2026-06-29 19:48:22 -05:00
539fdd92fe hopefully fix some issues regarding thruster initialization 2026-06-29 19:46:03 -05:00
4976c5b227 fix PollVelocity empty array check 2026-06-29 16:19:31 -05:00
e27c899c17 add nil check for main SensorData subtables (but not values in those subtables) 2026-06-29 16:13:43 -05:00
e69c370c97 assorted bug fixes 2026-06-29 16:11:54 -05:00
9c22f72d4e add nil check for rotator thrusters with nil transmissions 2026-06-29 14:12:07 -05:00
dd4bc11c43 added error print for SetThrusterPower in order to catch nil thruster references 2026-06-29 14:10:17 -05:00
e13ae84aae hopefully fix nil reference error related to propeller transmissions 2026-06-29 14:02:58 -05:00
a9f483a05d remove missed UpdateStabilization reference in mainloop 2026-06-29 13:57:10 -05:00
d57bcf0ad4 begin reimplementation of UpdateGlobalThrust based on PIDs instead of the old system 2026-06-29 13:52:38 -05:00
de7decceaa modified thruster table to include all axis movement vectors 2026-06-29 13:51:57 -05:00
d9c29c89be refactored thruster init to follow new thruster schema; removed redundant UpdateStabilization function; removed some implimentation from the UpdateGlobalThrust functions in preparation for refactor 2026-06-28 11:02:53 -05:00
583c291af7 i switched up angular and lateral in the last commit. fixed 2026-06-28 10:55:58 -05:00
38e2e36e25 update thruster table for better thrust direction support 2026-06-28 10:53:15 -05:00
0c42fdaa8e removed debug statements from previous commit and (hopefully) fixed the array not empty check, since the check was designed for tables and not arrays 2026-06-27 18:04:28 -05:00
c724e848f7 more debug statements for troubleshooting 2026-06-27 18:02:05 -05:00
67c6916632 random test 1 for velocity sensors not found error 2026-06-27 18:00:08 -05:00
14ba0ba5ab re-order PollSensors to verify that the most important sensors have their debug statements display last 2026-06-27 17:58:52 -05:00
02b7e64301 accidentally forgot to re-define thrustDirections in UpdateGlobalAngularThrust 2026-06-27 17:55:02 -05:00
286e7287aa broke out UpdateGlobalThrust into UpdateGlobalLateralThrust and UpdateGlobalAngularThrust to check if the sensor issue is isolated 2026-06-27 17:53:49 -05:00
f229d407f8 refine nil check in last commit 2026-06-27 17:50:08 -05:00
621c27e551 nil verification in UpdateGlobalThrust for required SensorData fields 2026-06-27 17:48:30 -05:00
633e2c11d5 fix accidental function references instead of function value references 2026-06-27 17:41:09 -05:00
ae0e728d3e first implementation of the UpdateGlobalThrust function 2026-06-27 17:34:10 -05:00
ba5888bf1a added a WIP schema for all data structures under the ### Data Structures heading 2026-06-27 17:33:48 -05:00
ae5091c31e fix typo 2026-06-27 16:46:28 -05:00
d4e44ec9af actually convert sensor tables to strings for debug prints 2026-06-26 11:01:57 -05:00
f34a2c0dc3 add Config.Debug global config variable and added some debug print statements that the variable controls 2026-06-26 10:55:26 -05:00
da937b7771 first fix for angles not updating 2026-06-25 18:24:23 -05:00
c3e9454241 i'm so dumb 2026-06-25 18:20:59 -05:00
8d6ec4f6b8 Actually change the heading value you dingus 2026-06-25 18:19:50 -05:00
40ee96467d add some debug prints to debug heading correction 2026-06-25 18:17:09 -05:00
1d82b480ce fix heading correction maybe? 2026-06-25 18:06:29 -05:00
f6e7b50b9d remove redundant os.sleep in mainloop 2026-06-25 18:04:07 -05:00
153b149f5e fix heading correction (i'm so very stupid) 2026-06-25 18:01:55 -05:00
b7c4257c5c fix heading correction (i'm stupid) 2026-06-25 18:01:03 -05:00
d3b1df1db0 add heading offset correction value in config 2026-06-25 17:47:53 -05:00
5bdd71ecde begin properly implementing monitor display logic 2026-06-25 17:37:42 -05:00
e44603336b edit thrusters 2026-06-25 17:05:26 -05:00
ba5d21a723 fix monitor peripheral values being a string 2026-06-25 16:17:07 -05:00
9c137b3d20 fix loop not exiting after termination 2026-06-25 16:13:09 -05:00
0e1b932392 switch termination to quit botton 2026-06-25 16:10:51 -05:00
1c13ea58e5 termination fix pt1 2026-06-25 15:56:04 -05:00
440151eadc identifyThrottle fix p2 2026-06-25 15:52:42 -05:00
15b9e272f5 identifyThrottle fix p1 2026-06-25 15:48:12 -05:00
d46071ad1d fix terminate thing for good hopefully and add the throttles table to the config so it persists on restart 2026-06-25 15:45:51 -05:00
9170eebd4e fix attempt 2 of the terminate check stopping the mainloop 2026-06-25 15:37:42 -05:00
4f874af256 fix attempt 1 of the terminate check stopping the mainloop 2026-06-25 15:34:43 -05:00
cd9ac740a1 add writing to config files when the terminate event is received. 2026-06-25 15:25:56 -05:00
0776699c68 add lua table serialization and deserialization so abstract out loading config files 2026-06-25 15:14:24 -05:00
59e3b5a266 remove redundant assignMonitor function 2026-06-25 15:02:12 -05:00
c436363b98 remove duplicate displayAutopilotControls definition 2026-06-25 14:59:17 -05:00
ebbec7f885 PollVelocity attempt 1 2026-06-25 14:54:20 -05:00
6a3cba3404 fix identifyMonitor? pt 4 2026-06-25 14:50:25 -05:00
f80165c718 fix identifyMonitor? pt 3 2026-06-25 14:49:13 -05:00
84632a101c fix identifyMonitor? pt 2 2026-06-25 14:48:07 -05:00
a26fd278da fix identifyMonitor? 2026-06-25 14:45:52 -05:00
19ee451b3d change identifyMonitor to be more like the peripheral.find() documentation 2026-06-25 14:44:41 -05:00
3c43c747b0 change identifyMonitor and assignMonitor to local functions 2026-06-25 14:42:06 -05:00
8a9a59e97c rename symbol because idk what else to do 2026-06-25 14:40:47 -05:00
ab987319cb re-institute monitor nil check 2026-06-25 14:39:51 -05:00
e202ced697 test remove monitor nil check 2026-06-25 14:38:41 -05:00
3f5def2b6b i'm an idiot 2026-06-25 14:34:58 -05:00
2d30323148 add nil check to thruster index checking 2026-06-25 14:32:32 -05:00
f15b8dc2ef hopefully fix "too long without yielding" error for throttles 2026-06-25 14:29:14 -05:00
6668a99f28 move monitor identification above throttle identification 2026-06-25 14:24:56 -05:00
d08d662d01 fix PollThrottle, remove duplicate function definitions 2026-06-25 14:17:14 -05:00
bd5b6376e9 fixed some misuse of ipairs over pairs 2026-06-25 11:43:54 -05:00
998cc318f6 fix typo 2026-06-25 11:08:04 -05:00
3528c9628e fourth ai assist plus generalizing throttle identification code 2026-06-25 11:07:08 -05:00
1d690c6087 fix ThrottleInit (3) 2026-06-25 06:26:34 -05:00
e1e996e50f Fix ThrottleInit (2) 2026-06-25 06:22:27 -05:00
1f487a98c4 fix ThrottleInit (1) 2026-06-25 06:20:15 -05:00
3 changed files with 1078 additions and 309 deletions

221
docs.md
View File

@@ -119,7 +119,7 @@ Relevant peripherals:
> note: returns 0 if the magnitude is below 0.05 m/s
- `getAxis()`: returns the body-frame axis the sensor measures along
- returns string "x", "y", and "z"
- returns string "x", "y", or "z"
### Analog Transmission
@@ -193,3 +193,222 @@ Every cycle:
- Altitude Sensor `getHeight()`, `getAirPressure()`, `getVerticalSpeed()`
- Velocity Sensor `getAxis()`, `getVelocity`
- Poll input signal strengths for global downwards thrust, and fore and aft thrust
### Math
#### Calculate Counteractive Thrust
TODO: fill in
### Data Structures
#### Config
The member variables of the Config table is as follows:
```lua
Config = {
ConfigPath = "/path/to/config.txt",
thrusterConfigPath = "path/to/thrusters.txt",
Debug = false, -- controls various debug print statements
Monitors = {
InstrumentPanelMonitor = {
name = "peripheralName",
peripheral = {} -- stores the table returned by running peripheral.wrap(name)
},
AutopilotControlMonitor = {
name = "peripheralName",
peripheral = {}
}
},
Autopilot = {
AutopilotEngaged = false, -- global shutoff for all autopilot functions
AutoForeAft = false, -- automatic forward/rearward throttle
AutopilotDesiredSpeed = nil, -- keep a certain velocity
AutopilotDesiredHeading = nil -- maintain a certain heading
},
SensorCorrection = {
Heading = 0 -- this is directly added to the heading value, in case the vessel was built with the heading not being direct north
},
Throttles = {
fore = {
name = "peripheralName",
side = "redstoneRelaySide" -- it is assumed that a user will use a redstone relay for their throttles
},
aft = {
name = "peripheralName",
side = "redstoneRelaySide"
},
down = {
name = "peripheralName",
side = "redstoneRelaySide"
}
}
}
```
#### SensorData
The member variables of the sensor table is as follows:
```lua
SensorData = {
Velocity = {
Raw = {
x = nil,
y = nil,
z = nil
}
},
Altitude = {
Altitude = nil,
AirPressure = nil,
VerticalSpeed = nil
},
NavTable = {
Heading = nil,
HasTarget = nil,
-- values past this are only populated if HasTarget == true
TargetBearing = nil,
TargetClosureRate = nil,
TargetVerticalOffset = nil,
TargetRelativeAngle = nil
},
Gimbal = {
Angles = {
xAngle = nil,
zAngle = nil
},
AngularRates = {
wx = nil,
wy = nil,
wz = nil
},
LinearAcceleration = {
ax = nil,
ay = nil,
az = nil
}
}
```
#### Thrusters
The member variables of the Thruster table are as follows (using some example thrusters):
```lua
Thrusters = {
gyroscopic_propeller_bearing_0 = {
-- primary attitude thruster?
primary_pitch_thruster = true,
primary_roll_thruster = true,
primary_yaw_thruster = false,
-- primary lateral thruster?
primary_altitude_thruster = true,
primary_fore_thruster = false,
primary_aft_thruster = false,
x_config_equivalent = "1", -- if you're running a standard x configuration, what prop is this equivalent to?
type = "rotator",
name = "gyroscopic_propeller_bearing_0",
thruster = nil,
transmission = nil,
affectVectors = {
angular = {
yaw = nil,
pitch = "up",
roll = "star",
},
lateral = {
x = nil,
y = "up",
z = nil
}
},
power = nil
},
gyroscopic_propeller_bearing_1 = {
-- primary attitude thruster?
primary_pitch_thruster = true,
primary_roll_thruster = true,
primary_yaw_thruster = false,
-- primary lateral thruster?
primary_altitude_thruster = true,
primary_fore_thruster = false,
primary_aft_thruster = false,
x_config_equivalent = "2", -- if you're running a standard x configuration, what prop is this equivalent to?
type = "rotator",
name = "gyroscopic_propeller_bearing_1",
thruster = nil,
transmission = nil,
affectVectors = {
angular = {
yaw = nil,
pitch = "up",
roll = "port",
},
lateral = {
x = nil,
y = "up",
z = nil
}
},
power = nil
},
gyroscopic_propeller_bearing_2 = {
-- primary attitude thruster?
primary_pitch_thruster = true,
primary_roll_thruster = true,
primary_yaw_thruster = false,
-- primary lateral thruster?
primary_altitude_thruster = true,
primary_fore_thruster = false,
primary_aft_thruster = false,
x_config_equivalent = "4", -- if you're running a standard x configuration, what prop is this equivalent to?
type = "rotator",
name = "gyroscopic_propeller_bearing_2",
thruster = nil,
transmission = nil,
affectVectors = {
angular = {
yaw = nil,
pitch = "down",
roll = "port",
},
lateral = {
x = nil,
y = "up",
z = nil
}
},
power = nil
},
gyroscopic_propeller_bearing_3 = {
-- primary attitude thruster?
primary_pitch_thruster = true,
primary_roll_thruster = true,
primary_yaw_thruster = false,
-- primary lateral thruster?
primary_altitude_thruster = true,
primary_fore_thruster = false,
primary_aft_thruster = false,
x_config_equivalent = "3", -- if you're running a standard x configuration, what prop is this equivalent to?
type = "rotator",
name = "gyroscopic_propeller_bearing_3",
thruster = nil,
transmission = nil,
affectVectors = {
angular = {
yaw = nil,
pitch = "down",
roll = "star",
},
lateral = {
x = nil,
y = "up",
z = nil
}
},
power = nil
}
}
```

1071
main.lua

File diff suppressed because it is too large Load Diff

View File

@@ -1,26 +1,105 @@
return {
gyroscopic_propeller_bearing_0 = {
primary_pitch_thruster = true,
primary_roll_thruster = true,
primary_yaw_thruster = false,
primary_altitude_thruster = true,
primary_fore_thruster = false,
primary_aft_thruster = false,
x_config_equivalent = "1",
type = "rotator",
name = "gyroscopic_propeller_bearing_0",
thruster = nil,
transmission = nil,
affectVectors = {
yaw = nil,
pitch = "up",
roll = "star",
lateral = nil
angular = {
yaw = nil,
pitch = "up",
roll = "star",
},
lateral = {
x = nil,
y = "up",
z = nil
}
},
power = nil
},
gyroscopic_propeller_bearing_1 = {
primary_pitch_thruster = true,
primary_roll_thruster = true,
primary_yaw_thruster = false,
primary_altitude_thruster = true,
primary_fore_thruster = false,
primary_aft_thruster = false,
x_config_equivalent = "2",
type = "rotator",
name = "gyroscopic_propeller_bearing_1",
thruster = nil,
transmission = nil,
affectVectors = {
yaw = nil,
pitch = "up",
roll = "port",
lateral = nil
angular = {
yaw = nil,
pitch = "up",
roll = "port",
},
lateral = {
x = nil,
y = "up",
z = nil
}
},
power = nil
},
gyroscopic_propeller_bearing_2 = {
primary_pitch_thruster = true,
primary_roll_thruster = true,
primary_yaw_thruster = false,
primary_altitude_thruster = true,
primary_fore_thruster = false,
primary_aft_thruster = false,
x_config_equivalent = "4",
type = "rotator",
name = "gyroscopic_propeller_bearing_2",
thruster = nil,
transmission = nil,
affectVectors = {
angular = {
yaw = nil,
pitch = "down",
roll = "port",
},
lateral = {
x = nil,
y = "up",
z = nil
}
},
power = nil
},
gyroscopic_propeller_bearing_3 = {
primary_pitch_thruster = true,
primary_roll_thruster = true,
primary_yaw_thruster = false,
primary_altitude_thruster = true,
primary_fore_thruster = false,
primary_aft_thruster = false,
x_config_equivalent = "3",
type = "rotator",
name = "gyroscopic_propeller_bearing_3",
thruster = nil,
transmission = nil,
affectVectors = {
angular = {
yaw = nil,
pitch = "down",
roll = "star",
},
lateral = {
x = nil,
y = "up",
z = nil
}
},
power = nil
}