5 axis kinematics setup

More
10 Nov 2017 14:28 #101606 by agsarg
Hello everyone sorry if this post is repeated but couldn t find the answer, so here it goes:
I m trying to set the 5 axis kinematics looking at the xyzac kins c source code

struct haldata {
hal_float_t *z_offset;
hal_float_t *y_offset;
hal_float_t *tool_offset;
} *haldata;

int kinematicsForward(const double *joints,
EmcPose * pos,
const KINEMATICS_FORWARD_FLAGS * fflags,
KINEMATICS_INVERSE_FLAGS * iflags)
{
double dy = *(haldata->y_offset);
double dz = *(haldata->z_offset);
double dt = *(haldata->tool_offset);
double a_rad = joints[JA]*TO_RAD;
double c_rad = joints[JC]*TO_RAD;

dz = dz + dt;

pos->tran.x = + cos(c_rad) * (joints[JX] )
+ sin(c_rad) * cos(a_rad) * (joints[JY] - dy)
+ sin(c_rad) * sin(a_rad) * (joints[JZ] - dz)
+ sin(c_rad) * dy;

pos->tran.y = - sin(c_rad) * (joints[JX] )
+ cos(c_rad) * cos(a_rad) * (joints[JY] - dy)
+ cos(c_rad) * sin(a_rad) * (joints[JZ] - dz)
+ cos(c_rad) * dy;

pos->tran.z = + 0
- sin(a_rad) * (joints[JY] - dy)
+ cos(a_rad) * (joints[JZ] - dz)
+ dz;

pos->a = joints[JA];
pos->c = joints[JC];

pos->b = 0;
pos->w = 0;
pos->u = 0;
pos->v = 0;

return 0;
}

where dy is the distance from a axis rotation center to c axis rotation center
and dz is the height from c table to a axis rotation center as explained on linuxcnc.org/docs/ja/html/motion/5-axis-kinematics.html

Is tool offset the tool diameter?

now how/where do i declare the offsets values? units for the offsets?

thanks in advance!
Attachments:

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

More
12 Nov 2017 11:10 - 12 Nov 2017 11:12 #101686 by andypugh
Replied by andypugh on topic 5 axis kinematics setup
I would expect "tool offset" to be the tool length. (especially with the line dz = dz + dt)
The offsets appear to come from HAL pins, are any created by the kins module?
Last edit: 12 Nov 2017 11:12 by andypugh.

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

More
13 Nov 2017 18:51 #101739 by agsarg
Replied by agsarg on topic 5 axis kinematics setup
Hi andy thanks for your reply that was the right question so i started looking and found this (think this info it s great to start undertanding the kins source file and hal implementation) github.com/LinuxCNC/linuxcnc/blob/master...-axis-kinematics.txt which basically has all the info for implementing the module. So i followed the steps and added the halpins that are created here

if((res = hal_pin_float_new("xyzac-trt-kins.y-offset",
HAL_IO, &(haldata->y_offset), comp_id)) < 0) goto error;
if((res = hal_pin_float_new("xyzac-trt-kins.z-offset",
HAL_IO, &(haldata->z_offset), comp_id)) < 0) goto error;
if((res = hal_pin_float_new("xyzac-trt-kins.tool-offset",
HAL_IN, &(haldata->tool_offset), comp_id)) < 0) goto error;

to the hal file:

net :tool-offset motion.tooloffset.z xyzac-trt-kins.tool-offset
setp xyzac-trt-kins.y-offset 0
setp xyzac-trt-kins.z-offset 20

Obviously i compiled the module with sudo halcompile --install xyzackins.c (my guess is that it turned out fine as i tested installing
another kinematics module for a 3 axis mill with axis deviation and it worked)

Still when i try to run lcnc i get this:

Debug file information:
.
./my-mill22.hal:4: module 'xyzackins1' not loaded
3847
PID TTY STAT TIME COMMAND
Stopping realtime threads
Unloading hal components
/usr/bin/linuxcnc_module_helper: Invalid usage with args: remove xyzac-trt-kins

Usage: /usr/bin/linuxcnc_module_helper insert /path/to/module.ext [param1=value1 ...]

where module is one of:
rtai_math
rtai_sem
rtai_shm
rtai_fifos
rtai_up
rtai_lxrt
rtai_hal
rtai_sched
rtai_smi
rtai
rt_mem_mgr
adeos

the path starts with one of:
/lib/modules
/usr/realtime-3.4-9-rtai-686-pae

and the extension is one of:
.ko

or the module is in the directory /usr/realtime-3.4-9-rtai-686-pae/modules/linuxcnc

OR

/usr/bin/linuxcnc_module_helper remove module

where module is one of the modules listed above.

<commandline>:0: exit value: 1
<commandline>:0: rmmod failed, returned -1
<commandline>:0: unloadrt failed
Error: Module hal_lib is in use by: xyzackins1
Error: Module rtapi is in use by: hal_lib
Error: Module rtai_sched is in use by: rtapi
Error: Module rtai_hal is in use by: rtapi rtai_sched

the xyzackins.ko (compiled file) is locaded at usr/realtimexxx/modules/linuxcnc with trivkins.ko and all other modules.
"invalid usage with args" don t understand what seems to be the problem here. Thanks everyone ill keep updating as this post may be helpful to fresh boarders.

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

More
13 Nov 2017 19:40 - 13 Nov 2017 19:41 #101744 by andypugh
Replied by andypugh on topic 5 axis kinematics setup

Hi andy thanks for your reply that was the right question so i started looking and found this (think this info it s great to start undertanding the kins source file and hal implementation) github.com/LinuxCNC/linuxcnc/blob/master...-axis-kinematics.txt which basically has all the info for implementing the module.


That file creates this (more legible) documentation section:
linuxcnc.org/docs/devel/html/motion/5-axis-kinematics.html
And there is also this:
linuxcnc.org/docs/2.7/html/motion/kinematics.html

/usr/bin/linuxcnc_module_helper: Invalid usage with args: remove xyzac-trt-kins
.


What does the "loadrt xyzackins-trt" line in the HAL look like, and what does your kinematics file look like?

(It sounds like you are trying to pass command-line parameters to you kins module and it is not expecting them.)
Last edit: 13 Nov 2017 19:41 by andypugh.

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

More
13 Nov 2017 21:11 #101746 by agsarg
Replied by agsarg on topic 5 axis kinematics setup
i replaced the default line
"loadrt trivkins" for "loadrt xyzackins1" as that s the name of the source code i compiled (xyzackins1.c)
even tried adding in the ini file
[KINS]
KINEMATICS = xyzackins1 but the msg error is the same (tried rebooting and replacing the kinematics mod to trivkins
and it worked just fine even removing this part from the ini works fine.

and my kinematics file is the exact one from here github.com/LinuxCNC/linuxcnc/blob/master...ics/xyzac-trt-kins.c
i used the pins as written "xyzac-trt-kins.tool-offset" "xyzac-trt-kins.z-offset" "xyzac-trt-kins.y-offset"
to wire up the hal file

net :tool-offset motion.tooloffset.z xyzac-trt-kins.tool-offset
setp xyzac-trt-kins.y-offset 0
setp xyzac-trt-kins.z-offset 20

being the pin "motion.tooloffset.z" an out pin from motion controller

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

More
13 Nov 2017 22:46 #101749 by andypugh
Replied by andypugh on topic 5 axis kinematics setup
So, you are not actually passing any arguments to xyzackins in the loadrt line?

Which version of LinuxCNC are you using? (I am wondering why you needed to compile a kins module that is a standard part of LinuxCNC)

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

More
14 Nov 2017 13:54 #101776 by agsarg
Replied by agsarg on topic 5 axis kinematics setup
First time i see i have to give command loadusr the arguments for the module i read the hal manual 2.6.13 the loadusr section and kinematics implementation section and didn t found any examples like that. sorry if my questions sound silly

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

More
14 Nov 2017 14:03 #101780 by andypugh
Replied by andypugh on topic 5 axis kinematics setup
It is "loadrt" for a kins module. You can't "loadusr" one, that won't work.
Was that a typo, or is that the problem?

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

More
14 Nov 2017 14:21 #101783 by agsarg
Replied by agsarg on topic 5 axis kinematics setup
just a typo i meant loadrt

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

More
14 Nov 2017 15:01 - 14 Nov 2017 15:02 #101784 by andypugh
Replied by andypugh on topic 5 axis kinematics setup
github.com/LinuxCNC/linuxcnc/blob/9d99a3.../module_helper.c#L78

So, it isn't complaining about command line arguments, sorry about that.
It seems to be a hint that "more info follows" and it might actually be complaining that the kins module can't be removed.
So, then the question has to be why it is trying.

Just as an experiment (I would do this myself, but I am not at a LinuxCNC machine) try the following in a terminal window.

halrun
loadrt trivkins
exit

and then

halrun
loadrt xyza-trtkins
exit

and see if there is a difference in the output.
Last edit: 14 Nov 2017 15:02 by andypugh.

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

Time to create page: 0.088 seconds
Powered by Kunena Forum