mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-30 14:22:07 +00:00
Calibration Cornering Jerk Test + Generic interpolator + Fix (#10962)
This commit is contained in:
@@ -4241,10 +4241,10 @@ LayerResult GCode::process_layer(
|
||||
}
|
||||
} else {
|
||||
if (print.calib_params().freqStartX == print.calib_params().freqStartY && print.calib_params().freqEndX == print.calib_params().freqEndY) {
|
||||
gcode += writer().set_input_shaping('A', 0.f, (print.calib_params().freqStartX) + ((print.calib_params().freqEndX)-(print.calib_params().freqStartX)) * (m_layer_index - 2) / (m_layer_count - 3), "");
|
||||
gcode += writer().set_input_shaping('A', 0.f, this->interpolate_value_across_layers(print.calib_params().freqStartX, print.calib_params().freqEndX), "");
|
||||
} else {
|
||||
gcode += writer().set_input_shaping('X', 0.f, (print.calib_params().freqStartX) + ((print.calib_params().freqEndX)-(print.calib_params().freqStartX)) * (m_layer_index - 2) / (m_layer_count - 3), "");
|
||||
gcode += writer().set_input_shaping('Y', 0.f, (print.calib_params().freqStartY) + ((print.calib_params().freqEndY)-(print.calib_params().freqStartY)) * (m_layer_index - 2) / (m_layer_count - 3), "");
|
||||
gcode += writer().set_input_shaping('X', 0.f, this->interpolate_value_across_layers(print.calib_params().freqStartX, print.calib_params().freqEndX), "");
|
||||
gcode += writer().set_input_shaping('Y', 0.f, this->interpolate_value_across_layers(print.calib_params().freqStartY, print.calib_params().freqEndY), "");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -4258,12 +4258,18 @@ LayerResult GCode::process_layer(
|
||||
gcode += writer().set_input_shaping('X', 0.f, print.calib_params().freqStartX, print.calib_params().shaper_type);
|
||||
gcode += writer().set_input_shaping('Y', 0.f, print.calib_params().freqStartY, print.calib_params().shaper_type);
|
||||
} else {
|
||||
gcode += writer().set_input_shaping('A', print.calib_params().start + ((print.calib_params().end)-(print.calib_params().start)) * (m_layer_index) / (m_layer_count), 0.f, "");
|
||||
gcode += writer().set_input_shaping('A', this->interpolate_value_across_layers(print.calib_params().start, print.calib_params().end), 0.f, "");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CalibMode::Calib_Junction_Deviation: {
|
||||
gcode += writer().set_junction_deviation(print.calib_params().start + ((print.calib_params().end)-(print.calib_params().start)) * (m_layer_index) / (m_layer_count));
|
||||
case CalibMode::Calib_Cornering: {
|
||||
if (m_writer.get_gcode_flavor() == gcfMarlinFirmware &&
|
||||
!m_config.machine_max_junction_deviation.values.empty() &&
|
||||
m_config.machine_max_junction_deviation.values.front() > 0) {
|
||||
gcode += writer().set_junction_deviation(this->interpolate_value_across_layers(print.calib_params().start, print.calib_params().end));
|
||||
} else {
|
||||
gcode += writer().set_jerk_xy(this->interpolate_value_across_layers(print.calib_params().start, print.calib_params().end));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -6680,6 +6686,17 @@ std::string GCode::extrusion_role_to_string_for_parser(const ExtrusionRole & rol
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate the interpolated value for the current layer between start_value and end_value
|
||||
float GCode::interpolate_value_across_layers(float start_value, float end_value) const {
|
||||
if (m_layer_index == 1) {
|
||||
return start_value;
|
||||
} else {
|
||||
float ratio = (m_layer_index - 2.0f) / (m_layer_count - 3.0f);
|
||||
ratio = std::max(0.0f, std::min(1.0f, ratio)); // clamp
|
||||
return start_value + ratio * (end_value - start_value);
|
||||
}
|
||||
}
|
||||
|
||||
std::string encodeBase64(uint64_t value)
|
||||
{
|
||||
//Always use big endian mode
|
||||
@@ -7523,7 +7540,6 @@ void GCode::ObjectByExtruder::Island::Region::append(const Type type, const Extr
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Index into std::vector<LayerToPrint>, which contains Object and Support layers for the current print_z, collected for
|
||||
// a single object, or for possibly multiple objects with multiple instances.
|
||||
|
||||
|
||||
@@ -236,6 +236,9 @@ public:
|
||||
bool enable_cooling_markers() const { return m_enable_cooling_markers; }
|
||||
std::string extrusion_role_to_string_for_parser(const ExtrusionRole &);
|
||||
|
||||
// Calculate the interpolated value for the current layer between start_value and end_value
|
||||
float interpolate_value_across_layers(float start_value, float end_value) const;
|
||||
|
||||
// For Perl bindings, to be used exclusively by unit tests.
|
||||
unsigned int layer_count() const { return m_layer_count; }
|
||||
void set_layer_count(unsigned int value) { m_layer_count = value; }
|
||||
|
||||
@@ -1655,7 +1655,7 @@ StringObjectException Print::validate(StringObjectException *warning, Polygons*
|
||||
}
|
||||
}
|
||||
|
||||
// check junction deviation
|
||||
// Check junction deviation
|
||||
const auto max_junction_deviation = m_config.machine_max_junction_deviation.values[0];
|
||||
if (warning_key.empty() && m_default_object_config.default_junction_deviation.value > max_junction_deviation) {
|
||||
warning->string = L( "Junction deviation setting exceeds the printer's maximum value "
|
||||
|
||||
@@ -4040,15 +4040,16 @@ void PrintConfigDef::init_fff_params()
|
||||
def->set_default_value(new ConfigOptionFloats(axis.max_jerk));
|
||||
}
|
||||
}
|
||||
// M205 J... [mm] machine junction deviation limits
|
||||
// M205 J... [mm] machine junction deviation limits
|
||||
def = this->add("machine_max_junction_deviation", coFloats);
|
||||
def->full_label = L("Maximum Junction Deviation");
|
||||
def->category = L("Machine limits");
|
||||
def->tooltip = L("Maximum junction deviation (M205 J, only apply if JD > 0 for Marlin Firmware)");
|
||||
def->tooltip = L("Maximum junction deviation (M205 J, only apply if JD > 0 for Marlin Firmware\nIf your Marlin 2 printer uses Classic Jerk set this value to 0.)");
|
||||
def->sidetext = "mm"; // milimeters, don't need translation
|
||||
def->min = 0;
|
||||
def->max = 1;
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionFloats{0. ,0. });
|
||||
def->set_default_value(new ConfigOptionFloats { 0.01});
|
||||
|
||||
// M205 S... [mm/sec]
|
||||
def = this->add("machine_min_extruding_rate", coFloats);
|
||||
|
||||
@@ -895,5 +895,4 @@ double CalibPressureAdvancePattern::pattern_shift() const
|
||||
return (wall_count() - 1) * line_spacing_first_layer() + line_width_first_layer() + m_glyph_padding_horizontal;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
@@ -26,7 +26,7 @@ enum class CalibMode : int {
|
||||
Calib_Retraction_tower,
|
||||
Calib_Input_shaping_freq,
|
||||
Calib_Input_shaping_damp,
|
||||
Calib_Junction_Deviation
|
||||
Calib_Cornering
|
||||
};
|
||||
|
||||
enum class CalibState { Start = 0, Preset, Calibration, CoarseSave, FineCalibration, Save, Finish };
|
||||
|
||||
Reference in New Issue
Block a user