Executing FORCE_MOVE from within Kinematics class home() implementation

Hi,

I’m working on a non-Cartesian kinematic that requires a fairly unusual homing procedure for XY. I have to turn off one motor and force-move the other motor with reduced current; this ends up placing the toolhead in a predictable XY position in the corner of its movement range.

I can home it with the following g-code sequence:

M18 X0 Y0
SET_TMC_CURRENT STEPPER=stepper_a CURRENT=0.4 HOLDCURRENT=0.4
FORCE_MOVE STEPPER=stepper_a DISTANCE=-400 VELOCITY=200 ACCEL=50
G4 P1000
M18 X1 Y1
SET_KINEMATIC_POSITION X=... Y=...
SET_TMC_CURRENT STEPPER=stepper_a CURRENT=0.8 HOLDCURRENT=0.8

Here’s a short video of the kinematics to make it clearer:

The mechanism in the back provides mechanical limits to toolhead movement.

(also a video of a speed benchy in case you want to see it printing: First speedboatrace attempt with Marionette, using PLA. - YouTube)

With one motor powered off and the other motor reeling in its cable, the toolhead ends up placed in the corner next to that motor.

I’m trying to implement this homing procedure in the Kinematics class now (so that G28 would work for homing), and I’ve been a bit lost as to how to do the equivalent of above commands, from Python code.

Also, in the future I may add a couple limit switches to detect when the toolhead is fully in the corner, which would require the FORCE_MOVE equivalent to stop when an endstop is triggered.

I like Marionette :heart_eyes:
You are fu…ing nuts :grinning:

Good luck, hcet14

Thanks!

An update: I got it to work via [homing_override] config section, although that is slightly less than ideal because it does not allow me to save and restore motor current.

Trying to do it from the home() method, i got as far as:

          if home_xy:
            gcode=self.printer.lookup_object('gcode')
            toolhead = self.printer.lookup_object('toolhead')
            print('Trying to home')
            fmove = self.printer.lookup_object('force_move')
            stepper_enable=self.printer.lookup_object('stepper_enable')
            stepper_b_enable=stepper_enable.lookup_enable(self.steppers[1].get_name())
            toolhead.dwell(0.1)
            print_time = toolhead.get_last_move_time()
            stepper_b_enable.motor_disable(print_time)
            move=fmove.manual_move

            stepper_a_name=self.steppers[0].get_name()

            gcode.run_script_from_command(f'SET_TMC_CURRENT STEPPER={stepper_a_name} CURRENT=0.4\n')
            move(self.steppers[0], -20, 20, 20)
            # TODO : obtain current from configuration
            gcode.run_script_from_command(f'SET_TMC_CURRENT STEPPER={stepper_a_name} CURRENT=0.8\n')

but I couldn’t find how to get hold of the instance of CurrentHelper object.

See I'd like to live better with Global Values - #4 by theophile for a nice example