## Client klipper macro definitions ## ## Copyright (C) 2022 Alex Zellner ## ## This file may be distributed under the terms of the GNU GPLv3 license ## ## !!! This file is read-only. Maybe the used editor indicates that. !!! ## ## Customization: ## 1) copy the gcode_macro _CLIENT_VARIABLE (see below) to your printer.cfg ## 2) remove the comment mark (#) from all lines ## 3) change any value in there to your needs ## ## Use the PAUSE macro direct in your M600: ## e.g. with a different park position front left and a minimal height of 50 ## [gcode_macro M600] ## description: Filament change ## gcode: PAUSE X=10 Y=10 Z_MIN=50 ## Z_MIN will park the toolhead at a minimum of 50 mm above to bed to make it easier for you to swap filament. ## ## Client variable macro for your printer.cfg #[gcode_macro _CLIENT_VARIABLE] #variable_use_custom_pos : False ; use custom park coordinates for x,y [True/False] #variable_custom_park_x : 0.0 ; custom x position; value must be within your defined min and max of X #variable_custom_park_y : 0.0 ; custom y position; value must be within your defined min and max of Y #variable_custom_park_dz : 2.0 ; custom dz value; the value in mm to lift the nozzle when move to park position #variable_retract : 1.0 ; the value to retract while PAUSE #variable_cancel_retract : 5.0 ; the value to retract while CANCEL_PRINT #variable_speed_retract : 35.0 ; retract speed in mm/s #variable_unretract : 1.0 ; the value to unretract while RESUME #variable_speed_unretract : 35.0 ; unretract speed in mm/s #variable_speed_hop : 15.0 ; z move speed in mm/s #variable_speed_move : 100.0 ; move speed in mm/s #variable_park_at_cancel : False ; allow to move the toolhead to park while execute CANCEL_PRINT [True/False] #variable_park_at_cancel_x : None ; different park position during CANCEL_PRINT [None/Position as Float]; park_at_cancel must be True #variable_park_at_cancel_y : None ; different park position during CANCEL_PRINT [None/Position as Float]; park_at_cancel must be True ## !!! Caution [firmware_retraction] must be defined in the printer.cfg if you set use_fw_retract: True !!! #variable_use_fw_retract : False ; use fw_retraction instead of the manual version [True/False] #variable_idle_timeout : 0 ; time in sec until idle_timeout kicks in. Value 0 means that no value will be set or restored #variable_runout_sensor : "" ; If a sensor is defined, it will be used to cancel the execution of RESUME in case no filament is detected. ## Specify the config name of the runout sensor e.g "filament_switch_sensor runout". Hint use the same as in your printer.cfg ## !!! Custom macros, please use with care and review the section of the corresponding macro. ## These macros are for simple operations like setting a status LED. Please make sure your macro does not interfere with the basic macro functions. ## Only single line commands are supported, please create a macro if you need more than one command. #variable_user_pause_macro : "" ; Everything inside the "" will be executed after the klipper base pause (PAUSE_BASE) function #variable_user_resume_macro: "" ; Everything inside the "" will be executed before the klipper base resume (RESUME_BASE) function #variable_user_cancel_macro: "" ; Everything inside the "" will be executed before the klipper base cancel (CANCEL_PRINT_BASE) function #gcode: [virtual_sdcard] path: /srv/klipper/moonraker/gcodes on_error_gcode: CANCEL_PRINT [pause_resume] #recover_velocity: 50. # When capture/restore is enabled, the speed at which to return to # the captured position (in mm/s). Default is 50.0 mm/s. [display_status] [respond] [gcode_macro CANCEL_PRINT] description: Cancel the actual running print rename_existing: CANCEL_PRINT_BASE gcode: ##### get user parameters or use default ##### {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} {% set allow_park = client.park_at_cancel|default(false)|lower == 'true' %} {% set retract = client.cancel_retract|default(5.0)|abs %} ##### define park position ##### {% set park_x =
#pragma once

#include <cmath>
#include "Vector.hpp"

struct Rotation {
    Rotation() = default;

    Rotation(Vector<3> vector) : vector{ wrap(vector) } {}

    explicit Rotation(Real angles[3]) : Rotation(angles[0], angles[1], angles[2]) {}

    Rotation(Real pitch, Real yaw, Real roll) {
        vector = wrap({pitch, yaw, roll });
    }

    Rotation operator+(Rotation other) const {
        return wrap(vector + other.vector);
    }

    std::string string() const {
        return vector.string();
    }

    static Vector<3> wrap(Vector<3> v) {
        return v.map([](auto a) { return fmod(a, 360.0f); });
    }

    Real& pitch() {
        return vector[0];
    }

    Real& yaw() {
        return vector[1];
    }

    Real& roll() {
        return vector[2];
    }

    Vector<3> vector;
};
e_move %} M8{ 2 if ABSOLUTE_E else 3 } {% endif %} G1 { x_move } { y_move } { z_move } { e_move } { rate } RESTORE_GCODE_STATE NAME=_client_movement