Import LinuxCNC source tree

This commit is contained in:
Wang Dequan
2026-08-20 06:17:39 +08:00
commit 2c814634c3
9429 changed files with 10556013 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
The hexapod (Stewart platform) configuration is a set of files that makes up a very basic LinuxCNC hexapod.
Start the machine, toggle E-Stop and Machine power, press Home all button and enter world mode. Note that Z home is 20, to run axis.ngc you need to touch off Z to 0.
hexapod.ini
---------------
Config file for a general hexapod.
To get it working with your machine you need to adjust base and platform joints coordinates in kinematics.hal and specify [KINS]KINEMATICS=genhexkins.
If you change the HOME location in TRAJ, make sure you change the appropriate HOME locations of the AXES as well, and make sure the position match (when run through the kinematics).
NOTE: The line "HALCMD = net ..." establishes a hal connection to enable switching kinematics between genhexkins, identity, and a user-defined kinematics
LIB:basic_sim.tcl
--------------
Defines simulated joints, no real hardware attached in this config.
kinematics.hal
--------------
Defines base and platform joints coordinates.
hexagui.hal
--------------
Adds simple Vismach visualisation for hexapod.
hexapod.xml
---------
Adds PyVCP panel.
hexapod_postgui.hal
------------------
Adds joints values and iterations number to PyVCP panel.

View File

@@ -0,0 +1,24 @@
pin+halui.axis.x.pos-feedback
pin+halui.axis.y.pos-feedback
pin+halui.axis.z.pos-feedback
pin+halui.axis.a.pos-feedback
pin+halui.axis.b.pos-feedback
pin+halui.axis.c.pos-feedback
pin+genhexkins.x
pin+genhexkins.y
pin+genhexkins.z
pin+genhexkins.a
pin+genhexkins.b
pin+genhexkins.c
pin+skgui.x
pin+skgui.y
pin+skgui.z
pin+skgui.a
pin+skgui.b
pin+skgui.c
pin+genhexkins.fwd-kins-fail
pin+genhexkins.last-iterations
pin+genhexkins.max-iterations

View File

