Skip to content

Commit 165571e

Browse files
committed
Remove the hardcoded kinematics_type_id_t enum that prevented custom
kinematics modules from working with planner type 2. Each kinematics module now ships a <name>_userspace.so plugin loaded via dlopen at init time, so built-in and custom modules are treated identically. - Add kins_plugin.h defining the plugin API (kins_userspace_setup) - Extract 17 built-in kinematics into self-contained plugin .so files - Rewrite kinematics_user.c as a dlopen loader (~280 lines, was ~1500) - Remove kinematics_type_id_t enum, type_id field, and dispatch switch - Remove kins_type_id from emcmot_config_t (shared memory layout change) - Fall back to planner type 0 if plugin .so not found Requires make clean (shared memory struct changed).
1 parent 495a262 commit 165571e

26 files changed

Lines changed: 1367 additions & 1382 deletions

src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ SUBDIRS := \
182182
emc/usr_intf/gremlin emc/usr_intf/gscreen emc/usr_intf/pyui emc/usr_intf/qtvcp \
183183
emc/usr_intf/gmoccapy emc/usr_intf/qtplasmac emc/usr_intf/mdro\
184184
emc/usr_intf emc/nml_intf emc/task emc/kinematics emc/tp emc/canterp \
185-
emc/motion emc/motion_planning emc/ini emc/rs274ngc emc/sai emc/pythonplugin \
185+
emc/motion emc/motion_planning emc/kinematics_userspace emc/ini emc/rs274ngc emc/sai emc/pythonplugin \
186186
emc/motion-logger \
187187
emc/tooldata \
188188
emc \

src/emc/ini/initraj.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,7 @@ static int loadTraj(EmcIniFile *trajInifile)
256256
return -1;
257257
}
258258

259-
rcs_print("Detected kinematics module: %s (type_id=%d)\n",
260-
kins_module, emcmotConfig->kins_type_id);
259+
rcs_print("Detected kinematics module: %s\n", kins_module);
261260

262261
// Get configuration from INI file
263262
auto coord = trajInifile->Find("COORDINATES", "TRAJ");
@@ -268,11 +267,14 @@ static int loadTraj(EmcIniFile *trajInifile)
268267
if (motion_planning::userspace_kins_init(kins_module,
269268
joints,
270269
coord ? coord->c_str() : "XYZ") != 0) {
271-
rcs_print_error("ERROR: Failed to initialize userspace kinematics\n");
272-
return -1;
270+
rcs_print_error("WARNING: Failed to initialize userspace kinematics for '%s'\n",
271+
kins_module);
272+
rcs_print_error(" Falling back to PLANNER_TYPE 0 (trapezoidal)\n");
273+
planner_type = 0;
274+
} else {
275+
rcs_print("Userspace kinematics initialized (module=%s, joints=%d, coords=%s)\n",
276+
kins_module, joints, coord ? coord->c_str() : "XYZ");
273277
}
274-
rcs_print("Userspace kinematics initialized (module=%s, joints=%d, coords=%s)\n",
275-
kins_module, joints, coord ? coord->c_str() : "XYZ");
276278
}
277279

278280
// Parse 9D-specific parameters
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Submakefile for userspace kinematics plugins
2+
# Each plugin is a self-contained .so loaded via dlopen by the planner
3+
4+
INCLUDES += emc/kinematics_userspace
5+
6+
KINS_PLUGIN_DIR := emc/kinematics_userspace/plugins
7+
KINS_PLUGIN_OUTDIR := ../lib/kinematics
8+
9+
# Simple plugins (no libposemath dependency)
10+
KINS_SIMPLE_PLUGINS := \
11+
trivkins \
12+
5axiskins \
13+
xyzac-trt-kins \
14+
xyzbc-trt-kins \
15+
maxkins \
16+
tripodkins \
17+
lineardeltakins \
18+
rotarydeltakins \
19+
rosekins \
20+
corexykins \
21+
rotatekins \
22+
scarakins \
23+
scorbot-kins
24+
25+
# Complex plugins (need libposemath for posemath types/functions)
26+
KINS_POSEMATH_PLUGINS := \
27+
pumakins \
28+
genhexkins \
29+
pentakins \
30+
genserkins
31+
32+
KINS_ALL_PLUGINS := $(KINS_SIMPLE_PLUGINS) $(KINS_POSEMATH_PLUGINS)
33+
34+
# Register all plugin sources
35+
KINS_PLUGIN_SRCS := $(foreach p,$(KINS_ALL_PLUGINS),$(KINS_PLUGIN_DIR)/$(p)_userspace.c)
36+
USERSRCS += $(KINS_PLUGIN_SRCS)
37+
38+
# Compile flags for all plugins
39+
$(call TOOBJSDEPS, $(KINS_PLUGIN_SRCS)) : EXTRAFLAGS=-fPIC -DUSERSPACE_LIB_BUILD -D_GNU_SOURCE
40+
41+
# Build rules for simple plugins (link with -lm only)
42+
$(foreach p,$(KINS_SIMPLE_PLUGINS),$(eval \
43+
$(KINS_PLUGIN_OUTDIR)/$(p)_userspace.so: objects/$(KINS_PLUGIN_DIR)/$(p)_userspace.o ; \
44+
$$(ECHO) Building kinematics plugin $$(notdir $$@) ; \
45+
mkdir -p $(KINS_PLUGIN_OUTDIR) ; \
46+
$$(CC) -g $$(LDFLAGS) -shared -o $$@ $$< -lm \
47+
))
48+
49+
# Build rules for posemath plugins (link with -lm and libposemath)
50+
$(foreach p,$(KINS_POSEMATH_PLUGINS),$(eval \
51+
$(KINS_PLUGIN_OUTDIR)/$(p)_userspace.so: objects/$(KINS_PLUGIN_DIR)/$(p)_userspace.o ../lib/libposemath.so ; \
52+
$$(ECHO) Building kinematics plugin $$(notdir $$@) ; \
53+
mkdir -p $(KINS_PLUGIN_OUTDIR) ; \
54+
$$(CC) -g $$(LDFLAGS) -shared -o $$@ $$< -lm -L../lib -lposemath \
55+
))
56+
57+
# All plugin .so targets
58+
KINS_PLUGIN_TARGETS := $(foreach p,$(KINS_ALL_PLUGINS),$(KINS_PLUGIN_OUTDIR)/$(p)_userspace.so)
59+
TARGETS += $(KINS_PLUGIN_TARGETS)

0 commit comments

Comments
 (0)