Here is my script. Where did I go wrong or why did it stop on the MaxDecel?
MaxDecelG = 1.20
chBrake = addChannel("vBrake", 25, 0, 0, 100, ' ')
function updatevBrake()
BrakeG = getChannel(LongAccel)
BrakePos = (BrakeG/MaxDecelG)*100
if BrakePos < 10 then BrakePos = 0 end
BrakePos = math.abs(BrakePos)
if BrakePos > 99 then BrakePos = 100 end
setChannel(chBrake, BrakePos)
end
setTickRate(25)
function onTick()
updatevBrake()
end
Here is the error
[lua] Successfully loaded script.
[lua] Script error: [string "MaxDecelG = 1.20..."]:5.0: Expected number or string argument at position 1
[lua] Script error: [string "MaxDecelG = 1.20..."]:5.0: Expected number or string argument at position 1
[lua] Script error: [string "MaxDecelG = 1.20..."]:5.0: Expected number or string argument at position 1
[lua] Failure: Runtime Error
[lua] Gracefully stopping Lua Task
[lua] Destroying Lua State
[lua] Initializing Lua state
[lua] memory usage: 17KB
[lua] Starting Lua Task
[lua] Loading script. Length: 354
timebase/logging/telemetry sample rate: 100/100/50
[lua] Successfully loaded script.
[lua] Script error: [string "MaxDecelG = 1.20..."]:5.0: Expected number or string argument at position 1
[lua] Script error: [string "MaxDecelG = 1.20..."]:5.0: Expected number or string argument at position 1
[lua] Script error: [string "MaxDecelG = 1.20..."]:5.0: Expected number or string argument at position 1
[lua] Failure: Runtime Error
[Solved] Help with Brake script on wiki
-
- Posts: 69
- Joined: Mon Jan 29, 2018 11:20 pm
[Solved] Help with Brake script on wiki
Last edited by Canyonfive on Fri Aug 07, 2020 8:15 pm, edited 1 time in total.
-
- Posts: 69
- Joined: Mon Jan 29, 2018 11:20 pm
-
- Posts: 69
- Joined: Mon Jan 29, 2018 11:20 pm
Even though I'm on the current firmware it looks like it worked with getImu instead of getChannel.
MaxDecelG = 1.20
chBrake = addChannel("vBrake", 25, 0, 0, 100, ' ')
function updatevBrake()
BrakeG = getImu(1)
BrakePos = (BrakeG/MaxDecelG)*100
if BrakePos < 10 then BrakePos = 0 end
BrakePos = math.abs(BrakePos)
if BrakePos > 99 then BrakePos = 100 end
setChannel(chBrake, BrakePos)
end
setTickRate(25)
function onTick()
updatevBrake()
end
MaxDecelG = 1.20
chBrake = addChannel("vBrake", 25, 0, 0, 100, ' ')
function updatevBrake()
BrakeG = getImu(1)
BrakePos = (BrakeG/MaxDecelG)*100
if BrakePos < 10 then BrakePos = 0 end
BrakePos = math.abs(BrakePos)
if BrakePos > 99 then BrakePos = 100 end
setChannel(chBrake, BrakePos)
end
setTickRate(25)
function onTick()
updatevBrake()
end