motion: allow alt tp,home modules, demo comp files
Squashed commits: =========================================================== A) halcompile.g options for homemod,tpmod 1) supply correct SYNOPSIS 2) force singleton option =========================================================== B) homecomp.comp (example module using halcompile) =========================================================== C) tpcomp.comp (skeleton module using halcompile) =========================================================== D) linuxcnc.in options for alternate tp,home modules =========================================================== E) Make: modular traj planning, homing (tpmod,homemod) 1) motmod no longer includes functions for trajectory planning and homing but uses exported functions from modules tpmod,homemod by default 2) building modules out-of-tree requires: homing.h,emcpose.h 3) sincos.c don't use config.h to allow out-of-tree build =========================================================== docs: tp,home modules
This commit is contained in:
parent
642ec9e23c
commit
08ac87d411
13 changed files with 547 additions and 18 deletions
|
|
@ -97,6 +97,34 @@ HAL Manual. Another chapter of this document will
|
|||
eventually go into the internals of the HAL itself, but in this
|
||||
chapter, we only use the HAL API as defined in src/hal/hal.h.
|
||||
|
||||
=== Motion Controller Modules
|
||||
|
||||
The realtime functions of the motion controller are implemented
|
||||
with modules -- shared objects for rtpreempt systems or kernel
|
||||
modules for some implementations (RTAI):
|
||||
|
||||
* 'tpmod' - trajectory planning
|
||||
|
||||
* 'homemod' - homing functions
|
||||
|
||||
* 'motmod' - processes NML commands and controls hardware via hal
|
||||
|
||||
* 'kinematics module' - performs foward (joints-->coordinates) and
|
||||
inverse (coordinates->joints) kinematics calculations
|
||||
|
||||
LinuxCNC is started by a *linuxcnc* script which reads a
|
||||
configuration ini file and starts all needed processes. For
|
||||
realtime motion control, the script first loads the default tpmod
|
||||
and homemod modules and then loads the kinematics and motion
|
||||
modules according to settings in halfiles specified by the ini
|
||||
file.
|
||||
|
||||
Custom (user-built) homing or trajectory-planning modules can
|
||||
be used in place of the default modules via ini file settings
|
||||
or command line options. Custom modules must implement all
|
||||
functions used by the default modules. The halcompile utility
|
||||
can be used to create a custom module.
|
||||
|
||||
image::LinuxCNC-motion-controller-small.png[align="center"]
|
||||
|
||||
== Block diagrams and Data Flow
|
||||
|
|
|
|||
|
|
@ -669,6 +669,12 @@ Section.
|
|||
realtime part of the motion controller) to acknowledge receipt of
|
||||
messages from Task (the non-realtime part of the motion controller).
|
||||
|
||||
* HOMEMOD = alternate_homing_module [home_parms=value]
|
||||
The HOMEMOD variable is optional. If specified, use a specified (user-built)
|
||||
module instead of the default (homemod). Module parameters (home_parms) may be
|
||||
included if supported by the named module. The setting may be overridden
|
||||
from the command line using the -m option ($linuxcnc -h)
|
||||
|
||||
[[sec:task-section]](((INI File, TASK Section)))
|
||||
|
||||
=== [TASK] Section
|
||||
|
|
@ -1003,6 +1009,10 @@ small, tight corners, since you're limited by cornering acceleration.
|
|||
using identity kinematics without homing ability will need to have this
|
||||
option set to 1.
|
||||
|
||||
[WARNING]
|
||||
|
||||
LinuxCNC will not know your joint travel limits when using 'NO_FORCE_HOMING = 1'.
|
||||
|
||||
* 'HOME = 0 0 0 0 0 0 0 0 0' - World home position needed for kinematics modules
|
||||
that compute world coordinates using kinematicsForward() when switching
|
||||
from joint to teleop mode. Up to nine coordinate values (X Y Z A B C U V W)
|
||||
|
|
@ -1011,8 +1021,11 @@ small, tight corners, since you're limited by cornering acceleration.
|
|||
kinematics (mill, lathe, gantry types) this value is ignored.
|
||||
Note: the sim hexapod config requires a non-zero value for the Z coordinate.
|
||||
|
||||
[WARNING]
|
||||
LinuxCNC will not know your joint travel limits when using 'NO_FORCE_HOMING = 1'.
|
||||
* TPMOD = alternate_trajectory_planning module [tp_parms=value]
|
||||
The TPMOD variable is optional. If specified, use a specified (user-built)
|
||||
module instead of the default (tpmod). Module parameters (tp_parms) may be
|
||||
included if supported by the named module. The setting may be overridden
|
||||
from the command line using the -t option ($linuxcnc -h)
|
||||
|
||||
[[sec:kins-section]](((INI File, KINS Section)))
|
||||
|
||||
|
|
|
|||
|
|
@ -1376,6 +1376,22 @@ The userspace test program has not been actively maintained and
|
|||
its use is deprecated. The ugenserkins.c file may be removed
|
||||
in the future.
|
||||
|
||||
==== Trajectory Planner
|
||||
|
||||
The trajectory planner is now implemented as a loadable module
|
||||
(default:tpmod). An alternate (user-built) planner can be loaded using
|
||||
ini setting [TRAJ]TPMOD= modulename or the 'linuxcnc -t modulename' option.
|
||||
The example file src/hal/components/tpcomp.com illustrates a method for
|
||||
creating a module using halcompile.
|
||||
|
||||
==== Homing
|
||||
|
||||
Homing functions are now implemented by a loadable module
|
||||
(default:homemod). An alternate (user-built) planner can be loaded using
|
||||
ini setting [EMCMOT]HOMEMOD=modulename or the 'linuxcnc -m modulename' option.
|
||||
The example file src/hal/components/homecomp.comp is a minimal example
|
||||
of a homing module that can be built with halcompile.
|
||||
|
||||
==== Other
|
||||
|
||||
lib/hallib/sim_lib.tcl: simulate encoder index if [JOINT_n]HOME_USE_INDEX
|
||||
|
|
|
|||
|
|
@ -325,6 +325,12 @@ The currently defined options are:
|
|||
'no'. When compiling a userspace component, the arguments given are inserted
|
||||
in the compiler command line.
|
||||
|
||||
* 'option homemod yes' - (default: no)
|
||||
Module is a custom Homing module loaded using [EMCMOT]HOMEMOD=modulename
|
||||
|
||||
* 'option tpmod yes' - (default: no)
|
||||
Module is a custom Trajectory Planning (tp) module loaded using [TRAJ]TPMOD=modulename
|
||||
|
||||
If an option's VALUE is not specified, then it is equivalent to
|
||||
specifying 'option … yes'.
|
||||
The result of assigning an inappropriate value to an option is undefined.
|
||||
|
|
|
|||
|
|
@ -11,8 +11,39 @@ linuxcnc [options] [<ini-file>]
|
|||
----
|
||||
|
||||
.linuxcnc script options
|
||||
* '-v' = verbose - prints info as it works
|
||||
* '-d' = echoes script commands to screen for debugging
|
||||
|
||||
----
|
||||
linuxcnc: Run LINUXCNC
|
||||
|
||||
Usage:
|
||||
$ linuxcnc -h
|
||||
This help
|
||||
|
||||
$ linuxcnc [Options]
|
||||
Choose the configuration inifile graphically
|
||||
|
||||
$ linuxcnc [Options] path/to/your_ini_file
|
||||
Name the configuration inifile using its path
|
||||
|
||||
$ linuxcnc [Options] -l
|
||||
Use the previously used configuration inifile
|
||||
|
||||
Options:
|
||||
-d: Turn on "debug" mode
|
||||
-v: Turn on "verbose" mode
|
||||
-k: Continue in the presence of errors in .hal files
|
||||
-t "tpmodulename [parameters]"
|
||||
specify custom trajectory_planning_module
|
||||
overrides optional ini setting [TRAJ]TPMOD
|
||||
-m "homemodulename [parameters]"
|
||||
specify custom homing_module
|
||||
overrides optional ini setting [EMCMOT]HOMEMOD
|
||||
-H "dirname": search dirname for Halfiles before searching
|
||||
ini directory and system library:
|
||||
/home/git/linuxcnc-dev/lib/hallib
|
||||
Note:
|
||||
The -H "dirname" option may be specified multiple times
|
||||
----
|
||||
|
||||
If the linuxcnc script is passed an ini file it reads the ini file and starts
|
||||
LinuxCNC. The ini file [HAL] section specifies the order of loading up HAL
|
||||
|
|
@ -26,7 +57,7 @@ INI configuration for more information.
|
|||
|
||||
=== Configuration Selector
|
||||
|
||||
If no ini file is passed to the linuxcnc script it loads the configuration
|
||||
If no ini file is passed to the linuxcnc script it loads the configuration
|
||||
selector so you can choose and save a sample configuration. Once a sample
|
||||
configuration has been saved it can be modified to suit your application.
|
||||
The configuration files are saved in linuxcnc/configs directory.
|
||||
|
|
|
|||
|
|
@ -113,6 +113,12 @@ Options:
|
|||
-d: Turn on "debug" mode
|
||||
-v: Turn on "verbose" mode
|
||||
-k: Continue in the presence of errors in .hal files
|
||||
-t "tpmodulename [parameters]"
|
||||
specify custom trajectory_planning_module
|
||||
overrides optional ini setting [TRAJ]TPMOD
|
||||
-m "homemodulename [parameters]"
|
||||
specify custom homing_module
|
||||
overrides optional ini setting [EMCMOT]HOMEMOD
|
||||
-H "dirname": search dirname for Halfiles before searching
|
||||
ini directory and system library:
|
||||
$HALLIB_DIR
|
||||
|
|
@ -125,7 +131,7 @@ EOF
|
|||
################################################################################
|
||||
# 1.1. strip and process command line options
|
||||
################################################################################
|
||||
while getopts "dvlhkrH:" opt
|
||||
while getopts "dvlhkrH:t:m:" opt
|
||||
do
|
||||
case "$opt" in
|
||||
d)
|
||||
|
|
@ -159,6 +165,16 @@ do
|
|||
exit 1
|
||||
fi
|
||||
;;
|
||||
t) # -t modname: user-supplied trajectory planning module
|
||||
# modname must conform to tpmod api,
|
||||
# and be located in: $LINUXCNC_RTLIB_DIR
|
||||
TPMOD=$OPTARG
|
||||
;;
|
||||
m) # -m modname: user-supplied homing module
|
||||
# modname must conform to homing api,
|
||||
# and be located in: $LINUXCNC_RTLIB_DIR
|
||||
HOMEMOD=$OPTARG
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
|
|
@ -500,6 +516,18 @@ RS274NGC_PARAMFILE=$retval
|
|||
GetFromIniEx MOT MOT EMCMOT EMCMOT motmod
|
||||
EMCMOT=$retval$MODULE_EXT # add module extension
|
||||
|
||||
# commandline -t option supersedes inifile setting
|
||||
if [ -z "$TPMOD" ] ; then
|
||||
GetFromIni TPMOD TRAJ
|
||||
TPMOD=${retval:-tpmod} #use default if not found
|
||||
fi
|
||||
# commandline -m option supersedes inifile setting
|
||||
if [ -z "$HOMEMOD" ] ; then
|
||||
GetFromIni HOMEMOD EMCMOT
|
||||
HOMEMOD=${retval:-homemod} #use default if not found
|
||||
fi
|
||||
|
||||
|
||||
# 2.4. get io information
|
||||
GetFromIniEx IO IO EMCIO EMCIO io
|
||||
EMCIO=$retval
|
||||
|
|
@ -814,6 +842,10 @@ fi
|
|||
|
||||
# 4.3.6. execute HALCMD config files (if any)
|
||||
|
||||
echo "$(basename $0) TPMOD=$TPMOD HOMEMOD=$HOMEMOD EMCMOT=${EMCMOT%.*}"
|
||||
eval $HALCMD loadrt "$TPMOD"
|
||||
eval $HALCMD loadrt "$HOMEMOD"
|
||||
|
||||
TWOPASS=`$INIVAR -ini "$INIFILE" -var TWOPASS -sec HAL -num 1 2> /dev/null`
|
||||
if [ -n "$TWOPASS" ] ; then
|
||||
# 4.3.6.1. if [HAL]TWOPASS is defined, handle all [HAL]HALFILE entries here:
|
||||
|
|
@ -890,6 +922,7 @@ else
|
|||
done
|
||||
fi
|
||||
|
||||
|
||||
# 4.3.7. Run task in background
|
||||
echo "Starting TASK program: $EMCTASK" >>$PRINT_FILE
|
||||
if ! program_available $EMCTASK ; then
|
||||
|
|
|
|||
28
src/Makefile
28
src/Makefile
|
|
@ -333,6 +333,7 @@ HEADERS := \
|
|||
emc/tp/blendmath.h \
|
||||
emc/motion/emcmotcfg.h \
|
||||
emc/motion/motion.h \
|
||||
emc/motion/homing.h \
|
||||
emc/motion/simple_tp.h \
|
||||
emc/motion/state_tag.h \
|
||||
emc/motion/usrmotintf.h \
|
||||
|
|
@ -344,6 +345,7 @@ HEADERS := \
|
|||
emc/nml_intf/emccfg.h \
|
||||
emc/nml_intf/emcglb.h \
|
||||
emc/nml_intf/emcpos.h \
|
||||
emc/nml_intf/emcpose.h \
|
||||
emc/nml_intf/interp_return.hh \
|
||||
emc/nml_intf/interpl.hh \
|
||||
emc/nml_intf/motion_types.h \
|
||||
|
|
@ -1135,22 +1137,28 @@ obj-m += 5axiskins.o
|
|||
|
||||
obj-$(CONFIG_MOTMOD) += motmod.o
|
||||
motmod-objs := emc/kinematics/cubic.o
|
||||
motmod-objs += emc/tp/tc.o
|
||||
motmod-objs += emc/tp/tcq.o
|
||||
motmod-objs += emc/tp/tp.o
|
||||
motmod-objs += emc/tp/spherical_arc.o
|
||||
motmod-objs += emc/tp/blendmath.o
|
||||
motmod-objs += emc/motion/motion.o
|
||||
motmod-objs += emc/motion/command.o
|
||||
motmod-objs += emc/motion/control.o
|
||||
motmod-objs += emc/motion/homing.o
|
||||
motmod-objs += emc/motion/simple_tp.o
|
||||
motmod-objs += emc/motion/emcmotutil.o
|
||||
motmod-objs += emc/motion/stashf.o
|
||||
motmod-objs += emc/motion/dbuf.o
|
||||
motmod-objs += emc/nml_intf/emcpose.o
|
||||
motmod-objs += libnml/posemath/_posemath.o
|
||||
motmod-objs += libnml/posemath/sincos.o $(MATHSTUB)
|
||||
|
||||
obj-m += homemod.o
|
||||
homemod-objs := emc/motion/homemod.o
|
||||
homemod-objs += emc/motion/homing.o
|
||||
|
||||
obj-m += tpmod.o
|
||||
tpmod-objs := emc/tp/tpmod.o
|
||||
tpmod-objs += emc/tp/tc.o
|
||||
tpmod-objs += emc/tp/tcq.o
|
||||
tpmod-objs += emc/tp/tp.o
|
||||
tpmod-objs += emc/tp/spherical_arc.o
|
||||
tpmod-objs += emc/tp/blendmath.o
|
||||
tpmod-objs += emc/nml_intf/emcpose.o
|
||||
tpmod-objs += libnml/posemath/_posemath.o
|
||||
tpmod-objs += libnml/posemath/sincos.o $(MATHSTUB)
|
||||
|
||||
TORTOBJS = $(foreach file,$($(patsubst %.o,%,$(1))-objs), objects/rt$(file))
|
||||
ifeq ($(BUILD_SYS),uspace)
|
||||
|
|
@ -1239,6 +1247,8 @@ endif
|
|||
../rtlib/scope_rt$(MODULE_EXT): $(addprefix objects/rt,$(scope_rt-objs))
|
||||
../rtlib/hal_lib$(MODULE_EXT): $(addprefix objects/rt,$(hal_lib-objs))
|
||||
../rtlib/motmod$(MODULE_EXT): $(addprefix objects/rt,$(motmod-objs))
|
||||
../rtlib/tpmod$(MODULE_EXT): $(addprefix objects/rt,$(tpmod-objs))
|
||||
../rtlib/homemod$(MODULE_EXT): $(addprefix objects/rt,$(homemod-objs))
|
||||
../rtlib/trivkins$(MODULE_EXT): $(addprefix objects/rt,$(trivkins-objs))
|
||||
../rtlib/5axiskins$(MODULE_EXT): $(addprefix objects/rt,$(5axiskins-objs))
|
||||
../rtlib/maxkins$(MODULE_EXT): $(addprefix objects/rt,$(maxkins-objs))
|
||||
|
|
|
|||
46
src/emc/motion/homemod.c
Normal file
46
src/emc/motion/homemod.c
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
**Notes:
|
||||
** 1) The rtapi_app_main() creates a minimal component (homemod)
|
||||
** allowing use with:
|
||||
** 'halcmd loadrt homemod' (loads module: homemod.so)
|
||||
** 2) homing.c provides all functions required by subsequent load
|
||||
** of motmod
|
||||
*/
|
||||
#include "rtapi.h"
|
||||
#include "rtapi_app.h"
|
||||
#include "hal.h"
|
||||
|
||||
#define HOMEMOD_DEBUG
|
||||
#undef HOMEMOD_DEBUG
|
||||
|
||||
// provision for testing use of module parameters:
|
||||
static char *home_parms;
|
||||
RTAPI_MP_STRING(home_parms,"Example home parms");
|
||||
|
||||
static int homemod_id;
|
||||
int rtapi_app_main(void)
|
||||
{
|
||||
#ifdef HOMEMOD_DEBUG
|
||||
if (home_parms) {
|
||||
rtapi_print("%s:%s: home_parms=%s\n",__FILE__,__FUNCTION__,home_parms);
|
||||
}
|
||||
#endif
|
||||
|
||||
char* emsg;
|
||||
homemod_id = hal_init("homemod"); // dlopen(".../homemod.so")
|
||||
if (homemod_id < 0) {emsg="hal_init()"; goto error;}
|
||||
|
||||
hal_ready(homemod_id);
|
||||
return 0;
|
||||
|
||||
error:
|
||||
rtapi_print_msg(RTAPI_MSG_ERR,"\nhomemod FAIL:<%s>\n",emsg);
|
||||
hal_exit(homemod_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void rtapi_app_exit(void)
|
||||
{
|
||||
hal_exit(homemod_id);
|
||||
return;
|
||||
}
|
||||
46
src/emc/tp/tpmod.c
Normal file
46
src/emc/tp/tpmod.c
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
**Notes:
|
||||
** 1) This rtapi_app_main() creates a minimal component (tpmod)
|
||||
** allowing use with:
|
||||
** 'halcmd loadrt tpmod' (loads module: tpmod.so)
|
||||
** 2) tp.c, tc.c,...,etc provide all functions required by
|
||||
** subsequent load of motmod
|
||||
*/
|
||||
#include "rtapi.h"
|
||||
#include "rtapi_app.h"
|
||||
#include "hal.h"
|
||||
|
||||
#define TPMOD_DEBUG
|
||||
#undef TPMOD_DEBUG
|
||||
|
||||
// provision for testing use of module parameters:
|
||||
static char *tp_parms;
|
||||
RTAPI_MP_STRING(tp_parms,"Example tp parms");
|
||||
|
||||
static int tpmod_id;
|
||||
int rtapi_app_main(void)
|
||||
{
|
||||
#ifdef TPMOD_DEBUG
|
||||
if (tp_parms) {
|
||||
rtapi_print("%s:%s: tp_parms=%s\n",__FILE__,__FUNCTION__,tp_parms);
|
||||
}
|
||||
#endif
|
||||
|
||||
char* emsg;
|
||||
tpmod_id = hal_init("tpmod"); // dlopen(".../tpmod.so")
|
||||
if (tpmod_id < 0) {emsg="hal_init()"; goto error;}
|
||||
|
||||
hal_ready(tpmod_id);
|
||||
return 0;
|
||||
|
||||
error:
|
||||
rtapi_print_msg(RTAPI_MSG_ERR,"\ntpmod FAIL:<%s>\n",emsg);
|
||||
hal_exit(tpmod_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void rtapi_app_exit(void)
|
||||
{
|
||||
hal_exit(tpmod_id);
|
||||
return;
|
||||
}
|
||||
201
src/hal/components/homecomp.comp
Normal file
201
src/hal/components/homecomp.comp
Normal file
|
|
@ -0,0 +1,201 @@
|
|||
component homecomp"homing module template";
|
||||
|
||||
description """
|
||||
Example of a homing module buildable with halcompile.
|
||||
Demonstrates required code for #includes, function definitions, etc.
|
||||
|
||||
An actual homing scheme is \\fBnot\\fR implemented but all necessary
|
||||
functions are included as skeleton code. (All joints are
|
||||
effectively homed at all times and cannot be unhomed).
|
||||
|
||||
See the source code file: src/emc/motion/homing.c for the baseline
|
||||
implementation that includes all functions for the default \\fBhomemod\\fR
|
||||
module.
|
||||
|
||||
To avoid updates that overwrite homecomp.comp, best practice is
|
||||
to rename the file and its component name (example:
|
||||
\\fBuser_homecomp.comp, user_homecomp\\fR).
|
||||
|
||||
The (renamed) component can be built and installed with
|
||||
halcompile and then substituted for the default homing module
|
||||
(\\fBhomemod\\fR) using:\n
|
||||
$ linuxcnc \\fB-m user_homecomp\\fR someconfig.ini\n
|
||||
or by inifile setting: \\fB[EMCMOT]HOMEMOD=user_homecomp\\fR
|
||||
|
||||
\\fBNote:\\fRIf using a deb install:\n
|
||||
1) halcompile is provided by the package linuxcnc-dev\n
|
||||
2) This source file for BRANCHNAME (master,2.9,etc) is downloadable from github:\n
|
||||
https://github.com/LinuxCNC/linuxcnc/blob/BRANCHNAME/src/hal/components/homecomp.comp
|
||||
""";
|
||||
|
||||
pin out bit is_module=1; //one pin is required to use halcompile)
|
||||
|
||||
license "GPL";
|
||||
option homemod;
|
||||
option extra_setup;
|
||||
;;
|
||||
|
||||
#include "motion.h"
|
||||
#include "homing.h"
|
||||
|
||||
static char *home_parms;
|
||||
RTAPI_MP_STRING(home_parms,"Example home parms");
|
||||
|
||||
// rtapi_app_main() supplied by halcompile
|
||||
// EXTRA_SETUP is executed before rtapi_app_main()
|
||||
EXTRA_SETUP() {
|
||||
if (!home_parms) {home_parms = "no_home_parms";}
|
||||
rtapi_print("@@@%s:%s: home_parms=%s\n",__FILE__,__FUNCTION__,home_parms);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// retrieved from motmod.so:
|
||||
static emcmot_config_t *emcmotConfig;
|
||||
static emcmot_joint_t *joints;
|
||||
|
||||
//========================================================
|
||||
// motmod function ptrs for functions called BY homecomp:
|
||||
static void(*SetRotaryUnlock)(int,int);
|
||||
static int (*GetRotaryIsUnlocked)(int);
|
||||
|
||||
//========================================================
|
||||
// functions ptrs received from motmod:
|
||||
void homeMotFunctions(void(*pSetRotaryUnlock)(int,int)
|
||||
,int (*pGetRotaryIsUnlocked)(int)
|
||||
)
|
||||
{
|
||||
SetRotaryUnlock = *pSetRotaryUnlock;
|
||||
GetRotaryIsUnlocked = *pGetRotaryIsUnlocked;
|
||||
}
|
||||
|
||||
// emcmot pointers received from motmod
|
||||
void homeMotData(emcmot_config_t * pconfig
|
||||
,emcmot_joint_t * pjoints
|
||||
)
|
||||
{
|
||||
emcmotConfig = pconfig;
|
||||
joints = pjoints;
|
||||
}
|
||||
//========================================================
|
||||
|
||||
// data for per-joint homing-specific hal pins:
|
||||
typedef struct {
|
||||
hal_bit_t *home_sw; // home switch input
|
||||
hal_bit_t *homing; // joint is homing
|
||||
hal_bit_t *homed; // joint was homed
|
||||
hal_bit_t *index_enable; // motmod sets: request reset on index
|
||||
// encoder clears: index arrived
|
||||
hal_s32_t *home_state; // homing state machine state
|
||||
} one_joint_home_data_t;
|
||||
|
||||
typedef struct {
|
||||
one_joint_home_data_t jhd[EMCMOT_MAX_JOINTS];
|
||||
} all_joints_home_data_t;
|
||||
|
||||
static all_joints_home_data_t *joint_home_data = 0;
|
||||
|
||||
static int makepins(int id,int njoints)
|
||||
{
|
||||
// home_pins needed to work with configs expecting them:
|
||||
int jno,retval;
|
||||
one_joint_home_data_t *addr;
|
||||
|
||||
joint_home_data = hal_malloc(sizeof(all_joints_home_data_t));
|
||||
if (joint_home_data == 0) {
|
||||
rtapi_print_msg(RTAPI_MSG_ERR, "HOMING: all_joints_home_data_t malloc failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
retval = 0;
|
||||
for (jno = 0; jno < njoints; jno++) {
|
||||
addr = &(joint_home_data->jhd[jno]);
|
||||
|
||||
retval += hal_pin_bit_newf(HAL_IN, &(addr->home_sw), id,
|
||||
"joint.%d.home-sw-in", jno);
|
||||
retval += hal_pin_bit_newf(HAL_OUT, &(addr->homing), id,
|
||||
"joint.%d.homing", jno);
|
||||
retval += hal_pin_bit_newf(HAL_OUT, &(addr->homed), id,
|
||||
"joint.%d.homed", jno);
|
||||
retval += hal_pin_s32_newf(HAL_OUT, &(addr->home_state), id,
|
||||
"joint.%d.home-state", jno);
|
||||
retval += hal_pin_bit_newf(HAL_IO, &(addr->index_enable), id,
|
||||
"joint.%d.index-enable", jno);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
//========================================================
|
||||
// All functions required for homing api
|
||||
// For homecomp.comp: most are skeleton
|
||||
|
||||
bool do_homing(void) {return 1;}
|
||||
void do_homing_sequence(void) {return;}
|
||||
bool get_allhomed() {return 1;}
|
||||
bool get_homed(int jno) {return 1;}
|
||||
bool get_home_is_idle(int jno) {return 1;}
|
||||
bool get_home_is_synchronized(int jno) {return 0;}
|
||||
bool get_home_is_volatile(int jno) {return 0;}
|
||||
bool get_home_needs_unlock_first(int jno) {return 0;}
|
||||
int get_home_sequence(int jno) {return 0;}
|
||||
home_sequence_state_t get_home_sequence_state() {return HOME_SEQUENCE_IDLE;}
|
||||
bool get_homing(int jno) {return 0;}
|
||||
bool get_homing_at_index_search_wait(int jno) {return 0;}
|
||||
bool get_homing_is_active() {return 0;}
|
||||
int homing_init(int id,int njoints) {return makepins(id,njoints);}
|
||||
bool get_index_enable(int jno) {return 0;}
|
||||
void read_homing_in_pins(int njoints) {return;}
|
||||
void set_home_abort(int jno) {return;}
|
||||
void set_home_idle(int jno) {return;}
|
||||
void set_home_sequence_state(home_sequence_state_t s_state) {return;}
|
||||
void set_home_start(int jno) {return;}
|
||||
void set_joint_at_home(int jno, bool value) {return;}
|
||||
void set_joint_homed(int jno,bool value) {return;}
|
||||
void set_joint_homing(int jno,bool value) {return;}
|
||||
void set_joint_homing_params(int jno,
|
||||
double offset,
|
||||
double home,
|
||||
double home_final_vel,
|
||||
double home_search_vel,
|
||||
double home_latch_vel,
|
||||
int home_flags,
|
||||
int home_sequence,
|
||||
bool volatile_home
|
||||
) {return;}
|
||||
void update_joint_homing_params (int jno,
|
||||
double offset,
|
||||
double home,
|
||||
int home_sequence
|
||||
) {return;}
|
||||
void write_homing_out_pins(int njoints) {return;}
|
||||
|
||||
//========================================================
|
||||
// all home functions for homing api
|
||||
EXPORT_SYMBOL(homeMotFunctions);
|
||||
EXPORT_SYMBOL(homeMotData);
|
||||
|
||||
EXPORT_SYMBOL(do_homing);
|
||||
EXPORT_SYMBOL(do_homing_sequence);
|
||||
EXPORT_SYMBOL(get_allhomed);
|
||||
EXPORT_SYMBOL(get_homed);
|
||||
EXPORT_SYMBOL(get_home_is_idle);
|
||||
EXPORT_SYMBOL(get_home_is_synchronized);
|
||||
EXPORT_SYMBOL(get_home_is_volatile);
|
||||
EXPORT_SYMBOL(get_home_needs_unlock_first);
|
||||
EXPORT_SYMBOL(get_home_sequence);
|
||||
EXPORT_SYMBOL(get_home_sequence_state);
|
||||
EXPORT_SYMBOL(get_homing);
|
||||
EXPORT_SYMBOL(get_homing_at_index_search_wait);
|
||||
EXPORT_SYMBOL(get_homing_is_active);
|
||||
EXPORT_SYMBOL(get_index_enable);
|
||||
EXPORT_SYMBOL(homing_init);
|
||||
EXPORT_SYMBOL(read_homing_in_pins);
|
||||
EXPORT_SYMBOL(set_home_abort);
|
||||
EXPORT_SYMBOL(set_home_idle);
|
||||
EXPORT_SYMBOL(set_home_sequence_state);
|
||||
EXPORT_SYMBOL(set_home_start);
|
||||
EXPORT_SYMBOL(set_joint_at_home);
|
||||
EXPORT_SYMBOL(set_joint_homed);
|
||||
EXPORT_SYMBOL(set_joint_homing);
|
||||
EXPORT_SYMBOL(set_joint_homing_params);
|
||||
EXPORT_SYMBOL(update_joint_homing_params);
|
||||
EXPORT_SYMBOL(write_homing_out_pins);
|
||||
94
src/hal/components/tpcomp.comp
Normal file
94
src/hal/components/tpcomp.comp
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
component tpcomp"Trajectory Planning (tp) module skeleton";
|
||||
// NOTE: component name must agree with filename
|
||||
|
||||
description """
|
||||
Example of a trajectory planning (tp) module buildable with
|
||||
halcompile.
|
||||
|
||||
The tpcomp.comp file (src/hal/components/tpcomp.comp)
|
||||
illustrates a method to use halcompile to build a
|
||||
trajectory planning module based on the files used for the
|
||||
default trajectory planner (\\fBtpmod\\fR).
|
||||
|
||||
The example tpcomp.comp is not usable until modified
|
||||
for the user environment. To create a runnable tpcomp
|
||||
module, the tpcomp.comp file must be edited to supply 1) a
|
||||
valid '#define TOPDIR' and 2) references to valid source
|
||||
code file names for all files used.
|
||||
|
||||
To avoid updates that overwrite tpcomp.comp, best practice is
|
||||
to rename the file and its component name (example:
|
||||
\\fBuser_tpcomp.comp\\fR creates module: \\fBuser_tpcomp\\fR).
|
||||
|
||||
The (renamed) component can be built and installed with
|
||||
halcompile and then substituted for the default tp module
|
||||
(\\fBtpmod\\fR) using:\n
|
||||
$ linuxcnc \\fB-t user_tpcomp\\fR someconfig.ini\n
|
||||
or by inifile setting: \\fB[TRAJ]TPMOD=user_tpcomp\\fR
|
||||
|
||||
\\fBNote:\\fRIf using a deb install:\n
|
||||
1) halcompile is provided by the deb package linuxcnc-dev\n
|
||||
2) This source file for BRANCHNAME (master,2.9,etc) is downloadable from github:\n
|
||||
https://github.com/LinuxCNC/linuxcnc/blob/BRANCHNAME/src/hal/components/tpcomp.comp
|
||||
""";
|
||||
|
||||
pin out bit is_module=1; //one pin is required to use halcompile)
|
||||
|
||||
license "GPL";
|
||||
option tpmod;
|
||||
option extra_setup;
|
||||
;;
|
||||
|
||||
//=====================================================================
|
||||
/* To use trajectory planner (tp) files from a local git src tree:
|
||||
** set TOPDIR to the git src tree top directory
|
||||
** (Edit 'myname' as required)
|
||||
*/
|
||||
|
||||
//#define TOPDIR /home/myname/linuxcnc-dev
|
||||
|
||||
#ifdef TOPDIR // {
|
||||
/* To use a modified file from the src tree substitute as reqd.
|
||||
** Example (comment out standard file, add new one):
|
||||
** // #include USE_TOPDIR(src/emc/tp/tp.c)
|
||||
** #include "somepath/mymodified_tp.c
|
||||
*/
|
||||
|
||||
#define STR(s) #s
|
||||
#define XSTR(s) STR(s)
|
||||
#define USE_TOPDIR(b) XSTR(TOPDIR/b)
|
||||
|
||||
#include USE_TOPDIR(src/emc/tp/tp.c)
|
||||
#include USE_TOPDIR(src/emc/tp/tc.c)
|
||||
#include USE_TOPDIR(src/emc/tp/tcq.c)
|
||||
#include USE_TOPDIR(src/emc/tp/spherical_arc.c)
|
||||
#include USE_TOPDIR(src/emc/tp/blendmath.c)
|
||||
#include USE_TOPDIR(src/emc/nml_intf/emcpose.c)
|
||||
#include USE_TOPDIR(src/libnml/posemath/_posemath.c)
|
||||
#include USE_TOPDIR(src/libnml/posemath/sincos.c)
|
||||
|
||||
#endif // }
|
||||
//=====================================================================
|
||||
|
||||
// Example module parameters (RTAPI_MP_STRING,RTAPI_MP_INT,...)
|
||||
// that can be passed to custom tp files
|
||||
static char *tp_parms;
|
||||
RTAPI_MP_STRING(tp_parms,"Example tp parms");
|
||||
|
||||
// rtapi_app_main() supplied by halcompile
|
||||
// EXTRA_SETUP is executed before rtapi_app_main()
|
||||
EXTRA_SETUP() {
|
||||
#ifndef TOPDIR
|
||||
#warning No TOPDIR defined, module provides no tp functions
|
||||
rtapi_print("\n%s Using default tp functions\n",__FILE__);
|
||||
#else
|
||||
rtapi_print("\n%s TOPDIR=%s\n",__FILE__,XSTR(TOPDIR));
|
||||
#endif
|
||||
if (!tp_parms) {tp_parms="no_tp_parms";}
|
||||
rtapi_print("@@@%s:%s: tp_parms=%s\n",__FILE__,__FUNCTION__,tp_parms);
|
||||
return 0;
|
||||
}
|
||||
#undef USE_TOPDIR
|
||||
#undef XSTR
|
||||
#undef STR
|
||||
#undef TOPDIR
|
||||
|
|
@ -907,7 +907,11 @@ def document(filename, outfilename):
|
|||
print(rest, file=f)
|
||||
else:
|
||||
print(".HP", file=f)
|
||||
if options.get("singleton") or options.get("count_function"):
|
||||
if options.get("homemod"):
|
||||
print("Custom Homing module loaded with \\fB[EMCMOT]HOMEMOD=%s\\fR"%comp_name, file=f)
|
||||
elif options.get("tpmod"):
|
||||
print("Custom Trajectory Planning module loaded with \\fB[TRAJ]TPMOD=%s\\fR"%comp_name, file=f)
|
||||
elif options.get("singleton") or options.get("count_function"):
|
||||
if has_personality:
|
||||
print(".B loadrt %s personality=\\fIP\\fB" % comp_name, end='', file=f)
|
||||
else:
|
||||
|
|
@ -1042,6 +1046,9 @@ def process(filename, mode, outfilename):
|
|||
|
||||
f = open(outfilename, "w")
|
||||
|
||||
if options.get("homemod"): options["singleton"] = 1
|
||||
if options.get("tpmod"): options["singleton"] = 1
|
||||
|
||||
if options.get("userinit") and not options.get("userspace"):
|
||||
print("Warning: comp '%s' sets 'userinit' without 'userspace', ignoring" % filename, file=sys.stderr)
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@
|
|||
21-Jan-2004 P.C. Moved across from the original EMC source tree.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "rtapi_math.h"
|
||||
#include "sincos.h"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue