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

pa calib: batch mode for pa pattern #7199

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5b5ee7e
pa calib: batch mode option
buzzhuzz Oct 22, 2024
47fce7a
pa pattern: support for batch mode
buzzhuzz Oct 22, 2024
10fa878
code cleanup
buzzhuzz Oct 23, 2024
692d910
pa pattern: clear destination vector on string parse
buzzhuzz Oct 24, 2024
09e002c
Put handle cube inside the test pattern
buzzhuzz Oct 24, 2024
21d1f7a
pa pattern: rework object manipulation to not use gizmos
buzzhuzz Oct 25, 2024
c1e375c
pa pattern: merge calib 'handle' with test pattern
buzzhuzz Oct 25, 2024
331e151
Remove debug print
buzzhuzz Oct 26, 2024
38003cc
fix cube position on cloned plates
buzzhuzz Oct 26, 2024
7993063
Merge remote-tracking branch 'upstream/main' into dbuzz/pa-pattern-ba…
buzzhuzz Oct 26, 2024
a0969d2
pa pattern: test generation for single and batch modes
buzzhuzz Oct 27, 2024
d06883f
pa pattern: work with object reference
buzzhuzz Oct 25, 2024
aaf78c6
CalibPressureAdvancePattern to privide anchro object offset
buzzhuzz Oct 27, 2024
8311321
pa pattern: multiple anchor object per plate
buzzhuzz Oct 27, 2024
cae30e2
pa pattern: multiple tests on single plate
buzzhuzz Oct 27, 2024
5058d88
pa pattern: force update flow and accel on each test layer pass
buzzhuzz Oct 27, 2024
00545f8
Merge remote-tracking branch 'upstream/main' into dbuzz/pa-pattern-ba…
buzzhuzz Oct 27, 2024
6d462ce
pa pattern: correctly assign object to the plate
buzzhuzz Oct 28, 2024
eaaabf6
pa pattern: re-generate custom test gcode on plate reslicing
buzzhuzz Oct 29, 2024
55620a3
pa pattern: multiple columns per plate
buzzhuzz Oct 29, 2024
2d7c948
pa pattern batch mode for Rect plates only
buzzhuzz Oct 29, 2024
138a233
pa pattern: arrange objects using arrangement::arrange
buzzhuzz Oct 30, 2024
0079855
Merge remote-tracking branch 'upstream/main' into dbuzz/pa-pattern-ba…
buzzhuzz Dec 1, 2024
ce7082e
pa calib: remove "batch mode" checkbox
buzzhuzz Dec 1, 2024
70e1c0e
pa pattern: show warning on default values
buzzhuzz Dec 1, 2024
41b31d8
Merge branch 'main' into dbuzz/pa-pattern-batch-mode
SoftFever Dec 24, 2024
2fb347c
Merge remote-tracking branch 'upstream/main' into dbuzz/pa-pattern-ba…
buzzhuzz Dec 29, 2024
2945bea
Add calib objects into the object list
buzzhuzz Dec 29, 2024
664d962
pa calib: use volumetric speed as input for a batch mode
buzzhuzz Dec 29, 2024
3c0d691
pa pattern batch mode: show warning if flow is higher than max
buzzhuzz Dec 29, 2024
08555bf
calib_dlg: make text fields wider
buzzhuzz Dec 29, 2024
2dfcbd1
Revert "pa pattern batch mode: show warning if flow is higher than max"
buzzhuzz Jan 12, 2025
335fe77
Revert "pa calib: use volumetric speed as input for a batch mode"
buzzhuzz Jan 12, 2025
4f44310
Merge remote-tracking branch 'upstream/main' into dbuzz/pa-pattern-ba…
buzzhuzz Jan 12, 2025
9db3fa1
pa batch: add special case for single object calib
buzzhuzz Jan 12, 2025
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
61 changes: 39 additions & 22 deletions src/libslic3r/calib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,12 +538,19 @@ void CalibPressureAdvanceLine::delta_modify_start(double &startx, double &starty
}

CalibPressureAdvancePattern::CalibPressureAdvancePattern(
const Calib_Params &params, const DynamicPrintConfig &config, bool is_bbl_machine, Model &model, const Vec3d &origin)
const Calib_Params &params, const DynamicPrintConfig &config, bool is_bbl_machine, const ModelObject &object, const Vec3d &origin)
: m_params(params),CalibPressureAdvance(config)
{
this->m_draw_digit_mode = DrawDigitMode::Bottom_To_Top;

refresh_setup(config, is_bbl_machine, model, origin);
refresh_setup(config, is_bbl_machine, object, origin);
}

Vec3d CalibPressureAdvancePattern::handle_pos_offset() const
{
return Vec3d{0 - print_size_x() / 2 + handle_xy_size() / 2 + handle_spacing(),
0 - max_numbering_height() / 2 - m_glyph_padding_vertical,
max_layer_z() / 2};
}

