Welcome to the next generation of ComputerCraft stabilizers !
The qStab is a high performance 3-axis stabilizer made for both maintaining a heading and tracking a target.
Its robustness comes from its usage of quaternions instead of Euler angles and vectors, making it both simpler and more performant.
(not prone to gimbal-lock & higher precision).
This advanced system is designed to be fitted in Gen 3 tanks as it’s made to be integrated directly inside the transmission, the whole stabilizer is by default for oscillating turrets but can be modified to be only an horizontal stabilizer.
How to use it
-
Using the .vschem linked :
Spawn the schematic & drag all files to a computer, then restart each computer
-
Making your own transmission :
The code includes a “stabilizer.lua” file, being the core of its mechanics,
to use it, :
->load the library with ".dofile()",
->run ".setup()" once with the configs
->run ".calculateRPM()" every tick
local qStab = dofile("stabilizer.lua")
qStab.setup{ -- example configs for horizontal stab (xz plane)
-- proportional multiplier
P = 4,
-- output multiplier (if resistors are used for precision)
outputMult = 15,
-- the shipyard forward direction
forward = vector.new(0,0,-1),
-- the axis (-x, +x, -y, +y, -z, +z)
axis = "y", -- -y for horizontal
axis_sign = 1
}
-- then every tick..
local targetHeading = vector.new(1,0,0)
local RPM = qStab.calculateRPM({quat=...}, targetHeading:normalize())
RotationSpeedController.setTargetSpeed(RPM)
-- the code should be run in the ship controlling another one, not controlling itself
p.s: Credit is expected when used !