Gentlemen,
   I have modified (with Chris' assistance) the 5axiskins.c file
cradek used for the 5axis mill he just added. This works with the
w-tool-length branch. I copied this to his 5axiskins.c file,
recompiled and added setp 5axiskins.baxisX, setp 5axiskins.caxisX,
setp 5axiskins.caxisY, 5axiskins.pivot-length 250 to the 5axis_sim.hal
file.
   This allows geometric compensation.
Given B0 C0:
baxisX is the distance from the centerline of the tool axis to the
actual centerline of rotation of the B axis. We only need 1 value
because the Y axis needs no compensation and the Z axis value is the
distance from the gage point of the spindle taper to the B axis center
line of rotation. I had to negate the value in the parameter to get
the file to work as I wanted. I don't know why.
caxisX and caxisY are the distances from the centerline of rotation of
the B axis to the centerline of rotation of the C axis.
   Comments?
   Thoughts?
   Suggestions?
thanks
Stuart
/********************************************************************
* Description: 5axiskins.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:
* $Revision: 1.5.2.1 $
* $Author: cradek $
* $Date: 2007/11/21 01:18:34 $
********************************************************************/

#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;
    hal_float_t baxisX;
    hal_float_t caxisX;
    hal_float_t caxisY;
} *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;
}

static PmCartesian geocomp(double t, double p, double bx, double cx, double cy) {
    PmCartesian d;
    t = d2r(t), p = d2r(p);

    d.x = ((bx * cos(p)) * cos(t)) + (sqrt((cx * cx) + (cy * cy)) * (cos(atan2((cy),(cx)) + (t))));
    d.y = ((bx * cos(p)) * sin(t)) + (sqrt((cx * cx) + (cy * cy)) * (sin(atan2((cy),(cx)) + (t))));
    d.z = bx * sin(p);

    return d;
}


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);

    PmCartesian s = geocomp(pos->c, 180.0 - pos->b, haldata->baxisX, haldata->caxisX, haldata->caxisY);

    joints[0] = pos->tran.x - r.x + s.x;
    joints[1] = pos->tran.y - r.y + s.y;
    joints[2] = pos->tran.z - haldata->pivot_length - r.z + s.z;
    joints[3] = pos->a;
    joints[4] = pos->b;
    joints[5] = pos->c;
    joints[6] = pos->u;
    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;
}

#ifdef RTAPI
#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("5axiskins");
    if(comp_id < 0) return comp_id;

    haldata = hal_malloc(sizeof(struct haldata));

    result = hal_pin_float_new("5axiskins.tooloffset.z",\
             HAL_IN, &(haldata->tool_length), comp_id);
    if(result < 0) goto error;
    result = hal_param_float_new("5axiskins.pivot-length",\
             HAL_RW, &(haldata->pivot_length), comp_id);
    if(result < 0) goto error;
    result = hal_param_float_new("5axiskins.baxisX",\
             HAL_RW, &(haldata->baxisX), comp_id);
    if(result < 0) goto error;
    result = hal_param_float_new("5axiskins.caxisX",\
             HAL_RW, &(haldata->caxisX), comp_id);
    if(result < 0) goto error;
    result = hal_param_float_new("5axiskins.caxisY",\
             HAL_RW, &(haldata->caxisY), comp_id);
    if(result < 0) goto error;

    haldata->pivot_length = 0.0;
    haldata->baxisX = 0.0;
    haldata->caxisX = 0.0;
    haldata->caxisY = 0.0;

    hal_ready(comp_id);
    return 0;

error:
    hal_exit(comp_id);
    return result;
}

void rtapi_app_exit(void) { hal_exit(comp_id); }
#endif
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to