Skip to content

Commit

Permalink
Modify araisrobo repository for compiling with RTAI
Browse files Browse the repository at this point in the history
  • Loading branch information
ARAIS BOROT TECHNOLOGY committed May 8, 2013
1 parent 72e65ba commit da96794
Show file tree
Hide file tree
Showing 18 changed files with 162 additions and 172 deletions.
13 changes: 9 additions & 4 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ endif
ifeq ($(BUILD_SYS),kbuild)

modules:
$(PYTHON) modsilent.py $(MAKE) KBUILD_EXTRA_SYMBOLS=$(moduledir)/Module.symvers -C $(KERNELDIR) SUBDIRS=`pwd` CC=$(CC) V=0 modules
$(PYTHON) modsilent.py $(MAKE) KBUILD_EXTRA_SYMBOLS=$(moduledir)/Module.symvers -C $(KERNELDIR) SUBDIRS=`pwd` CC=$(CC) V=1 modules
-cp Module.symvers *$(MODULE_EXT) ../rtlib/
endif

Expand Down Expand Up @@ -664,7 +664,7 @@ EXTRA_CFLAGS = $(filter-out -ffast-math,$(RTFLAGS)) -D__MODULE__ -I$(BASEPWD) -I
-I$(BASEPWD)/libnml/os_intf -I$(BASEPWD)/libnml/nml -I$(BASEPWD)/libnml/buffer \
-I$(BASEPWD)/libnml/posemath -I$(BASEPWD)/rtapi -I$(BASEPWD)/hal \
-I$(BASEPWD)/emc/nml_intf -I$(BASEPWD)/emc/kinematics -I$(BASEPWD)/emc/motion \
-DSEQUENTIAL_SUPPORT -DHAL_SUPPORT -DDYNAMIC_PLCSIZE -DRT_SUPPORT -DOLD_TIMERS_MONOS_SUPPORT -DMODBUS_IO_MASTER \
-DSEQUENTIAL_SUPPORT -DHAL_SUPPORT -DDYNAMIC_PLCSIZE -DRT_SUPPORT -DOLD_TIMERS_MONOS_SUPPORT -DMODBUS_IO_MASTER \
-fno-fast-math $(call cc-option,-mieee-fp) -fno-unsafe-math-optimizations
#not for sim: $(call cc-option,-Wframe-larger-than=2560)

Expand All @@ -679,7 +679,12 @@ endif
# for libwou
ifneq ($(WOU_VERSION),)
EXTRA_CFLAGS += $(WOU_CFLAGS) -DMOTION_OVER_USB
ifeq ($(BUILD_SYS),sim)
LDFLAGS += $(WOU_LIBS)
else
# for kernel module build:
EXTRA_CFLAGS += -I$(BASEPWD)/hal/drivers/ar-usb
endif
endif


Expand Down Expand Up @@ -932,7 +937,7 @@ modules: $(patsubst %.o,../rtlib/%.so,$(obj-m))
$(Q)ld -r -o objects/$*.tmp $^
@if ! $(IS_POWERPC); then objcopy -j .rtapi_export -O binary objects/$*.tmp objects/$*.exp; fi
@if ! $(IS_POWERPC); then objcopy -G __i686.get_pc_thunk.bx `xargs -r0n1 echo -G < objects/$*.exp | grep -ve '^-G $$' | sort -u` objects/$*.tmp; fi
$(Q)$(CC) -shared -Bsymbolic -o $@ objects/$*.tmp -lm $(LDFLAGS)
$(Q)$(CC) -shared -Bsymbolic $(LDFLAGS) -o $@ objects/$*.tmp -lm

$(sort $(RTDEPS)): depends/rt%.d: %.c
@mkdir -p $(dir $@)
Expand Down Expand Up @@ -965,7 +970,7 @@ $(sort $(RTOBJS)) : objects/rt%.o : %.c

../rtlib/%.o:
$(ECHO) Linking $@
$(Q)ld -r -static -S -Os $(LDFLAGS) -o $@ $^ $(EXTRALINK) $(MATHLIB)
$(Q)ld -r -static -S $(OPT) $(LDFLAGS) -o $@ $^ $(EXTRALINK) $(MATHLIB)
endif

ifneq "$(filter normal sim,$(BUILD_SYS))" ""
Expand Down
77 changes: 0 additions & 77 deletions src/emc/kinematics/align_gantry_kins.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
*
********************************************************************/

#include "string.h"
#include "assert.h"
#include "rtapi_math.h"
#include "kinematics.h" /* these decls */

