Best way to do external controls for LinuxCNC

More
10 Sep 2021 03:09 #220102 by FDP
Thanks @Roiki. Do you know why Python 3 can't run as realtime code using PREEMPT_RT?

It's OK for me to lose the trajectory planner for this application as I am driving a linkage that is moved using a combination of rotary axes, so the standard trajectory planning is probably not useful in my case.

Please Log in or Create an account to join the conversation.

More
10 Sep 2021 13:26 #220128 by Roiki
Because python is interpreted language and the python interpreter is not a realtime process.

Only kernel modules can run at realtime.

Please Log in or Create an account to join the conversation.

More
10 Sep 2021 14:53 - 10 Sep 2021 14:54 #220136 by FDP
For some reason I assumed that since Python compiles to bytecode it would be able to run in realtime.

Do you think a reasonable workaround would be to write a C/C++ library and then make a Python wrapper using CTypes?
Last edit: 10 Sep 2021 14:54 by FDP.

Please Log in or Create an account to join the conversation.

More
11 Sep 2021 13:24 #220220 by Roiki
Just because it compiles into bytecode doesn't make it realtime capable if there's nothing to run that bytecode with. The realtime modules are just linux kernel modules. Linux kernel modules are written in C(and rust in the future).

The linuxcnc python api is a wrapper to the c++ api. I don't know what library you're wanting to make but most of the functionality is already there.

Please Log in or Create an account to join the conversation.

More
05 Oct 2021 22:34 #222315 by andypugh
Replied by andypugh on topic Best way to do external controls for LinuxCNC
You might want to look at:

linuxcnc.org/docs/2.8/html/man/man1/halrmt.1.html

linuxcnc.org/docs/2.8/html/man/man1/linuxcncrsh.1.html

linuxcnc.org/docs/2.8/html/man/man1/linuxcncsvr.1.html

The last one exists, but I have no idea how to use it. If you figure it out then perhaps you can add to that manpage?

Please Log in or Create an account to join the conversation.

More
06 Oct 2021 14:47 #222365 by arvidb

Thanks @Roiki. Do you know why Python 3 can't run as realtime code using PREEMPT_RT?

You could run the Python interpreter as a realtime process, but the interpreter's garbage collector will kick in at random times which means your program still won't be time deterministic. You simply can't control the latency between "instructions" in Python.

Please Log in or Create an account to join the conversation.

Time to create page: 0.125 seconds
Powered by Kunena Forum