ROS LinuxCNC Link
- thefabricator03
- Offline
- Platinum Member
- Posts: 1130
- Thank you received: 533
I am trying to get my head around what a ROS ( Robot Operating System) and LinuxCNC link would look like.
I know Machinekit has a HAL interface that works with ROS, github.com/machinekoder/hal_ros_control , but due to MachineKit not being well maintained I want to do something similar with LinuxCNC.
Reading this article, medium.com/@slaterobotics/how-to-impleme...m-robot-748b52751f2e , it goes into detail how to set up ROS control to work with a lower level control software.
Now my question, how would LinuxCNC go about taking incoming ros_control commands, carry out the required action and then reporting commands back to ros_control?
Please Log in or Create an account to join the conversation.
- Grotius
- Offline
- Platinum Member
- Posts: 2234
- Thank you received: 1949
The github code show's how to do the hal io. This code looks familiar to me.
The second article is more c++ code. This can be used to send command to the hal layer.
Now my question, how would LinuxCNC go about taking incoming ros_control commands, carry out the required action and then reporting commands back to ros_control?
If the ros controller does the motion, the only thing the hal layer has to do is follow the pid commands.
I think you have too chuck up linuxcnc into linuxcnc and hal. Then you use only the hal side of linuxcnc.
Please Log in or Create an account to join the conversation.
- tommylight
- Offline
- Moderator
- Posts: 19409
- Thank you received: 6507
Not sure how useful it is.
Please Log in or Create an account to join the conversation.
- thefabricator03
- Offline
- Platinum Member
- Posts: 1130
- Thank you received: 533
Also I would like to make a GUI that is robot specific, How does a GUI interface with the LinuxCNC code?
Please Log in or Create an account to join the conversation.
- thefabricator03
- Offline
- Platinum Member
- Posts: 1130
- Thank you received: 533
So if I were to create a new GUI I would use the Python NML API to talk to the LinuxCNC components?
linuxcnc.org/docs/html/config/python-interface.html
Also can someone explain what a Hal Thread is? And if I were to have ROS talk to the HAL, how does the INI file come into the system?
The way I see it in my head at the moment is that ROS will control the trajectory of my robot, handle the kinematics and output data to LinuxCNC which will then control the motors and handle I/O, LinuxCNC will then send data back to ROS and the loop will continue.
Now I dont think ROS can handle a G-Code file ( I might be wrong), so I was thinking LinuxCNC will have to have a part in processing the G-Code and sending it back to ROS for processing, is that possible?
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
- Posts: 23560
- Thank you received: 4858
At a certain level, yes. You might well not want to be on that level.I have spent a bit of time reading the docs and from what I can tell LinuxCNC is controlled via NML messages, is that correct?
If you are writing a GUI I would expect to be a layer above NML.So if I were to create a new GUI I would use the Python NML API to talk to the LinuxCNC components?
If ROS sends actual joint positions I would expect to be a layer below NML.
Also can someone explain what a Hal Thread is?
A HAL thread is a list of functions (in the software sense) that are called in a fixed sequence on a fixed schedule.
You can run HAL standalone.
Assuming that you have a LinuxCNC installation on a PC, the following example will load a HAL thread, load a simple "add" component, a (userspace, non realtime) GUI monitor and should create an accurate millisecond clock.
Open a teminal:
halrun
loadrt threads name1=mS_thread period1=1000000
loadrt sum2
addf sum2.0 mS_thread
setp sum2.0.in0 1
net loopback sum2.0.out sum2.0.in1
start
loadusr halmeter pin sum2.0.out
linuxcnc.org/docs/2.8/html/man/man9/threads.9.html
linuxcnc.org/docs/2.8/html/man/man9/sum2.9.html
linuxcnc.org/docs/2.8/html/man/man1/halmeter.1.html
Please Log in or Create an account to join the conversation.
- thefabricator03
- Offline
- Platinum Member
- Posts: 1130
- Thank you received: 533
In your opinion, what advantages do you see in how MachineKit has its own HAL only program and running LinuxCNC with HAL standalone?
ROS would be commanding joint positions and controlling the motion planing and LinuxCNC would be used for controlling the hardware and I would need a GUI connecting everything together.
I would like to create a Python based programming language for controlling the robots rather than G-Code. Tormach are doing this with their new robot. Would I have to write a new interpreter for this?
Sorry for all the basic questions but I am a non programmer trying to work out what is needed to make something like this work.
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
- Posts: 23560
- Thank you received: 4858
Thanks Andy, I appreciate the reply.
In your opinion, what advantages do you see in how MachineKit has its own HAL only program and running LinuxCNC with HAL standalone?
I am not an expert on Machinekit, but I think that their change was purely packaging, making it possible to install HAL without the rest of LinuxCNC. Otherwise the function is the same.
Please Log in or Create an account to join the conversation.
- Grotius
- Offline
- Platinum Member
- Posts: 2234
- Thank you received: 1949
I would like to create a Python based programming language for controlling the robots rather than G-Code
This is ok.
The most easy way to start is run Linucnc. Sent some python coded joint position's to the nml interface.
You can do for example, sent joint positions trough halcommand or halui. Halui is very close to nml.
Halui command's are very usefull.
Imagine linuxcnc as a pid controller.
And see what happens. I worked kind of this way to get a gremlin preview in axis that the command's works.
Step 2 would be connect the Ros output command's to nml or your custom python program.
Step 3 would be use ros & hal only. etc.
So step by step you will get it running.
Please Log in or Create an account to join the conversation.
- thefabricator03
- Offline
- Platinum Member
- Posts: 1130
- Thank you received: 533
Please Log in or Create an account to join the conversation.