@@ -0,0 +1,162 @@
[EMC]
VERSION = 1.1
MACHINE = hexapod (switchkins)
DEBUG = 0
[DISPLAY]
DISPLAY = axis
CYCLE_TIME = 0.200
HELP_FILE = tklinuxcnc.txt
POSITION_OFFSET = RELATIVE
POSITION_FEEDBACK = ACTUAL
MAX_FEED_OVERRIDE = 2.0
PROGRAM_PREFIX = ../../nc_files/
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 2
PYVCP = hexapod.xml
GEOMETRY = XYZA-B
[RS274NGC]
SUBROUTINE_PATH = ./remap_subs
HAL_PIN_VARS = 1
REMAP = M428 modalgroup=10 ngc=428remap
REMAP = M429 modalgroup=10 ngc=429remap
REMAP = M430 modalgroup=10 ngc=430remap
# start with no offsets
RS274NGC_STARTUP_CODE = G20 G10l2P0 x0 y0 z0 a0 b0 c0 (debug, ini: set offsets)
PARAMETER_FILE = hexapod.var
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 1.0
SERVO_PERIOD = 1000000
[TASK]
TASK = milltask
CYCLE_TIME = 0.010
[HAL]
HALUI = halui
HALFILE = LIB:basic_sim.tcl
HALFILE = kinematics.hal
HALCMD = loadusr -W hexagui
HALCMD = net :kinstype-select <= motion.analog-out-03 => motion.switchkins-type
POSTGUI_HALFILE = hexapod_postgui.hal
[HALUI]
# M428:genhexkins (kinstype==0 startupDEFAULT)
# M429:identity kins (kinstype==1)
# M430:userk kins (kinstype==2)
MDI_COMMAND = M428
MDI_COMMAND = M429
MDI_COMMAND = M430
[TRAJ]
# Note: the HOME Z coordinate should not be zero for this config
HOME = 0 0 20 0 0 0
NO_FORCE_HOMING = 1
COORDINATES = X Y Z A B C
LINEAR_UNITS = inch
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 1.0
MAX_LINEAR_VELOCITY = 10.0
DEFAULT_LINEAR_ACCELERATION = 10.0
MAX_LINEAR_ACCELERATION = 20.0
DEFAULT_ANGULAR_VELOCITY = 6
MAX_ANGULAR_VELOCITY = 6
[EMCIO]
TOOL_TABLE = hexapod.tbl
[KINS]
# Note: for identity, default order is XYZABC: joints 0,1,2,3,4,5
# use coordinates= to define a non-default ordering
KINEMATICS = genhexkins
JOINTS = 6
[JOINT_0]
TYPE = LINEAR
MAX_VELOCITY = 20.0
MAX_ACCELERATION = 200.0
MIN_LIMIT = -1000.0
MAX_LIMIT = 1000.0
HOME_OFFSET= 29.7466
HOME = 29.7466
HOME_SEQUENCE = 0
[JOINT_1]
TYPE = LINEAR
MAX_VELOCITY = 20.0
MAX_ACCELERATION = 200.0
MIN_LIMIT = -1000.0
MAX_LIMIT = 1000.0
HOME_OFFSET= 29.7466
HOME = 29.7466
HOME_SEQUENCE = 0
[JOINT_2]
TYPE = LINEAR
MAX_VELOCITY = 20.0
MAX_ACCELERATION = 200.0
MIN_LIMIT = -1000.0
MAX_LIMIT = 1000.0
HOME_OFFSET= 29.7466
HOME = 29.7466
HOME_SEQUENCE = 0
[JOINT_3]
TYPE = LINEAR
MAX_VELOCITY = 20.0
MAX_ACCELERATION = 200.0
MIN_LIMIT = -1000.0
MAX_LIMIT = 1000.0
HOME_OFFSET= 29.7466
HOME = 29.7466
HOME_SEQUENCE = 0
[JOINT_4]
TYPE = LINEAR
MAX_VELOCITY = 20.0
MAX_ACCELERATION = 200.0
MIN_LIMIT = -1000.0
MAX_LIMIT = 1000.0
HOME_OFFSET= 29.7466
HOME = 29.7466
HOME_SEQUENCE = 0
[JOINT_5]
TYPE = LINEAR
MAX_VELOCITY = 20.0
MAX_ACCELERATION = 200.0
MIN_LIMIT = -1000.0
MAX_LIMIT = 1000.0
HOME_OFFSET= 29.7466
HOME = 29.7466
HOME_SEQUENCE = 0
[AXIS_X]
MIN_LIMIT = -1000.0
MAX_LIMIT = 1000.0
MAX_VELOCITY = 20.0
MAX_ACCELERATION = 200.0
[AXIS_Y]
MIN_LIMIT = -1000.0
MAX_LIMIT = 1000.0
MAX_VELOCITY = 20.0
MAX_ACCELERATION = 200.0
[AXIS_Z]
MIN_LIMIT = -1000.0
MAX_LIMIT = 1000.0
MAX_VELOCITY = 20.0
MAX_ACCELERATION = 200.0
[AXIS_A]
MIN_LIMIT = -1000.0
MAX_LIMIT = 1000.0
MAX_VELOCITY = 20.0
MAX_ACCELERATION = 200.0
[AXIS_B]
MIN_LIMIT = -1000.0
MAX_LIMIT = 1000.0
MAX_VELOCITY = 20.0
MAX_ACCELERATION = 200.0
[AXIS_C]
MIN_LIMIT = -1000.0
MAX_LIMIT = 1000.0
MAX_VELOCITY = 20.0
MAX_ACCELERATION = 200.0

View File

@@ -0,0 +1,167 @@
<?xml version='1.0' encoding='UTF-8'?>
<pyvcp>
<vbox>
<relief>"ridge"</relief>
<bd>5</bd>
<label>
<text>"SWITCHKINS"</text>
<relief>RIDGE</relief>
<bd>3</bd>
</label>
<multilabel>
<legends>[" 0:GENHEX ", "1:IDENTITY", " 2:USERK "]</legends>
<font>("DejaVu Sans Mono",16)</font>
<bg>"black"</bg>
<fg>"yellow"</fg>
</multilabel>
<button>
<halpin>"type0-button"</halpin>
<text>"Genhexkins"</text>
<bd>3</bd>
</button>
<button>
<halpin>"type1-button"</halpin>
<text>"Identity "</text>
<bd>3</bd>
</button>
<button>
<halpin>"type2-button"</halpin>
<text>"userk "</text>
<bd>3</bd>
</button>
</vbox>
<hbox>
<relief>"ridge"</relief>
<bd>3</bd>
<label>
<padx>0</padx>
<font>"monospace"</font>
</label>
<led>
<halpin>"fwd-kins-fail"</halpin>
<size>15</size>
<on_color>"red"</on_color>
<off_color>"#d9d9d9"</off_color>
</led>
<label>
<text>" Fwd Kins Fail"</text>
<anchor>"w"</anchor>
</label>
</hbox>
<labelframe text="Iterations">
<font>("Helvetica",14)</font>
<vbox>
<hbox>
<label>
<text>"max:"</text>
<font>("Helvetica",14)</font>
</label>
<u32>
<halpin>"max-iter"</halpin>
<font>("Helvetica",14)</font>
<format>"3d"</format>
<width>3</width>
</u32>
</hbox>
<hbox>
<label>
<text>"last: "</text>
<font>("Helvetica",14)</font>
</label>
<u32>
<halpin>"last-iter"</halpin>
<font>("Helvetica",14)</font>
<format>"3d"</format>
<width>3</width>
</u32>
</hbox>
</vbox>
</labelframe>
<vbox>
<labelframe text="Joints values">
<font>("Helvetica",14)</font>
<hbox>
<label>
<text>"0: "</text>
<font>("Helvetica",14)</font>
</label>
<number>
<halpin>"joint0"</halpin>
<font>("Helvetica",14)</font>
<format>"4.4f"</format>
</number>
</hbox>
<hbox>
<label>
<text>"1: "</text>
<font>("Helvetica",14)</font>
</label>
<number>
<halpin>"joint1"</halpin>
<font>("Helvetica",14)</font>
<format>"4.4f"</format>
</number>
</hbox>
<hbox>
<label>
<text>"2: "</text>
<font>("Helvetica",14)</font>
</label>
<number>
<halpin>"joint2"</halpin>
<font>("Helvetica",14)</font>
<format>"4.4f"</format>
</number>
</hbox>
<hbox>
<label>
<text>"3: "</text>
<font>("Helvetica",14)</font>
</label>
<number>
<halpin>"joint3"</halpin>
<font>("Helvetica",14)</font>
<format>"4.4f"</format>
</number>
</hbox>
<hbox>
<label>
<text>"4: "</text>
<font>("Helvetica",14)</font>
</label>
<number>
<halpin>"joint4"</halpin>
<font>("Helvetica",14)</font>
<format>"4.4f"</format>
</number>
</hbox>
<hbox>
<label>
<text>"5: "</text>
<font>("Helvetica",14)</font>
</label>
<number>
<halpin>"joint5"</halpin>
<font>("Helvetica",14)</font>
<format>"4.4f"</format>
</number>
</hbox>
</labelframe>
</vbox>
<vbox>
<relief>"ridge"</relief>
<bd>5</bd>
<button>
<halpin>"vismach-clear"</halpin>
<text>"vismach-clear"</text>
<bd>3</bd>
</button>
</vbox>
</pyvcp>

View File

@@ -0,0 +1,26 @@
net :kinstype.is-0 <= kinstype.is-0 => pyvcp.multilabel.0.legend0
net :kinstype.is-1 <= kinstype.is-1 => pyvcp.multilabel.0.legend1
net :kinstype.is-2 <= kinstype.is-2 => pyvcp.multilabel.0.legend2
net :type0-button <= pyvcp.type0-button => halui.mdi-command-00
net :type1-button <= pyvcp.type1-button => halui.mdi-command-01
net :type2-button <= pyvcp.type2-button => halui.mdi-command-02
net :vismach-clear <= pyvcp.vismach-clear => vismach.plotclear
net :fwd-kins-fail <= genhexkins.fwd-kins-fail => pyvcp.fwd-kins-fail
net :last-iter <= genhexkins.last-iterations => pyvcp.last-iter
net :max-iter <= genhexkins.max-iterations => pyvcp.max-iter
net :j0 <= joint.0.pos-fb => pyvcp.joint0 => hexagui.joint.0
net :j1 <= joint.1.pos-fb => pyvcp.joint1 => hexagui.joint.1
net :j2 <= joint.2.pos-fb => pyvcp.joint2 => hexagui.joint.2
net :j3 <= joint.3.pos-fb => pyvcp.joint3 => hexagui.joint.3
net :j4 <= joint.4.pos-fb => pyvcp.joint4 => hexagui.joint.4
net :j5 <= joint.5.pos-fb => pyvcp.joint5 => hexagui.joint.5
net :gui.x <= skgui.x => hexagui.axis.x
net :gui.y <= skgui.y => hexagui.axis.y
net :gui.z <= skgui.z => hexagui.axis.z
net :gui.a <= skgui.a => hexagui.axis.a
net :gui.b <= skgui.b => hexagui.axis.b
net :gui.c <= skgui.c => hexagui.axis.c

View File

