Kinematics modification

More
15 Sep 2015 00:37 #62573 by tommy
What would be the proper way to inverse certain axis in kinematics module? I would need to modify 5axiskins.c module:

5axiskins

For now I would have to inverse X axis (joints[0]), as it happens now for example, when apply G0 B40, the X axis moves in wrong direction, and that happens when angular axis require linear axis to move along.
All axis are programmed correctly and are moving correctly as long as G-code is simple 3-axis (X,Y,Z)

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

More
15 Sep 2015 17:38 - 15 Sep 2015 17:39 #62609 by andypugh
Replied by andypugh on topic Kinematics modification
Before modifying the kinematics file, have you tried using a negative pivot-length?

Also, I believe that the 5-axis kinmeatic modules expect the tool length offset to be in the W column of the tool table, not the Z column.
Last edit: 15 Sep 2015 17:39 by andypugh.

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

More
15 Sep 2015 18:34 #62611 by tommy
Replied by tommy on topic Kinematics modification
Will give it a try with negative pivot length, I didn't think of that ....

5axiskins takes tool length from W column of the tool table, which is in my case filled automatically after measuring tool length on tool sensor, and after that G43Hn etc... and this number is added to a number which is already in kinematics module and represents fixed distance of pivot, in my case distance from center of rotation of B-axis to the end of tool holder, so sum of this two numbers should give negative value to try this out.

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

More
16 Sep 2015 21:49 #62641 by tommy
Replied by tommy on topic Kinematics modification
Negative value didn't help... I think I have somewhere else something wrong as also in preview window B-axis moves in opposite direction as it should.
+/- Jog is moving in correct directions for all axes...

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

More
16 Sep 2015 22:00 #62642 by andypugh
Replied by andypugh on topic Kinematics modification

Negative value didn't help..


Ok, then it might be time to modify the kinematics file.
You can probably compile/install it with halcompile.

Do you have the kinematics file, and do you understand it?

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

More
16 Sep 2015 22:38 #62644 by tommy
Replied by tommy on topic Kinematics modification
Kinematics that I use is:
/********************************************************************
* Description: my5axiskins.c
*   Trivial kinematics for 3 axis Cartesian machine
*
*   Derived from a work by Fred Proctor & Will Shackleford
*
* Author:
* License: GPL Version 2
* System: Linux
*    
* Copyright (c) 2007 Chris Radek
*
* Last change:
********************************************************************/

#include "kinematics.h"		/* these decls */
#include "posemath.h"
#include "hal.h"
#include "rtapi_math.h"

#define d2r(d) ((d)*PM_PI/180.0)
#define r2d(r) ((r)*180.0/PM_PI)

struct haldata {
    hal_float_t *tool_length;
    hal_float_t *pivot_length;
} *haldata;

static PmCartesian s2r(double r, double t, double p) {
    PmCartesian c;
    t = d2r(t), p = d2r(p);

    c.x = r * sin(p) * cos(t);
    c.y = r * sin(p) * sin(t);
    c.z = r * cos(p);

    return c;
}

int kinematicsForward(const double *joints,
		      EmcPose * pos,
		      const KINEMATICS_FORWARD_FLAGS * fflags,
		      KINEMATICS_INVERSE_FLAGS * iflags)
{
    PmCartesian r = s2r(*(haldata->pivot_length) + joints[8], joints[5], 180.0 - joints[4]);

    pos->tran.x = joints[0] + r.x;
    pos->tran.y = joints[1] + r.y;
    pos->tran.z = joints[2] + *(haldata->pivot_length) + r.z;
    pos->a = joints[3];
    pos->b = joints[4];
    pos->c = joints[5];
    pos->u = joints[6];
    pos->v = joints[7];
    pos->w = joints[8];

    return 0;
}

