mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 17:27:52 -06:00
Jerk - per axis maximum limit (#6252)
* Jerk - per axis maximum limit * Fixing Klipper and refactoring * Remove unused variables
This commit is contained in:
parent
98a243c302
commit
a4cfc14a7e
2 changed files with 30 additions and 14 deletions
|
@ -34,8 +34,10 @@ void GCodeWriter::apply_print_config(const PrintConfig &print_config)
|
||||||
std::round((use_mach_limits && supports_separate_travel_acceleration(print_config.gcode_flavor.value)) ?
|
std::round((use_mach_limits && supports_separate_travel_acceleration(print_config.gcode_flavor.value)) ?
|
||||||
print_config.machine_max_acceleration_travel.values.front() :
|
print_config.machine_max_acceleration_travel.values.front() :
|
||||||
0));
|
0));
|
||||||
m_max_jerk = std::lrint(
|
if (use_mach_limits) {
|
||||||
use_mach_limits ? std::min(print_config.machine_max_jerk_x.values.front(), print_config.machine_max_jerk_y.values.front()) : 0);
|
m_max_jerk_x = std::lrint(print_config.machine_max_jerk_x.values.front());
|
||||||
|
m_max_jerk_y = std::lrint(print_config.machine_max_jerk_y.values.front());
|
||||||
|
};
|
||||||
m_max_jerk_z = print_config.machine_max_jerk_z.values.front();
|
m_max_jerk_z = print_config.machine_max_jerk_z.values.front();
|
||||||
m_max_jerk_e = print_config.machine_max_jerk_e.values.front();
|
m_max_jerk_e = print_config.machine_max_jerk_e.values.front();
|
||||||
}
|
}
|
||||||
|
@ -230,20 +232,31 @@ std::string GCodeWriter::set_acceleration_internal(Acceleration type, unsigned i
|
||||||
|
|
||||||
std::string GCodeWriter::set_jerk_xy(double jerk)
|
std::string GCodeWriter::set_jerk_xy(double jerk)
|
||||||
{
|
{
|
||||||
// Clamp the jerk to the allowed maximum.
|
|
||||||
if (m_max_jerk > 0 && jerk > m_max_jerk)
|
|
||||||
jerk = m_max_jerk;
|
|
||||||
|
|
||||||
if (jerk < 0.01 || is_approx(jerk, m_last_jerk))
|
if (jerk < 0.01 || is_approx(jerk, m_last_jerk))
|
||||||
return std::string();
|
return std::string();
|
||||||
|
|
||||||
m_last_jerk = jerk;
|
m_last_jerk = jerk;
|
||||||
|
|
||||||
std::ostringstream gcode;
|
std::ostringstream gcode;
|
||||||
if(FLAVOR_IS(gcfKlipper))
|
if (FLAVOR_IS(gcfKlipper)) {
|
||||||
|
// Clamp the jerk to the allowed maximum.
|
||||||
|
if (m_max_jerk_x > 0 && jerk > m_max_jerk_x)
|
||||||
|
jerk = m_max_jerk_x;
|
||||||
|
if (m_max_jerk_y > 0 && jerk > m_max_jerk_y)
|
||||||
|
jerk = m_max_jerk_y;
|
||||||
|
|
||||||
gcode << "SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=" << jerk;
|
gcode << "SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=" << jerk;
|
||||||
else
|
} else {
|
||||||
gcode << "M205 X" << jerk << " Y" << jerk;
|
double jerk_x = jerk;
|
||||||
|
double jerk_y = jerk;
|
||||||
|
// Clamp the axis jerk to the allowed maximum.
|
||||||
|
if (m_max_jerk_x > 0 && jerk > m_max_jerk_x)
|
||||||
|
jerk_x = m_max_jerk_x;
|
||||||
|
if (m_max_jerk_y > 0 && jerk > m_max_jerk_y)
|
||||||
|
jerk_y = m_max_jerk_y;
|
||||||
|
|
||||||
|
gcode << "M205 X" << jerk_x << " Y" << jerk_y;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_is_bbl_printers)
|
if (m_is_bbl_printers)
|
||||||
gcode << std::setprecision(2) << " Z" << m_max_jerk_z << " E" << m_max_jerk_e;
|
gcode << std::setprecision(2) << " Z" << m_max_jerk_z << " E" << m_max_jerk_e;
|
||||||
|
@ -277,8 +290,10 @@ std::string GCodeWriter::set_accel_and_jerk(unsigned int acceleration, double je
|
||||||
is_empty = false;
|
is_empty = false;
|
||||||
}
|
}
|
||||||
// Clamp the jerk to the allowed maximum.
|
// Clamp the jerk to the allowed maximum.
|
||||||
if (m_max_jerk > 0 && jerk > m_max_jerk)
|
if (m_max_jerk_x > 0 && jerk > m_max_jerk_x)
|
||||||
jerk = m_max_jerk;
|
jerk = m_max_jerk_x;
|
||||||
|
if (m_max_jerk_y > 0 && jerk > m_max_jerk_y)
|
||||||
|
jerk = m_max_jerk_y;
|
||||||
|
|
||||||
if (jerk > 0.01 && !is_approx(jerk, m_last_jerk)) {
|
if (jerk > 0.01 && !is_approx(jerk, m_last_jerk)) {
|
||||||
gcode << " SQUARE_CORNER_VELOCITY=" << jerk;
|
gcode << " SQUARE_CORNER_VELOCITY=" << jerk;
|
||||||
|
|
|
@ -20,7 +20,7 @@ public:
|
||||||
multiple_extruders(false), m_extruder(nullptr),
|
multiple_extruders(false), m_extruder(nullptr),
|
||||||
m_single_extruder_multi_material(false),
|
m_single_extruder_multi_material(false),
|
||||||
m_last_acceleration(0), m_max_acceleration(0),m_last_travel_acceleration(0), m_max_travel_acceleration(0),
|
m_last_acceleration(0), m_max_acceleration(0),m_last_travel_acceleration(0), m_max_travel_acceleration(0),
|
||||||
m_last_jerk(0), m_max_jerk(0),
|
m_last_jerk(0), m_max_jerk_x(0), m_max_jerk_y(0),
|
||||||
m_last_bed_temperature(0), m_last_bed_temperature_reached(true),
|
m_last_bed_temperature(0), m_last_bed_temperature_reached(true),
|
||||||
m_lifted(0),
|
m_lifted(0),
|
||||||
m_to_lift(0),
|
m_to_lift(0),
|
||||||
|
@ -130,7 +130,8 @@ public:
|
||||||
// Limit for setting the acceleration, to respect the machine limits set for the Marlin firmware.
|
// Limit for setting the acceleration, to respect the machine limits set for the Marlin firmware.
|
||||||
// If set to zero, the limit is not in action.
|
// If set to zero, the limit is not in action.
|
||||||
unsigned int m_max_acceleration;
|
unsigned int m_max_acceleration;
|
||||||
double m_max_jerk;
|
double m_max_jerk_x;
|
||||||
|
double m_max_jerk_y;
|
||||||
double m_last_jerk;
|
double m_last_jerk;
|
||||||
double m_max_jerk_z;
|
double m_max_jerk_z;
|
||||||
double m_max_jerk_e;
|
double m_max_jerk_e;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue