Best way to do external controls for LinuxCNC
- FDP
- Offline
- Junior Member
Less
More
- Posts: 30
- Thank you received: 1
10 Sep 2021 03:09 #220102
by FDP
Replied by FDP on topic Best way to do external controls for LinuxCNC
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.
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.
- Roiki
- Offline
- Premium Member
Less
More
- Posts: 116
- Thank you received: 19
10 Sep 2021 13:26 #220128
by Roiki
Replied by Roiki on topic Best way to do external controls for LinuxCNC
Because python is interpreted language and the python interpreter is not a realtime process.
Only kernel modules can run at realtime.
Only kernel modules can run at realtime.
Please Log in or Create an account to join the conversation.
- FDP
- Offline
- Junior Member
Less
More
- Posts: 30
- Thank you received: 1
10 Sep 2021 14:53 - 10 Sep 2021 14:54 #220136
by FDP
Replied by FDP on topic Best way to do external controls for LinuxCNC
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?
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.
- Roiki
- Offline
- Premium Member
Less
More
- Posts: 116
- Thank you received: 19
11 Sep 2021 13:24 #220220
by Roiki
Replied by Roiki on topic Best way to do external controls for LinuxCNC
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.
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.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23170
- Thank you received: 4860
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?
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.
- arvidb
- Offline
- Platinum Member
Less
More
- Posts: 512
- Thank you received: 158
06 Oct 2021 14:47 #222365
by arvidb
Replied by arvidb on topic Best way to do external controls for LinuxCNC
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.Thanks @Roiki. Do you know why Python 3 can't run as realtime code using PREEMPT_RT?
Please Log in or Create an account to join the conversation.
Time to create page: 0.125 seconds