int kinematicsInverse(const EmcPose * pos,
		      double *joints,
		      const KINEMATICS_INVERSE_FLAGS * iflags,
		      KINEMATICS_FORWARD_FLAGS * fflags)
{

    PmCartesian r = s2r(*(haldata->pivot_length) + pos->w, pos->c, 180.0 - pos->b);

    joints[0] = pos->tran.x - r.x;
    joints[1] = pos->tran.y - r.y;
    joints[2] = pos->tran.z - *(haldata->pivot_length) - r.z;
    joints[3] = pos->a;
    joints[4] = pos->b;
    joints[5] = pos->c;
    joints[6] = pos->tran.y -r.y;
    joints[7] = pos->v;
    joints[8] = pos->w;

    return 0;
}

/* implemented for these kinematics as giving joints preference */
int kinematicsHome(EmcPose * world,
		   double *joint,
		   KINEMATICS_FORWARD_FLAGS * fflags,
		   KINEMATICS_INVERSE_FLAGS * iflags)
{
    *fflags = 0;
    *iflags = 0;

    return kinematicsForward(joint, world, fflags, iflags);
}

KINEMATICS_TYPE kinematicsType()
{
    return KINEMATICS_BOTH;
}

#include "rtapi.h"		/* RTAPI realtime OS API */
#include "rtapi_app.h"		/* RTAPI realtime module decls */
#include "hal.h"

EXPORT_SYMBOL(kinematicsType);
EXPORT_SYMBOL(kinematicsForward);
EXPORT_SYMBOL(kinematicsInverse);
MODULE_LICENSE("GPL");

int comp_id;
int rtapi_app_main(void) {
    int result;
    comp_id = hal_init("my5axiskins");
    if(comp_id < 0) return comp_id;

    haldata = hal_malloc(sizeof(struct haldata));

    result = hal_pin_float_new("my5axiskins.tooloffset.z", HAL_IN, &(haldata->tool_length), comp_id);
    if(result < 0) goto error;
    result = hal_pin_float_new("my5axiskins.pivot-length", HAL_IO, &(haldata->pivot_length), comp_id);
    if(result < 0) goto error;

    *(haldata->pivot_length) = 100;

    hal_ready(comp_id);
    return 0;

error:
    hal_exit(comp_id);
    return result;
}

void rtapi_app_exit(void) { hal_exit(comp_id); }

compiling is done with:
halcompile --install m5axiskins.c


But I'm a bit cautious about modifying it...

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

More
16 Sep 2015 22:45 #62645 by andypugh
Replied by andypugh on topic Kinematics modification

Kinematics that I use is:
    comp_id = hal_init("my5axiskins");
compiling is done with:
halcompile --install m5axiskins.c

But I'm a bit cautious about modifying it...


You will get hard-to-understand errors if the comp_id and file name don't match.

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

More
16 Sep 2015 23:18 - 16 Sep 2015 23:19 #62646 by tommy
Replied by tommy on topic Kinematics modification
Recently I was checking basic 5axis kinematics with running SIM-5-AXIS configuration and noticed that there also B axis rotates counter clockwise in positive direction (referenced by Y-axis direction), and that is opposite as A and C axis rotation referenced to their center axis ( X and Z)...
Mybe I'm totally wrong, but I think this is the correct (basic) coordinate system with angular axis included:

Last edit: 16 Sep 2015 23:19 by tommy.

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

More
17 Sep 2015 16:28 #62677 by andypugh
Replied by andypugh on topic Kinematics modification

Recently I was checking basic 5axis kinematics with running SIM-5-AXIS configuration and noticed that there also B axis rotates counter clockwise in positive direction (referenced by Y-axis direction), and that is opposite as A and C axis rotation referenced to their center axis ( X and Z)...


The original kins was written (I think) for a turntable-C + tilting head machine which might explain that. I think the sim config is a gantry?

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

More
17 Sep 2015 17:12 #62683 by tommy
Replied by tommy on topic Kinematics modification
SIM config is gantry and also "head-head" design of BC axis (same as mine), so I could use it's kinematics module, except rotation of B-axis should be inverted somehow ...

I know I could invert B-axis with postprocessor but I think it would be better if it is done by kinematics so all angular axis are rotating clockwise.

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

Time to create page: 0.218 seconds
Powered by Kunena Forum