JuliaControl / ModelPredictiveControl.jl

An open source model predictive control package for Julia.
https://juliacontrol.github.io/ModelPredictiveControl.jl/stable
MIT License
66 stars 0 forks source link

Real-time loop tools #85

Closed franckgaga closed 1 month ago

franckgaga commented 3 months ago

@baggepinnen André was asking if there is any tools for (soft) real-time loops in julia. Something that could be use with this package to implement MPC on a real plant.

For sure, there is the simple polling solution with time in a while loop. Are you aware of anything fancier ? Maybe we could add simple functionalities for that ? I was thinking of using Asynchronous Programming for that, since one could say that's the high-level equivalent of an interrupt. What do you think ?

baggepinnen commented 3 months ago

I normally use the method I outline in this video (starts at 5:00), that is, to measure the execution time of the loop and then sleep using systemsleep for the loop interval, adjusted for the execution time. This is the method I've found to have the best predictability, at least under Linux.

For fancier scheduling there are tools like https://github.com/narijauskas/ReactiveToolkit.jl