Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --подключение библиотеки
- l=dofile('pid_loop')
- --положение
- local c=0
- --цель
- local r=10
- --скорость
- local speed=0
- --разница для регулятора
- function get()
- return r-c
- end
- --задание значения
- --скорость набирается не мгновенно,к слову
- function set(value)
- if value>0 then speed=speed+math.min(0.1,value) else speed=speed-math.min(-value,0.3) end
- end
- --создание цикла
- loop=l.add(get,set,0.01,0.006,0.006,-0.3,0.1)
- while true do
- --шаг
- loop:execute(0.1)
- --вычесление позиции
- c=c+speed
- print(c)
- --задержка
- os.sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement