grotius-cnc / hal-core

cnc and robot realtime controller. runs on a hal kernel module.
GNU General Public License v2.0
43 stars 20 forks source link

Interact in RT with EtherCAT | I/O #15

Closed jjrbfi closed 2 years ago

jjrbfi commented 3 years ago

Interact with the terminals in RT will be a plus. Getting values and also changing them.

(Not sure if halcmd will be the way to go. At least in realtime)

[Edit] EtherCAT or whatever other terminal connected into HAL.

[Edit] Good source to reach the goal? http://linuxcnc.org/docs/ja/html/man/man3/.

grotius-cnc commented 3 years ago

Hi,

Linuxcnc has original halshow and halmeter to interact with the kernel modules from userland. Halmeter is using tk and is a kind of old program, but works well. Halmeter is a tiny program, not very handy in usage.

I made the halview program in qt : https://sourceforge.net/projects/halview/ Halview is 90% working. Some exotic's like hal_port is not implemented. Halview has a update timer of 200ms.

For interaction (testing ethercat terminals) we usally use one of above programs.

For example, a gantry ethercat machine with steppers will also make usage of the base-thread in nanoseconds to give the step-pulses to the EL2124.

I have plenty examples how to integrate a c++ qt gui directly with Hal. But that will alway's be non-realtime interface. The realtime stuff is done between the different linked kernel modules.

Yes, that's a nice source!

I can imagine in your case when connecting to ROS. Ros will output a target position for a certain robot joint. Then you can use for example the DoFs or a Stepgen component coupled to a ethercat terminal in hal to perform this step.

If you see any usefull existing component in lcnc, you can just implement it in hal-ccore easy.

Most of the time i used the stepgen component to drive the motors on my desk, and also with real machines.

jjrbfi commented 3 years ago

Hi,

Thanks for the hints!

My idea is just to get the values of pins and motor encoder (EL7342) in "realtime" to interact it with ROS commands ( rostopic echo and rostopic pub ).

I used this time ago. But FSOE are not implemented in those drivers: https://github.com/chucktator/rtt_soem

That ROS "wrapped" are based on: https://github.com/orocos/rtt_ros_integration

And here are some rtt_ROS examples that they have made quite many years a go to use and implement ROS: https://github.com/jhu-lcsr/rtt_ros_examples

I believe that the integration will be not quite hard, but the interaction with HAL in real-time will be tricky. What do you think?

grotius-cnc commented 3 years ago

Hi,

If i look here http://wiki.ros.org/rostopic, i suggest this is a commandline style that you can use :

$ rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: 0.1, y: 0.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: 0.0}}' $ rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: 200.1, y: 200.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: 0.0}}

In above example you did 2 moves. I imagine the above commands are passed to a hal-core "c struct" that contains a list of positions to do.

Easyer is to pass it to the c++ side of the hal-core component as this can handle vectors easy. Using vectors in C is quite more work to setup with allocating, de-allocating etc. The c++ side then gives the pos info to the c struct as a single line pos command and reports back when the move is done.

Then hal-core uses the stepgen component to perform the moves. You can report back your encoder pos every 1ms or even faster if you pass values back on the base-thread.

The stepgen component is the interpolation mechanisme to ensure your motors run very shooth without shocking because of time delays. The ruckig component is a s-curve style motion but has no stepgen pulse generator. But you can combine these 2 easy.

Ros commands -> Your-hal-realtime-interface-component -> Ruckig.so -> Stepgen.so -> Lcec.so or: Ros commands -> Your-hal-realtime-interface-component -> Stepgen.so -> Lcec.so

jjrbfi commented 3 years ago

Hi,

Our idea using ROS is to interact with the iCIM robot we have with the EtherCAT terminals. (Read/Write values and set values to the motor encoder to go to whatever position [EL7342])

Right now ROS, is used in researchs as well as a "robot system standard" in many companies. So I guess that if ROS is wrapped into/with HAL, LinuxCNC will be used more in companies that they already have EtherCAT with some proprietaries software.

Same with universities, that are using some software non open source that cost quite a lot and because of the cost, that can't be an option for schools/universities in different countries.

At this point I'm a bit more familiar with HAL and the commands it uses and looks great and works pretty good. But to interact with Gazebo for example, things go a bit more complicated if we use just halcmd commands for example.

My idea at begging was to interact directly with the drivers as I have used before here: rtt_soem (Different EtherCAT master)

But seems to me easier to interact with HAL and them get other drivers compatible with the same approach.

jjrbfi commented 2 years ago

Real-time is enabled since #18 Merge.

Looking forward to interact with it in real-time and them be able to use ROS at some point with it.

jjrbfi commented 2 years ago

Seems like something was working with that EtherCAT master. I will close this.

https://ighmaster-userspace-program-in-ros.readthedocs.io/en/latest/#