add aformentioned simplified stabilization for vessels with thrusters with the field populated correctly
This commit is contained in:
15
main.lua
15
main.lua
@@ -961,6 +961,8 @@ function UpdateGlobalThrust()
|
|||||||
for _, thruster in pairs(Thrusters) do
|
for _, thruster in pairs(Thrusters) do
|
||||||
local desiredThrust = 0
|
local desiredThrust = 0
|
||||||
|
|
||||||
|
if thruster.x_config_equivalent ~= nil then
|
||||||
|
|
||||||
-- Calculate desired thrust based on affectVectors and PID outputs
|
-- Calculate desired thrust based on affectVectors and PID outputs
|
||||||
if thruster.affectVectors.angular.pitch ~= nil and thruster.primary_pitch_thruster then
|
if thruster.affectVectors.angular.pitch ~= nil and thruster.primary_pitch_thruster then
|
||||||
if thruster.affectVectors.angular.pitch == "up" then
|
if thruster.affectVectors.angular.pitch == "up" then
|
||||||
@@ -994,6 +996,19 @@ function UpdateGlobalThrust()
|
|||||||
--if Config.Debug then print("DEBUG: "..thruster.name..": desiredThrust "..desiredThrust.." (from UpdateGlobalThrust)") end
|
--if Config.Debug then print("DEBUG: "..thruster.name..": desiredThrust "..desiredThrust.." (from UpdateGlobalThrust)") end
|
||||||
|
|
||||||
SetThrusterPower(thruster, desiredThrust)
|
SetThrusterPower(thruster, desiredThrust)
|
||||||
|
else
|
||||||
|
local prop1 = throttleOutput + pitchRateOutput + rollRateOutput -- front-left
|
||||||
|
local prop2 = throttleOutput + pitchRateOutput - rollRateOutput -- front-right
|
||||||
|
local prop3 = throttleOutput - pitchRateOutput - rollRateOutput -- back-right
|
||||||
|
local prop4 = throttleOutput - pitchRateOutput + rollRateOutput -- back-left
|
||||||
|
|
||||||
|
if thruster.x_config_equivalent == "1" then SetThrusterPower(thruster, prop1)
|
||||||
|
elseif thruster.x_config_equivalent == "2" then SetThrusterPower(thruster, prop2)
|
||||||
|
elseif thruster.x_config_equivalent == "3" then SetThrusterPower(thruster, prop3)
|
||||||
|
elseif thruster.x_config_equivalent == "4" then SetThrusterPower(thruster, prop4)
|
||||||
|
else print("ERROR: Thruster "..thruster.name.." has invalid x_config_equivalent value")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user