switchkins - using own kinematics module as kinstype=2

  • mittim
  • mittim's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
23 Jul 2022 19:01 #248134 by mittim
Hey there,

i want to use switchkins with my own kinematics module.

Currently I am using xyzac-trt-kins and it is working fine. In addition i want to use switchkins with my own kinematics module named "userkfuncs.c".

1. What do I need to change in the "userkfuncs.c" for switchkins to use it as kinsytpe=2?
2. In which directory do I put the "userkfuncs.c" file?
3. How do I compile the "userkfuncs.c" file?

Any help is appreciated, thanks!

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

More
23 Jul 2022 22:37 #248146 by dgarrett
Ref: linuxcnc.org/docs/devel/html/motion/switchkins.html
> 6. User kinematics provisions
>
> Custom kinematics can be coded and tested on
> Run-In-Place (RIP) builds. A template file
> src/emc/kinematics/userkfuncs.c is provided in the
> distribution. This file can be copied/renamed to
> a user directory and edited to supply custom
> kinematics with kinstype==2.
>
> The user custom kinematics file can be compiled
> from out-of-tree source locations for rt-preempt
> implementations or by replacing the in-tree
> template file (src/emc/kinematics/userkfuncs.c)
> for rtai systems.
>
> Preempt-rt make example:
>
> $ userkfuncs=/home/myname/kins/mykins.c make && sudo make setuid



Example:
$ mkdir /tmp/test ;# anywhere you want
$
$ cd your_LINUXCNC_GIT_TOP_DIRECORY
$ cd src
$ cp emc/kinematics/userkfuncs.c /tmp/test/try.c
$
$ # edit /tmp/test/try.c
$ # show your edits:
$ diff emc/kinematics/userkfuncs.c /tmp/test/try.c
diff emc/kinematics/userkfuncs.c /tmp/test/try.c
55a56
> rtapi_print("*************HELLO %s %d\n",__FILE__,__LINE__);
$
$ # build:
$ userkfuncs=/tmp/test/try.c make && sudo make setuid
Reading 205/205 dependency files
Done reading dependencies
!!!USERKFUNCS=/tmp/test/try.o
...
Linking ../rtlib/xyzac-trt-kins.so
...
$ # test:
$ halrun
halcmd: loadrt xyzac-trt-kins
Note: Using POSIX realtime
...
userkKinematicsSetup:
/tmp/test/try.c <xyzac> max_joints=16 allow_duplicates=1

*************HELLO /tmp/test/try.c 56
...
The following user(s) said Thank You: tommylight

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

  • mittim
  • mittim's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
20 Aug 2022 16:44 - 20 Aug 2022 16:47 #250112 by mittim
what I tried: sudo userkfuncs=/home/tim/linuxcnc-dev/custom_kinematics/userkfuncs.c make && sudo make setuid

When I want to comile the file I am getting the following error message:

"Es wurden keine Ziele angegeben und keine make Steuerdatei gefunden"

translation: "no directory assigned and no make file found"

What am I doing wrong?
Last edit: 20 Aug 2022 16:47 by mittim.

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

  • tommylight
  • tommylight's Avatar
  • Away
  • Moderator
  • Moderator
More
22 Aug 2022 16:54 #250218 by tommylight

what I tried: sudo userkfuncs=/home/tim/linuxcnc-dev/custom_kinematics/userkfuncs.c make && sudo make setuid

When I want to comile the file I am getting the following error message:

"Es wurden keine Ziele angegeben und keine make Steuerdatei gefunden"

translation: "no directory assigned and no make file found"

What am I doing wrong?

This quote was used to start a new topic, so it was deleted after some consultation.
--
Back on topic:
The error :"no directory assigned and no make file found" is usually due to starting a compile in the wrong directory, so going back one level and running the compile again usually works.

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

  • mittim
  • mittim's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
23 Aug 2022 14:32 #250259 by mittim
I edited the "userkfuncs.c" file to my needs and build linuxcnc again. Everything compiles and builds fine without error messages.

I want to use userkfuncs as kinstype==2. But when switching, my kinematics module is not working. Any ideas?
Attachments:

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

  • Aciera
  • Aciera's Avatar
  • Away
  • Administrator
  • Administrator
More
23 Aug 2022 19:06 #250277 by Aciera
So when you switch to kinstype==2 do you get any information in the terminal about what is happening?
Have you verified in halshow that the kinstype pin has actually changed it's value to "2"?

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

  • mittim
  • mittim's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
26 Aug 2022 09:23 - 26 Aug 2022 10:03 #250499 by mittim
Thanks for your help Aciera,

I managed to set up userkfuncs.c as my switchkinstype 2.

But there is still one problem I am facing. I want to adjust the xyzac-trt-kins (switchkins type 0) to my needs (reducing the TCP to my geomtrical machine rrors only).
So, to test, whether I am on the right path, I used the trtfuncs.c kinematics in my userkfuncs.c module. The problem is, that the macine is still in identity kinematics when changing to switchkins-type 2.

To make my problem clerar:
1. In which module is the TCP kinematics beeing calculated?
2. Why does switchkinstype 2 not use TCP, when I am using trtfuncs.c code?
3. Is there an example, where someone has written his own kinematics module or adjusted one to his needs?

I attached the userkfuncs.c file, which I am trying to use.
Attachments:
Last edit: 26 Aug 2022 10:03 by mittim.

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

  • Aciera
  • Aciera's Avatar
  • Away
  • Administrator
  • Administrator
More
26 Aug 2022 14:56 #250517 by Aciera
1. I presume the calculation is in "trtfuncs.c"

2. I have a feeling that your custom userfuncs.c might not get called that is why I suggested to verify that the hal pin "kinstype_is_2" is indeed "true".

3. I don't know of any examples using the "userfuncs.c" template. But I have created custom kinematics using the "userkins.comp" template (see "configs/sim/axis/vismach/millturn" the corresponding "millturn.comp" is here github.com/LinuxCNC/linuxcnc/blob/master...onents/millturn.comp
The following user(s) said Thank You: mittim

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

  • mittim
  • mittim's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
26 Aug 2022 15:04 #250518 by mittim
I have checked the hal pin and it is kinstype_is_2 that becomes true with my command: setp motion.switchkins-type 2.

Is it possible to change the trtfuncs.c file and build linuxcnc again? (I know that may cause problems in the future)

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

  • Aciera
  • Aciera's Avatar
  • Away
  • Administrator
  • Administrator
More
26 Aug 2022 15:07 #250519 by Aciera

Is it possible to change the trtfuncs.c file and build linuxcnc again?

Yes that should work.

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

Time to create page: 0.069 seconds
Powered by Kunena Forum