diff --git a/firmware/controllers/lua/examples/can-client-dc-pid.txt b/firmware/controllers/lua/examples/can-client-dc-pid.txt index db0452f0a1..a80a3aae1c 100644 --- a/firmware/controllers/lua/examples/can-client-dc-pid.txt +++ b/firmware/controllers/lua/examples/can-client-dc-pid.txt @@ -4,6 +4,7 @@ startPwm(1, 80, 1.0) -- disable startPwm(2, 80, 0.0) +-- p, i, d, min, max pid = Pid.new(2, 0, 0, -100, 100) biasCurveIndex = findCurveIndex("bias") diff --git a/firmware/controllers/lua/examples/custom-launch-control.txt b/firmware/controllers/lua/examples/custom-launch-control.txt new file mode 100644 index 0000000000..35788844f7 --- /dev/null +++ b/firmware/controllers/lua/examples/custom-launch-control.txt @@ -0,0 +1,40 @@ +desiredRpmCurve = findCurveIndex("desired_rpm") +desiredBoostCurve = findCurveIndex("desired_boost") +initialTorqueReductionTable = findTableIndex("torque_red") +sparkCutByTorqueCurve = findCurveIndex("spark_cut") +sparkRetardByTorqueCurve = findCurveIndex("spark_retard") + +previousLaunchButtonState = 0 + +-- 50Hz +setTickRate(50) + +-- p, i, d, min, max +pid = Pid.new(2, 0, 0, -100, 100) + +function onTick() + launchButtonState = getAuxAnalog(0) > 1.5 + launchStrength = getAuxAnalog(1) + + if previousLaunchButtonState == 1 and launchButtonState == 0 then + print "Exiting LC" + elseif previousLaunchButtonState == 0 and launchButtonState == 1 then + desiredRPM = curve(desiredRpmCurve, launchStrength) + desiredBoost = curve(desiredBoostCurve, launchStrength) + + initialTorqueReduction = table3d(initialTorqueReductionTable, desiredRPM, desiredBoost) + + + print ("Running LC " ..desiredRPM .." boost=" + desiredBoost ..' t=' ..initialTorqueReduction) + + elseif launchButtonState == 1 then + + + print ("Running LC " ..desiredRPM .." boost=" + desiredBoost) + + else + print "Not running LC" + end + +end +