Beispiel #1
0
    def finalize(self, positions):
        kin = self.printer.lookup_object('toolhead').get_kinematics()
        logging.info("Calculating delta_calibrate with: %s", positions)
        params = kin.get_calibrate_params()
        logging.info("Initial delta_calibrate parameters: %s", params)
        adj_params = ('endstop_a', 'endstop_b', 'endstop_c', 'radius',
                      'angle_a', 'angle_b')

        def delta_errorfunc(params):
            total_error = 0.
            for spos in positions:
                x, y, z = delta.get_position_from_stable(spos, params)
                total_error += (z - self.probe_z_offset)**2
            return total_error

        new_params = mathutil.coordinate_descent(adj_params, params,
                                                 delta_errorfunc)
        logging.info("Calculated delta_calibrate parameters: %s", new_params)
        for spos in positions:
            logging.info("orig: %s new: %s",
                         delta.get_position_from_stable(spos, params),
                         delta.get_position_from_stable(spos, new_params))
        self.gcode.respond_info(
            "stepper_a: position_endstop: %.6f angle: %.6f\n"
            "stepper_b: position_endstop: %.6f angle: %.6f\n"
            "stepper_c: position_endstop: %.6f angle: %.6f\n"
            "radius: %.6f\n"
            "To use these parameters, update the printer config file with\n"
            "the above and then issue a RESTART command" %
            (new_params['endstop_a'], new_params['angle_a'],
             new_params['endstop_b'], new_params['angle_b'],
             new_params['endstop_c'], new_params['angle_c'],
             new_params['radius']))
Beispiel #2
0
 def delta_errorfunc(params):
     total_error = 0.
     for spos in positions:
         x, y, z = delta.get_position_from_stable(spos, params)
         total_error += (z - self.probe_z_offset)**2
     return total_error