mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-18 19:12:17 +00:00
JD processor upgrade (#12440)
* Update GCodeProcessor.cpp Co-Authored-By: Rodrigo Faselli <162915171+RF47@users.noreply.github.com> * Fix Co-Authored-By: Rodrigo Faselli <162915171+RF47@users.noreply.github.com> * get_axis_max_jerk_with_jd * get_get fix Co-Authored-By: Rodrigo Faselli <162915171+RF47@users.noreply.github.com> --------- Co-authored-by: Rodrigo Faselli <162915171+RF47@users.noreply.github.com>
This commit is contained in:
@@ -5155,6 +5155,9 @@ void GCodeProcessor::process_M205(const GCodeReader::GCodeLine& line)
|
|||||||
|
|
||||||
if (line.has_value('T', value))
|
if (line.has_value('T', value))
|
||||||
set_option_value(m_time_processor.machine_limits.machine_min_travel_rate, i, value);
|
set_option_value(m_time_processor.machine_limits.machine_min_travel_rate, i, value);
|
||||||
|
|
||||||
|
if (line.has_value('J', value))
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_junction_deviation, i, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5567,14 +5570,37 @@ float GCodeProcessor::get_axis_max_acceleration(PrintEstimatedStatistics::ETimeM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float GCodeProcessor::get_axis_max_jerk_with_jd(PrintEstimatedStatistics::ETimeMode mode, Axis axis) const
|
||||||
|
{
|
||||||
|
if (axis != X && axis != Y && axis != Z && axis != E)
|
||||||
|
return 0.0f;
|
||||||
|
|
||||||
|
const size_t id = static_cast<size_t>(mode);
|
||||||
|
const float jd = get_option_value(m_time_processor.machine_limits.machine_max_junction_deviation, id);
|
||||||
|
if (jd <= 0.0f)
|
||||||
|
return 0.0f;
|
||||||
|
|
||||||
|
const float axis_max_acc = get_axis_max_acceleration(mode, axis);
|
||||||
|
const float generic_acc = get_acceleration(mode);
|
||||||
|
const float effective_acc = axis_max_acc > 0.0f ? axis_max_acc : generic_acc;
|
||||||
|
|
||||||
|
return std::sqrt(jd * effective_acc * 2.5f);
|
||||||
|
}
|
||||||
|
|
||||||
float GCodeProcessor::get_axis_max_jerk(PrintEstimatedStatistics::ETimeMode mode, Axis axis) const
|
float GCodeProcessor::get_axis_max_jerk(PrintEstimatedStatistics::ETimeMode mode, Axis axis) const
|
||||||
{
|
{
|
||||||
|
const size_t id = static_cast<size_t>(mode);
|
||||||
|
const float jd = get_option_value(m_time_processor.machine_limits.machine_max_junction_deviation, id);
|
||||||
|
if (m_flavor == gcfMarlinFirmware && jd > 0.0f) {
|
||||||
|
return get_axis_max_jerk_with_jd(mode, axis);
|
||||||
|
}
|
||||||
|
|
||||||
switch (axis)
|
switch (axis)
|
||||||
{
|
{
|
||||||
case X: { return get_option_value(m_time_processor.machine_limits.machine_max_jerk_x, static_cast<size_t>(mode)); }
|
case X: { return get_option_value(m_time_processor.machine_limits.machine_max_jerk_x, id); }
|
||||||
case Y: { return get_option_value(m_time_processor.machine_limits.machine_max_jerk_y, static_cast<size_t>(mode)); }
|
case Y: { return get_option_value(m_time_processor.machine_limits.machine_max_jerk_y, id); }
|
||||||
case Z: { return get_option_value(m_time_processor.machine_limits.machine_max_jerk_z, static_cast<size_t>(mode)); }
|
case Z: { return get_option_value(m_time_processor.machine_limits.machine_max_jerk_z, id); }
|
||||||
case E: { return get_option_value(m_time_processor.machine_limits.machine_max_jerk_e, static_cast<size_t>(mode)); }
|
case E: { return get_option_value(m_time_processor.machine_limits.machine_max_jerk_e, id); }
|
||||||
default: { return 0.0f; }
|
default: { return 0.0f; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5582,43 +5608,26 @@ float GCodeProcessor::get_axis_max_jerk(PrintEstimatedStatistics::ETimeMode mode
|
|||||||
Vec3f GCodeProcessor::get_xyz_max_jerk(PrintEstimatedStatistics::ETimeMode mode) const
|
Vec3f GCodeProcessor::get_xyz_max_jerk(PrintEstimatedStatistics::ETimeMode mode) const
|
||||||
{
|
{
|
||||||
// Default values from config
|
// Default values from config
|
||||||
const size_t id = static_cast<size_t>(mode);
|
const size_t id = static_cast<size_t>(mode);
|
||||||
float jx = get_option_value(m_time_processor.machine_limits.machine_max_jerk_x, id);
|
float jx = 0.0f;
|
||||||
float jy = get_option_value(m_time_processor.machine_limits.machine_max_jerk_y, id);
|
float jy = 0.0f;
|
||||||
const float jz = get_option_value(m_time_processor.machine_limits.machine_max_jerk_z, id);
|
float jz = 0.0f;
|
||||||
const float machine_jd = get_option_value(m_time_processor.machine_limits.machine_max_junction_deviation, id);
|
const float jd = get_option_value(m_time_processor.machine_limits.machine_max_junction_deviation, id);
|
||||||
|
|
||||||
// early exit: Junction Deviation is only supported by Marlin firmware
|
// Classic Jerk: Junction Deviation is only supported by Marlin firmware when using a JD value grater than 0.
|
||||||
if (m_flavor != gcfMarlinFirmware || machine_jd <= 0.0f) {
|
if (m_flavor != gcfMarlinFirmware || jd <= 0.0f)
|
||||||
return Vec3f(jx, jy, jz);
|
{
|
||||||
|
jx = get_option_value(m_time_processor.machine_limits.machine_max_jerk_x, id);
|
||||||
|
jy = get_option_value(m_time_processor.machine_limits.machine_max_jerk_y, id);
|
||||||
|
jz = get_option_value(m_time_processor.machine_limits.machine_max_jerk_z, id);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
// default junction deviation:
|
{
|
||||||
const ConfigOptionFloat* opt = nullptr;
|
jx = get_axis_max_jerk_with_jd(mode, X);
|
||||||
|
jy = get_axis_max_jerk_with_jd(mode, Y);
|
||||||
if (m_print) {
|
jz = get_axis_max_jerk_with_jd(mode, Z);
|
||||||
const auto& config = m_print->full_print_config();
|
|
||||||
opt = config.option<ConfigOptionFloat>("default_junction_deviation");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const float default_jd = opt ? opt->value : 0.0f;
|
|
||||||
|
|
||||||
// If default_jd is specified (>0), use the smaller of machine_jd and default_jd.
|
|
||||||
const float jd = (default_jd > 0.0f) ? std::min(machine_jd, default_jd) : machine_jd;
|
|
||||||
|
|
||||||
// Use per-axis acceleration when available; fall back to generic acceleration.
|
|
||||||
// If axis-specific acceleration not provided (zero), use general acceleration
|
|
||||||
const PrintEstimatedStatistics::ETimeMode emode = static_cast<PrintEstimatedStatistics::ETimeMode>(id);
|
|
||||||
const float max_acc_x = get_axis_max_acceleration(emode, X);
|
|
||||||
const float max_acc_y = get_axis_max_acceleration(emode, Y);
|
|
||||||
const float generic_acc = get_acceleration(emode);
|
|
||||||
const float acc_x = max_acc_x > 0.0f ? max_acc_x : generic_acc;
|
|
||||||
const float acc_y = max_acc_y > 0.0f ? max_acc_y : generic_acc;
|
|
||||||
|
|
||||||
// Jerk = sqrt(2.5 * jd * acc) as per Marlin's junction deviation implementation
|
|
||||||
jx = std::sqrt(jd * acc_x * 2.5f);
|
|
||||||
jy = std::sqrt(jd * acc_y * 2.5f);
|
|
||||||
|
|
||||||
return Vec3f(jx, jy, jz);
|
return Vec3f(jx, jy, jz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1074,6 +1074,7 @@ class Print;
|
|||||||
// per-nozzle machine limits (filament_map_2 / get_config_idx_for_filament).
|
// per-nozzle machine limits (filament_map_2 / get_config_idx_for_filament).
|
||||||
float get_axis_max_feedrate(PrintEstimatedStatistics::ETimeMode mode, Axis axis) const;
|
float get_axis_max_feedrate(PrintEstimatedStatistics::ETimeMode mode, Axis axis) const;
|
||||||
float get_axis_max_acceleration(PrintEstimatedStatistics::ETimeMode mode, Axis axis) const;
|
float get_axis_max_acceleration(PrintEstimatedStatistics::ETimeMode mode, Axis axis) const;
|
||||||
|
float get_axis_max_jerk_with_jd(PrintEstimatedStatistics::ETimeMode mode, Axis axis) const;
|
||||||
float get_axis_max_jerk(PrintEstimatedStatistics::ETimeMode mode, Axis axis) const;
|
float get_axis_max_jerk(PrintEstimatedStatistics::ETimeMode mode, Axis axis) const;
|
||||||
Vec3f get_xyz_max_jerk(PrintEstimatedStatistics::ETimeMode mode) const;
|
Vec3f get_xyz_max_jerk(PrintEstimatedStatistics::ETimeMode mode) const;
|
||||||
float get_retract_acceleration(PrintEstimatedStatistics::ETimeMode mode) const;
|
float get_retract_acceleration(PrintEstimatedStatistics::ETimeMode mode) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user