@@ -0,0 +1,66 @@
# These values should be edited to represent the machine geometry
# Base joints positions in base (world) coordinates
setp genhexkins.base.0.x -22.950
setp genhexkins.base.0.y 13.250
setp genhexkins.base.0.z 0.000
setp genhexkins.base.1.x 22.950
setp genhexkins.base.1.y 13.250
setp genhexkins.base.1.z 0.000
setp genhexkins.base.2.x 22.950
setp genhexkins.base.2.y 13.250
setp genhexkins.base.2.z 0.000
setp genhexkins.base.3.x 0.000
setp genhexkins.base.3.y -26.500
setp genhexkins.base.3.z 0.000
setp genhexkins.base.4.x 0.000
setp genhexkins.base.4.y -26.500
setp genhexkins.base.4.z 0.000
setp genhexkins.base.5.x -22.950
setp genhexkins.base.5.y 13.250
setp genhexkins.base.5.z 0.000
# Platform joints positions in platform coordinates
setp genhexkins.platform.0.x -1.000
setp genhexkins.platform.0.y 11.500
setp genhexkins.platform.0.z 0.000
setp genhexkins.platform.1.x 1.000
setp genhexkins.platform.1.y 11.500
setp genhexkins.platform.1.z 0.000
setp genhexkins.platform.2.x 10.459
setp genhexkins.platform.2.y -4.884
setp genhexkins.platform.2.z 0.000
setp genhexkins.platform.3.x 9.459
setp genhexkins.platform.3.y -6.616
setp genhexkins.platform.3.z 0.000
setp genhexkins.platform.4.x -9.459
setp genhexkins.platform.4.y -6.616
setp genhexkins.platform.4.z 0.000
setp genhexkins.platform.5.x -10.459
setp genhexkins.platform.5.y -4.884
setp genhexkins.platform.5.z 0.000
# Connect tool offset pin to motion
net tool-offset genhexkins.tool-offset motion.tooloffset.z
# Forward kinematics iterations control, uncomment to use
# Normally not nesessary, use only if you know what you're doing
# Minimum error value that ends iterations with found solution
# setp genhexkins.convergence-criterion 1e-9
# Limit of iterations, if exceeded iterations stop with no convergence
# setp genhexkins.limit-iterations 120
# Maximum error value, if exceeded iterations stop with no convergence
# setp genhexkins.max-error 100.0

View File

@@ -0,0 +1,24 @@
;M428 by remap: select kinstype=0 genhexkins
o<428remap>sub
#<kinstype> = 0
#<SWITCHKINS_PIN> = 3 ; set N as required: motion.analog-out-0N
o1 if [exists [#<_hal[motion.switchkins-type]>]]
o1 else
(debug,M428:Missing [RS274NGC]HAL_PIN_VARS=1)
(debug,STOP)
M2
o1 endif
M68 E#<SWITCHKINS_PIN> Q#<kinstype> ; set kinstype value
M66 E0 L0 ; force synch
o2 if [[#<_task> EQ 1] AND [#<_hal[motion.switchkins-type]> NE #<kinstype>]]
(debug,M428: Wrong motion.switchkins-type)
(debug,or missing hal net to analog-out-0x)
(debug,STOP)
M2
o2 else
o2 endif
o<428remap>endsub

View File

@@ -0,0 +1,24 @@
;M429 by remap: select kinstype==1 Identity kinematics
o<429remap>sub
#<kinstype> = 1
#<SWITCHKINS_PIN> = 3 ; set N as required: motion.analog-out-0N
o1 if [exists [#<_hal[motion.switchkins-type]>]]
o1 else
(debug,M429:Missing [RS274NGC]HAL_PIN_VARS=1)
(debug,STOP)
M2
o1 endif
M68 E#<SWITCHKINS_PIN> Q#<kinstype> ; set kinstype value
M66 E0 L0 ; force synch
o2 if [[#<_task> EQ 1] AND [#<_hal[motion.switchkins-type]> NE #<kinstype>]]
(debug,M429:Wrong motion.switchkins-type)
(debug,or missing hal net to analog-out-0x)
(debug,STOP)
M2
o2 else
o2 endif
o<429remap>endsub

View File

@@ -0,0 +1,24 @@
;M430 by remap: select kinstype==2 userk kins
o<430remap>sub
#<kinstype> = 2
#<SWITCHKINS_PIN> = 3 ; set N as required: motion.analog-out-0N
o1 if [exists [#<_hal[motion.switchkins-type]>]]
o1 else
(debug,M30:Missing [RS274NGC]HAL_PIN_VARS=1)
(debug,STOP)
M2
o1 endif
M68 E#<SWITCHKINS_PIN> Q#<kinstype> ; set kinstype value
M66 E0 L0 ; force synch
o2 if [[#<_task> EQ 1] AND [#<_hal[motion.switchkins-type]> NE #<kinstype>]]
(debug,M430:Wrong motion.switchkins-type)
(debug,or missing hal net to analog-out-0x)
(debug,STOP)
M2
o2 else
o2 endif
o<430remap>endsub