Expand Down Expand Up @@ -41,17 +39,6 @@ typedef struct {

static align_pins_t *align_pins;

// #define THETA (*(align_pins->theta))
// #define PREV_THETA (align_pins->prev_theta)
// #define PREV_X_OFFSET (align_pins->prev_x_offset)
// #define PREV_Y_OFFSET (align_pins->prev_y_offset)
// #define PREV_X_CENT (align_pins->prev_y_cent)
// #define PREV_Y_CENT (align_pins->prev_x_cent)
// #define X_OFFSET (align_pins->x_offset)
// #define Y_OFFSET (align_pins->y_offset)
// #define X_CENT (align_pins->x_cent)
// #define Y_CENT (align_pins->y_cent)
// #define TOUCH_OFF_CENT (*(align_pins->touch_off_cent))
#define GANTRY_POLARITY (*(align_pins->gantry_polarity))
#define YY_OFFSET (*(align_pins->yy_offset))

Expand All @@ -63,57 +50,19 @@ EXPORT_SYMBOL(kinematicsForward);
EXPORT_SYMBOL(kinematicsInverse);
MODULE_LICENSE("GPL");

// void cord_change_handler(EmcPose * pos, double * joints) {
// // update XYZ position but keep joint position unchanged
// if (TOUCH_OFF_CENT == 1) {
// X_CENT = joints[0];
// Y_CENT = joints[1];
// }
// if (THETA != PREV_THETA ||
// TOUCH_OFF_CENT == 1) {
// if (joints[0] == 0 && joints[1] == 0) {
// return;
// }
// // fprintf(stderr, "THETA(%f)\n", THETA);
// // fprintf(stderr, "x-cent(%f) y-cent(%f) x-offset(%f) y-offset(%f)\n", X_CENT, Y_CENT, X_OFFSET, Y_OFFSET);
// // fprintf(stderr, "1:x(%f) y(%f) \nj0(%f) j1(%f)\n", pos->tran.x, pos->tran.y,
// // joints[0], joints[1]);
// pos->tran.x = (joints[0] - X_CENT - X_OFFSET) * cos(THETA) +
// (joints[1] - Y_CENT - Y_OFFSET) * sin(THETA) + X_OFFSET + X_CENT;
// pos->tran.y = -(joints[0] - X_CENT - X_OFFSET)* sin(THETA) +
// (joints[1] - Y_CENT - Y_OFFSET) * cos(THETA) + Y_OFFSET + Y_CENT;
// // fprintf(stderr, "2:x(%f) y(%f) \nj0(%f) j1(%f)\n", pos->tran.x, pos->tran.y,
// // joints[0], joints[1]);
// PREV_THETA = THETA;
// PREV_X_OFFSET = X_OFFSET;
// PREV_Y_OFFSET = Y_OFFSET;
// PREV_X_CENT = X_CENT;
// PREV_Y_CENT = Y_CENT;
// }
// TOUCH_OFF_CENT = 0;
// }

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

// cord_change_handler((EmcPose *)pos, (double*)joints);
// pos->tran.x = (joints[0] - X_CENT - X_OFFSET) * cos(THETA) +
// (joints[1] - Y_CENT - Y_OFFSET) * sin(THETA) + X_OFFSET + X_CENT;
// pos->tran.y = -(joints[0] - X_CENT - X_OFFSET)* sin(THETA) +
// (joints[1] - Y_CENT - Y_OFFSET) * cos(THETA) + Y_OFFSET + Y_CENT;

pos->tran.x = joints[0];
pos->tran.y = joints[1];
pos->tran.z = joints[3];
pos->a = joints[4];
pos->b = joints[5];
pos->c = joints[6];

// YY_OFFSET = joints[1] - (joints[2] * GANTRY_POLARITY);

DP("kFWD: x(%f), y(%f), j0(%f), j1(%f), j2(%f), yy_offset(%f),POLARITY(%f)\n",
pos->tran.x, pos->tran.y, joints[0], joints[1], joints[2], YY_OFFSET, GANTRY_POLARITY);

Expand All @@ -125,31 +74,6 @@ int kinematicsInverse(const EmcPose * pos,
const KINEMATICS_INVERSE_FLAGS * iflags,
KINEMATICS_FORWARD_FLAGS * fflags)
{
// double c_rad = pos->c*M_PI/180;
// double rad, x_cent, y_cent;
// fprintf(stderr,"kI j0(%f) j1(%f) THETA(%f) X_CENT(%f) Y_CENT(%f)\n",joints[0], joints[1],
// THETA, X_CENT, Y_CENT);
// fprintf(stderr,"KI x(%f) y(%f)\n", pos->tran.x, pos->tran.y);
// if (THETA == PREV_THETA) {
// rad = THETA;
// } else {
// rad = PREV_THETA;
// }
// if (X_CENT == PREV_X_CENT) {
// x_cent = X_CENT;
// } else {
// x_cent = PREV_X_CENT;
// }
// if (Y_CENT == PREV_Y_CENT) {
// y_cent = Y_CENT;
// } else {
// y_cent = PREV_Y_CENT;
// }
// joints[0] = (pos->tran.x - x_cent - X_OFFSET) * cos(rad) -
// (pos->tran.y - y_cent - Y_OFFSET) * sin(rad) + X_OFFSET + x_cent;

// joints[1] = (pos->tran.x - x_cent - X_OFFSET) * sin(rad) +
// (pos->tran.y - y_cent - Y_OFFSET) * cos(rad) + Y_OFFSET + y_cent;
joints[0] = pos->tran.x;
joints[1] = pos->tran.y;
joints[2] = (pos->tran.y - YY_OFFSET) * GANTRY_POLARITY; // YY
Expand All @@ -160,7 +84,6 @@ int kinematicsInverse(const EmcPose * pos,
// joints[6] = pos->u;
// joints[7] = pos->v;
// joints[8] = pos->w;
// fprintf(stderr,"kI j0(%f) j1(%f)\n",joints[0], joints[1]);
DP("kINV: x(%f), y(%f), j0(%f), j1(%f), j2(%f), yy_offset(%f), POLARITY(%f) \n",
pos->tran.x, pos->tran.y, joints[0], joints[1], joints[2], YY_OFFSET, GANTRY_POLARITY);

Expand Down
8 changes: 4 additions & 4 deletions src/emc/kinematics/alignmentkins.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ void cord_change_handler(EmcPose * pos, double * joints) {
Y_OFFSET != PREV_Y_OFFSET ||
X_CENT != PREV_X_CENT ||
Y_CENT != PREV_Y_CENT) {
fprintf(stderr, "THETA(%f)\n", THETA);
fprintf(stderr, "x-cent(%f) y-cent(%f) x-offset(%f) y-offset(%f)\n", X_CENT, Y_CENT, X_OFFSET, Y_OFFSET);
fprintf(stderr, "1:x(%f) y(%f) \nj0(%f) j1(%f)\n", pos->tran.x, pos->tran.y,
DP("THETA(%f)\n", THETA);
DP("x-cent(%f) y-cent(%f) x-offset(%f) y-offset(%f)\n", X_CENT, Y_CENT, X_OFFSET, Y_OFFSET);
DP("1:x(%f) y(%f) \nj0(%f) j1(%f)\n", pos->tran.x, pos->tran.y,
joints[0], joints[1]);
pos->tran.x = (joints[0] - X_CENT - X_OFFSET) * cos(THETA) +
(joints[1] - Y_CENT - Y_OFFSET) * sin(THETA) + X_OFFSET + X_CENT;
pos->tran.y = -(joints[0] - X_CENT - X_OFFSET)* sin(THETA) +
(joints[1] - Y_CENT - Y_OFFSET) * cos(THETA) + Y_OFFSET + Y_CENT;
fprintf(stderr, "2:x(%f) y(%f) \nj0(%f) j1(%f)\n", pos->tran.x, pos->tran.y,
DP("2:x(%f) y(%f) \nj0(%f) j1(%f)\n", pos->tran.x, pos->tran.y,
joints[0], joints[1]);
PREV_THETA = THETA;
PREV_X_OFFSET = X_OFFSET;
Expand Down
9 changes: 9 additions & 0 deletions src/emc/kinematics/dptrace.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef _DPTRACE_H_
#define _DPTRACE_H_

#ifdef SIM

// for simulation only:
#include <stdio.h>

#ifndef TRACE
Expand All @@ -27,4 +30,10 @@
#define DPS(fmt, args...) do {} while(0)
#endif

#else
// NOT-SIM
#define DP(fmt, args...) do {} while(0)
#define DPS(fmt, args...) do {} while(0)
#endif // SIM

#endif // _DPTRACE_H_
24 changes: 22 additions & 2 deletions src/emc/kinematics/tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@
FIXME-- should include <stdlib.h> for sizeof(), but conflicts with
a bunch of <linux> headers
*/

#ifdef RTAPI
#define assert(args...) do {} while(0)
#else
// SIM
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#endif

#include "rtapi.h" /* rtapi_print_msg */
#include "posemath.h"
#include "emcpos.h"
Expand Down Expand Up @@ -62,8 +69,14 @@ void nurbs_basisfun(int i, double u, int p,
int j,r;
double saved, temp;

#ifndef RTAPI
double *left = (double*)malloc(sizeof(double)*(p+1));
double *right = (double*)malloc(sizeof(double)*(p+1));
#else
#warning "to implement rtai_kmalloc() or static memory chunk for left[] and right[]"
double left[4096];
double right[4096];
#endif

N[0] = 1.0;
for (j = 1; j <= p; j++)
Expand All @@ -82,8 +95,12 @@ void nurbs_basisfun(int i, double u, int p,
N[j] = saved;

}
#ifndef RTAPI
free(left);
free(right);
#else
#warning "to implement rtai_kmalloc() or static memory chunk for left[] and right[]"
#endif

}

Expand Down Expand Up @@ -584,9 +601,10 @@ int tcqRemove(TC_QUEUE_STRUCT * tcq, int n)
(n > tcq->_len)) { /* too many requested */
return -1;
}
/* if NURBS ?*/
for(i=tcq->start;i<(tcq->start+n);i++){

#ifndef RTAPI
/* for NURBS only */
for(i=tcq->start;i<(tcq->start+n);i++){
if(tcq->queue[i].motion_type == TC_NURBS) {
//fprintf(stderr,"Remove TCNURBS PARAM\n");
free(tcq->queue[i].nurbs_block.knots_ptr);
Expand All @@ -595,6 +613,8 @@ int tcqRemove(TC_QUEUE_STRUCT * tcq, int n)

}
}
#endif //RTAPI

/* update start ptr and reset allFull flag and len */
tcq->start = (tcq->start + n) % tcq->size;
tcq->allFull = 0;
Expand Down
31 changes: 26 additions & 5 deletions src/emc/kinematics/tp.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
* Copyright (c) 2004 All rights reserved.
********************************************************************/

#ifdef RTAPI
#define assert(args...) do {} while(0)
#else
// SIM
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
#endif

#include "rtapi.h" /* rtapi_print_msg */
#include "rtapi_string.h" /* NULL */
#include "posemath.h"
Expand All @@ -21,16 +31,12 @@
#include "hal.h"
#include "../motion/mot_priv.h"
#include "motion_debug.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

// #undef SMLBLND // turn off seamless blending
#define SMLBLND // to evaluate seamless blending

// to disable DP(): #define TRACE 0
#define TRACE 0
#include <stdint.h>
#include "dptrace.h"
#if (TRACE!=0)
static FILE* dptrace = 0;
Expand Down Expand Up @@ -641,6 +647,12 @@ int tpAddCircle(TP_STRUCT * tp, EmcPose end, PmCartesian center,
// allowed; we are guaranteed to have a move in xyz so target is
// always the circle/arc/helical length.

#ifdef RTAPI
#warning "implement rtai_kmalloc() for nurbs"
static CONTROL_POINT ctrl_pts_array[8192];
static double knots_array[8192];
static double N_array[8192];
#endif

int tpAddNURBS(TP_STRUCT *tp, int type, nurbs_block_t nurbs_block, EmcPose pos,
unsigned char enables, double vel, double ini_maxvel,
Expand Down Expand Up @@ -671,14 +683,23 @@ int tpAddNURBS(TP_STRUCT *tp, int type, nurbs_block_t nurbs_block, EmcPose pos,
nr_of_ctrl_pts = nurbs_block.nr_of_ctrl_pts;
nr_of_knots = nurbs_block.nr_of_knots;


#ifdef RTAPI
#warning "implement rtai_kmalloc() for nurbs"
nurbs_to_tc->ctrl_pts_ptr = ctrl_pts_array;
nurbs_to_tc->knots_ptr = knots_array;
nurbs_to_tc->N = N_array;
#else
// SIM
nurbs_to_tc->ctrl_pts_ptr = (CONTROL_POINT*) malloc(
sizeof(CONTROL_POINT) * nurbs_block.nr_of_ctrl_pts);
nurbs_to_tc->knots_ptr = (double*) malloc(sizeof(double)
* nurbs_block.nr_of_knots);
nurbs_to_tc->N = (double*) malloc(sizeof(double) * (order + 1));
#endif
nurbs_to_tc->axis_mask = nurbs_block.axis_mask;



}
if (knots_todo > 0) {
if (knots_todo > (nr_of_knots - nr_of_ctrl_pts)) { // this part add ctrl pts and knots
Expand Down
11 changes: 10 additions & 1 deletion src/emc/kinematics/yyzzkins.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@
* Copyright (c) 2012 All rights reserved.
********************************************************************/

#ifdef RTAPI
#define assert(args...) do {} while(0)
#else
// SIM
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
#include "string.h"
#include "assert.h"
#endif

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

Expand Down
Loading

0 comments on commit da96794

Please sign in to comment.