Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UX: check and warn users if print speed/accel/jerk are higher than the machine limits #4403

Merged
merged 1 commit into from
Mar 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 100 additions & 10 deletions src/libslic3r/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1419,17 +1419,107 @@ StringObjectException Print::validate(StringObjectException *warning, Polygons*
}
}

if (warning && (m_default_object_config.default_jerk == 1 || m_default_object_config.outer_wall_jerk == 1 ||
m_default_object_config.inner_wall_jerk == 1)) {
warning->string = L("Setting the jerk speed too low could lead to artifacts on curved surfaces");
if (m_default_object_config.outer_wall_jerk == 1)
warning->opt_key = "outer_wall_jerk";
else if (m_default_object_config.inner_wall_jerk == 1)
warning->opt_key = "inner_wall_jerk";
else
warning->opt_key = "default_jerk";
}
// check if print speed/accel/jerk is higher than the maximum speed of the printer
if (warning) {
try {
auto check_motion_ability_object_setting = [&](const std::initializer_list<const char*>& keys_to_check,
double limit) -> std::string {
std::string warning_key;
for (const auto& key : keys_to_check) {
if (m_default_object_config.get_abs_value(key) > limit) {
warning_key = key;
break;
}
}
return warning_key;
};
auto check_motion_ability_region_setting = [&](const std::initializer_list<const char*>& keys_to_check,
double limit) -> std::string {
std::string warning_key;
for (const auto& key : keys_to_check) {
if (m_default_region_config.get_abs_value(key) > limit) {
warning_key = key;
break;
}
}
return warning_key;
};
std::string warning_key;

// check jerk
if (m_default_object_config.default_jerk == 1 || m_default_object_config.outer_wall_jerk == 1 ||
m_default_object_config.inner_wall_jerk == 1) {
warning->string = L("Setting the jerk speed too low could lead to artifacts on curved surfaces");
if (m_default_object_config.outer_wall_jerk == 1)
warning_key = "outer_wall_jerk";
else if (m_default_object_config.inner_wall_jerk == 1)
warning_key = "inner_wall_jerk";
else
warning_key = "default_jerk";

warning->opt_key = warning_key;
}

if (warning_key.empty() && m_default_object_config.default_jerk > 0) {
auto jerk_to_check = {"default_jerk", "outer_wall_jerk", "inner_wall_jerk", "infill_jerk",
"top_surface_jerk", "initial_layer_jerk", "travel_jerk"};
const auto max_jerk = std::min(m_config.machine_max_jerk_x.values[0], m_config.machine_max_jerk_y.values[0]);
warning_key.clear();
if (m_default_object_config.default_jerk > 0)
warning_key = check_motion_ability_object_setting(jerk_to_check, max_jerk);
if (!warning_key.empty()) {
warning->string = L("The jerk is set higher than the printer's maximum jerk "
"(machine_max_jerk_x/machine_max_jerk_y), resulting in the jerk speed being capped.\nYou might "
"consider increasing the maximum jerk in your printer settings.");
warning->opt_key = warning_key;
}
}

// check acceleration
if (warning_key.empty() && m_default_object_config.default_acceleration > 0) {
auto accel_to_check = {
"default_acceleration",
"inner_wall_acceleration",
"outer_wall_acceleration",
"bridge_acceleration",
"initial_layer_acceleration",
"sparse_infill_acceleration",
"internal_solid_infill_acceleration",
"top_surface_acceleration",
"travel_acceleration",
};
const auto max_accel = m_config.machine_max_acceleration_extruding.values[0];
warning_key = check_motion_ability_object_setting(accel_to_check, max_accel);
if (!warning_key.empty()) {
warning->string = L(
"The acceleration is set higher than the printer's maximum extruding acceleration "
"(machine_max_acceleration_extruding), resulting in the print acceleration being capped.\nYou might "
"consider increasing the maximum acceleration in your printer settings.");
warning->opt_key = warning_key;
}
}

// check speed
if (warning_key.empty()) {
auto speed_to_check = {"inner_wall_speed", "outer_wall_speed", "sparse_infill_speed", "internal_solid_infill_speed",
"top_surface_speed", "bridge_speed", "internal_bridge_speed", "gap_infill_speed"};
const auto max_speed = std::min(m_config.machine_max_speed_x.values[0], m_config.machine_max_speed_y.values[0]);
warning_key.clear();
warning_key = check_motion_ability_region_setting(speed_to_check, max_speed);
if (warning_key.empty() && m_config.travel_speed > max_speed)
warning_key = "travel_speed";
if (!warning_key.empty()) {
warning->string = L("The speed is set higher than the printer's maximum speed "
"(machine_max_speed_x/machine_max_speed_y), resulting in the print speed being capped.\nYou might "
"consider increasing the maximum speed in your printer settings.");
warning->opt_key = warning_key;
}
}

} catch (std::exception& e) {
BOOST_LOG_TRIVIAL(warning) << "Orca: validate motion ability failed: " << e.what() << std::endl;
}
}
return {};
}

Expand Down
Loading