feat: add dock_dir for rear-mounted tool docks - #7
Conversation
…ont and back) mounted tool racks
{-(expr)} is parsed as whitespace-strip, so front-dock peel
became Y-10 into the dock and tripped position_min.
b24e0ea to
990f97b
Compare
|
Merged. I checked the maths both ways before taking it: front comes out at trigger_y -21 with the dance stepping -21.5 / -22 / -23 and peel +10, which is bit identical to what main did before, so the default really is a no-op for existing setups. Rear puts the trigger line on the bed side and marches the dance deeper, which is right. Two follow ups. The variable adds exactly one new way to hurt yourself: set dock_dir -1 on a rear dock and the head drives away from the trigger line into the dock. Your own alternative in the description is the fix for that, not as a replacement but as a guard. sign(dock_y - clearance_y) gives the right answer in both configurations, and those two values are already calibrated so they can't disagree with reality. Worth erroring out if dock_dir contradicts them. Happy to take that as a small follow up PR if you fancy it. The other thing is INDX_DOCK_MEASURE. It's documented as homing Y then X from the dock and deriving the position from raw stepper counts, but on a rear dock homing Y moves away from the dock. That's plugin side rather than anything dock_dir can fix, so it needs @dalegaard rather than either of us, but anyone running a rear dock should know dock calibration may not work the same way. Also worth knowing this unblocks part of #26: your homing.cfg uses tp.dock_dir for the clearance check and carries its own copy of variable_dock_dir, which is some of why that PR is showing as conflicting. With this on main that overlap goes away and the rebase should be a bit less painful. |
The comment added in #7 warning about the bare-minus form contained that form literally. Klipper hands the whole macro body to Jinja, comments included, so the warning parsed as an expression and every config using these two macros failed to load. Rephrased so it says the same thing without writing the sequence out.
|
Heads up, I had to push a follow up on this one. The comment above the peel move broke config loading: Klipper hands the whole macro body to Jinja, comments included, since the # is only stripped later at gcode execution. So the sequence you were warning about gets parsed rather than read, the next token is a colon, and _LINEAR_EXIT and _CAL_PARK_ACTIVE both fail to compile. Klipper refuses to start with that on main. The comment fell into the exact trap it was documenting, which I did enjoy slightly. Fixed in 266f53e, same warning phrased so it doesn't write the sequence out. The code either side of it is fine and your front and rear numbers check out, so I assume the comment went in after you'd tested, because a config with that in it won't load at all. No harm done, it was on main for about four minutes. Worth knowing for anything else you write though: you can't put those delimiters inside a Klipper macro comment, the template engine sees them regardless. |
A macro that fails to compile stops Klipper from starting, so it is a dead printer at boot rather than a runtime warning. #7 shipped one briefly and only a manual check caught it. Uses the same delimiters as Klipper's gcode_macro, including the part that caught us out: # comments are not stripped before compilation, so a Jinja delimiter written inside a comment is still parsed.
feat: add dock_dir for rear-mounted tool docks
Summary
Dock geometry assumed the tools sit at the front of the machine (min Y).
trigger_y, unlock-dance depths, and peel-off moves all used that sign. On a rear-mounted dock (max Y), park/pickup approached from the wrong side and could drive past the seat into the dock.Adds
variable_dock_dir(-1front,+1rear, default-1) for trigger-line derivation, unlock dance, and peel moves. Default-1leaves existing front-dock configs alone.Alternative
To avoid another variable, derive
dock_dirfromclearance_yand a tool'sdock_y: the sign of Y that moves fromclearance_ytowarddock_y(i.e.sign(dock_y - clearance_y)).Changes
macros/indx.cfgvariable_dock_dir: -1; update trigger-line commentsmacros/indx-tc-macros.cfgtrigger_y, unlock dance, and peel fromdock_dirmacros/indx-cal.cfgdock_dirREADME.mdvariable_dock_dirand rear-dockclearance_yplacementTest plan
dock_dir: -1, default):PARK_TOOL/T0matches current behaviourdock_dir: 1): same behaiour but in reverse direction.clearance_yon the bed side)