double CalibPressureAdvancePattern::flow_val() const
Expand All @@ -552,21 +559,21 @@ double CalibPressureAdvancePattern::flow_val() const
double nozzle_diameter = m_config.option<ConfigOptionFloats>("nozzle_diameter")->get_at(0);
double line_width = m_config.get_abs_value("line_width", nozzle_diameter);
double layer_height = m_config.get_abs_value("layer_height");
double speed = m_config.opt_float("outer_wall_speed");
double speed = speed_perimeter();
Flow pattern_line = Flow(line_width, layer_height, m_config.option<ConfigOptionFloats>("nozzle_diameter")->get_at(0));

return speed * pattern_line.mm3_per_mm() * flow_mult;
};

void CalibPressureAdvancePattern::generate_custom_gcodes(const DynamicPrintConfig &config,
bool is_bbl_machine,
Model &model,
const Vec3d &origin)
CustomGCode::Info CalibPressureAdvancePattern::generate_custom_gcodes(const DynamicPrintConfig &config,
bool is_bbl_machine,
const ModelObject &object,
const Vec3d &origin)
{
std::stringstream gcode;
gcode << "; start pressure advance pattern for layer\n";

refresh_setup(config, is_bbl_machine, model, origin);
refresh_setup(config, is_bbl_machine, object, origin);

gcode << move_to(Vec2d(m_starting_point.x(), m_starting_point.y()), m_writer, "Move to start XY position");
gcode << m_writer.travel_to_z(height_first_layer() + height_z_offset(), "Move to start Z position");
Expand All @@ -590,6 +597,8 @@ void CalibPressureAdvancePattern::generate_custom_gcodes(const DynamicPrintConfi
const int num_patterns = get_num_patterns(); // "cache" for use in loops

const double zhop_config_value = m_config.option<ConfigOptionFloats>("z_hop")->get_at(0);
const auto accel = accel_perimeter();

// draw pressure advance pattern
for (int i = 0; i < m_num_layers; ++i) {
const double layer_height = height_first_layer() + height_z_offset() + (i * height_layer());
Expand Down Expand Up @@ -637,7 +646,7 @@ void CalibPressureAdvancePattern::generate_custom_gcodes(const DynamicPrintConfi
// acceleration
line_num = num_patterns + 4;
gcode << draw_number(glyph_start_x(line_num), m_starting_point.y() + frame_size_y() + m_glyph_padding_vertical + line_width(),
m_config.opt_float("default_acceleration"), m_draw_digit_mode, line_width(), number_e_per_mm,
accel, m_draw_digit_mode, line_width(), number_e_per_mm,
speed_first_layer(), m_writer);
}

Expand All @@ -653,6 +662,14 @@ void CalibPressureAdvancePattern::generate_custom_gcodes(const DynamicPrintConfi
side_length = m_wall_side_length - shrink;
to_x += shrink * std::sin(to_radians(90) - to_radians(m_corner_angle) / 2);
to_y += line_spacing_first_layer() * (wall_count() - 1) + (line_width_first_layer() * (1 - m_encroachment));
} else {
/* Draw a line at slightly slower accel and speed in order to trick gcode writer to force update acceleration and speed.
* We do this since several tests may be generated by their own gcode writers which are
* not aware about their neighbours updating acceleration/speed */
gcode << m_writer.set_print_acceleration(accel - 10);
gcode << move_to(Vec2d(m_starting_point.x(), m_starting_point.y()), m_writer, "Move to starting point", zhop_height, layer_height);
gcode << draw_line(m_writer, Vec2d(m_starting_point.x(), m_starting_point.y() + frame_size_y()), line_width(), height_layer(), speed_adjust(speed_perimeter() - 10), "Accel/flow trick line");
gcode << m_writer.set_print_acceleration(accel);
}

double initial_x = to_x;
Expand Down Expand Up @@ -713,7 +730,7 @@ void CalibPressureAdvancePattern::generate_custom_gcodes(const DynamicPrintConfi
info.mode = CustomGCode::Mode::SingleExtruder;
info.gcodes = gcode_items;

model.plates_custom_gcodes[model.curr_plate_index] = info;
return info;
}

void CalibPressureAdvancePattern::set_start_offset(const Vec3d &offset)
Expand All @@ -729,30 +746,30 @@ Vec3d CalibPressureAdvancePattern::get_start_offset()

void CalibPressureAdvancePattern::refresh_setup(const DynamicPrintConfig &config,
bool is_bbl_machine,
const Model &model,
const ModelObject &object,
const Vec3d &origin)
{
m_config = config;
m_config.apply(model.objects.front()->config.get(), true);
m_config.apply(model.objects.front()->volumes.front()->config.get(), true);
m_config.apply(object.config.get(), true);
m_config.apply(object.volumes.front()->config.get(), true);

_refresh_starting_point(model);
_refresh_writer(is_bbl_machine, model, origin);
_refresh_starting_point(object);
_refresh_writer(is_bbl_machine, object, origin);
}

void CalibPressureAdvancePattern::_refresh_starting_point(const Model &model)
void CalibPressureAdvancePattern::_refresh_starting_point(const ModelObject &object)
{
if (m_is_start_point_fixed)
return;

ModelObject *obj = model.objects.front();
BoundingBoxf3 bbox = obj->instance_bounding_box(*obj->instances.front(), false);
BoundingBoxf3 bbox = object.instance_bounding_box(*object.instances.front(), false);

m_starting_point = Vec3d(bbox.min.x(), bbox.max.y(), 0);
m_starting_point.y() += m_handle_spacing;
m_starting_point.x() -= m_handle_spacing;
m_starting_point.y() -= std::sin(to_radians(m_corner_angle) / 2) * m_wall_side_length + (bbox.max.y() - bbox.min.y()) / 2;
}

void CalibPressureAdvancePattern::_refresh_writer(bool is_bbl_machine, const Model &model, const Vec3d &origin)
void CalibPressureAdvancePattern::_refresh_writer(bool is_bbl_machine, const ModelObject &object, const Vec3d &origin)
{
PrintConfig print_config;
print_config.apply(m_config, true);
Expand All @@ -761,7 +778,7 @@ void CalibPressureAdvancePattern::_refresh_writer(bool is_bbl_machine, const Mod
m_writer.set_xy_offset(origin(0), origin(1));
m_writer.set_is_bbl_machine(is_bbl_machine);

const unsigned int extruder_id = model.objects.front()->volumes.front()->extruder_id();
const unsigned int extruder_id = object.volumes.front()->extruder_id();
m_writer.set_extruders({extruder_id});
m_writer.set_extruder(extruder_id);
}
Expand Down Expand Up @@ -837,7 +854,7 @@ size_t CalibPressureAdvancePattern::max_numbering_length() const
}
}

std::string sAccel = convert_number_to_string(m_config.opt_float("default_acceleration"));
std::string sAccel = convert_number_to_string(accel_perimeter());
most_characters = std::max(most_characters, sAccel.length());

/* don't actually check flow value: we'll print as many fractional digits as fits */
Expand Down
18 changes: 12 additions & 6 deletions src/libslic3r/calib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ struct Calib_Params
Calib_Params() : mode(CalibMode::Calib_None){};
double start, end, step;
bool print_numbers;

std::vector<double> accelerations;
std::vector<double> speeds;

CalibMode mode;
};

Expand Down Expand Up @@ -249,23 +253,25 @@ class CalibPressureAdvancePattern : public CalibPressureAdvance

public:
CalibPressureAdvancePattern(
const Calib_Params &params, const DynamicPrintConfig &config, bool is_bbl_machine, Model &model, const Vec3d &origin);
const Calib_Params &params, const DynamicPrintConfig &config, bool is_bbl_machine, const ModelObject &object, const Vec3d &origin);

double handle_xy_size() const { return m_handle_xy_size; };
double handle_spacing() const { return m_handle_spacing; };
Vec3d handle_pos_offset() const;
double print_size_x() const { return object_size_x() + pattern_shift(); };
double print_size_y() const { return object_size_y(); };
double max_layer_z() const { return height_first_layer() + ((m_num_layers - 1) * height_layer()); };
double flow_val() const;

void generate_custom_gcodes(const DynamicPrintConfig &config, bool is_bbl_machine, Model &model, const Vec3d &origin);
CustomGCode::Info generate_custom_gcodes(const DynamicPrintConfig &config, bool is_bbl_machine, const ModelObject &object, const Vec3d &origin);

void set_start_offset(const Vec3d &offset);
Vec3d get_start_offset();

protected:
double speed_first_layer() const { return m_config.option<ConfigOptionFloat>("initial_layer_speed")->value; };
double speed_perimeter() const { return m_config.option<ConfigOptionFloat>("outer_wall_speed")->value; };
double accel_perimeter() const { return m_config.option<ConfigOptionFloat>("outer_wall_acceleration")->value; }
double line_width_first_layer() const
{
// TODO: FIXME: find out current filament/extruder?
Expand All @@ -281,9 +287,9 @@ class CalibPressureAdvancePattern : public CalibPressureAdvance
int wall_count() const { return m_config.option<ConfigOptionInt>("wall_loops")->value; };

private:
void refresh_setup(const DynamicPrintConfig &config, bool is_bbl_machine, const Model &model, const Vec3d &origin);
void _refresh_starting_point(const Model &model);
void _refresh_writer(bool is_bbl_machine, const Model &model, const Vec3d &origin);
void refresh_setup(const DynamicPrintConfig &config, bool is_bbl_machine, const ModelObject &object, const Vec3d &origin);
void _refresh_starting_point(const ModelObject &object);
void _refresh_writer(bool is_bbl_machine, const ModelObject &object, const Vec3d &origin);

double height_first_layer() const { return m_config.option<ConfigOptionFloat>("initial_layer_print_height")->value; };
double height_z_offset() const { return m_config.option<ConfigOptionFloat>("z_offset")->value; };
Expand Down Expand Up @@ -319,7 +325,7 @@ class CalibPressureAdvancePattern : public CalibPressureAdvance
bool m_is_start_point_fixed = false;

const double m_handle_xy_size{5};
const double m_handle_spacing{2};
const double m_handle_spacing{1.2};
const int m_num_layers{4};

const double m_wall_side_length{30.0};
Expand Down
Loading
Loading