Skip to content

Commit

Permalink
Merge pull request #11 from Fabi0San/devel
Browse files Browse the repository at this point in the history
* Moving away from Bootstrap 2 collapsible controls as they are buggy, Fixes #10
* Leveraging Marlin's [newly introduced](MarlinFirmware/Marlin#18423) ability to configure DIAGONAL_ROD_TRIM via M665. Fixes #6
* Instructs Marling to not raise the probe on every probe point, especially helpful to manually deployed probes. Fixes #3
* Improves instructions, mentions useful Marlin configs.
* Discontinue use of deprecated THREE.js API issuing warning on console.
  • Loading branch information
Fabi0San authored Jun 28, 2020
2 parents fe59b37 + 29b2e97 commit 56a9eb2
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 102 deletions.
87 changes: 24 additions & 63 deletions extras/DuCalibrator.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,83 +7,44 @@ description: An OctoPrint Plugin for performing micro calibration in linear delt
author: Fabio Santos
license: AGPLv3

# TODO
date: today's date in format YYYY-MM-DD, e.g. 2015-04-21
date: 2020-06-24

homepage: https://github.com/Fabi0San/DuCalibrator
source: https://github.com/Fabi0San/DuCalibrator
archive: https://github.com/Fabi0San/DuCalibrator/archive/master.zip

# TODO
# Set this to true if your plugin uses the dependency_links setup parameter to include
# library versions not yet published on PyPi. SHOULD ONLY BE USED IF THERE IS NO OTHER OPTION!
#follow_dependency_links: false

# TODO
tags:
- a list
- of tags
- that apply
- to your plugin
- (take a look at the existing plugins for what makes sense here)
- delta
- calibration
- 3d
- visualization

# TODO
screenshots:
- url: url of a screenshot, /assets/img/...
alt: alt-text of a screenshot
caption: caption of a screenshot
- url: url of another screenshot, /assets/img/...
alt: alt-text of another screenshot
caption: caption of another screenshot
- ...
- url: /assets/img/plugins/DuCalibrator/screenshot.png
alt: Screenshot
caption: Main calibration tab showing the full calibration workflow.

# TODO
featuredimage: url of a featured image for your plugin, /assets/img/...
compatibility:
python: ">=2.7,<4"

# TODO
# You only need the following if your plugin requires specific OctoPrint versions or
# specific operating systems to function - you can safely remove the whole
# "compatibility" block if this is not the case.
featuredimage: /assets/img/plugins/DuCalibrator/screenshot.png

compatibility:
---

# List of compatible versions
#
# A single version number will be interpretated as a minimum version requirement,
# e.g. "1.3.1" will show the plugin as compatible to OctoPrint versions 1.3.1 and up.
# More sophisticated version requirements can be modelled too by using PEP440
# compatible version specifiers.
#
# You can also remove the whole "octoprint" block. Removing it will default to all
# OctoPrint versions being supported.
# Delta Micro Calibrator "ΔµCalibrator"
An [OctoPrint](https://octoprint.org/) Plugin for performing micro calibration in linear delta machines.

octoprint:
- 1.2.0
[README](https://github.com/Fabi0San/DuCalibrator/blob/master/README.md)

# List of compatible operating systems
#
# Valid values:
#
# - windows
# - linux
# - macos
# - freebsd
#
# There are also two OS groups defined that get expanded on usage:
#
# - posix: linux, macos and freebsd
# - nix: linux and freebsd
#
# You can also remove the whole "os" block. Removing it will default to all
# operating systems being supported.
## Key features:
* Automatic probing
* Calibrates up to 18 geometry parameters
* 3D visualization of probed points and estimated points after proposed calibration

os:
- linux
- windows
- macos
- freebsd
![Screenshot](/assets/img/plugins/DuCalibrator/screenshot.png)

---
## Demo

{% include youtube.html vid="kTJlOl7_X2M" preview="'/assets/img/plugins/DuCalibrator/screenshot.png'" %}

**TODO**: Longer description of your plugin, configuration examples etc. This part will be visible on the page at
http://plugins.octoprint.org/plugin/DuCalibrator/
Watch it in full screen
21 changes: 7 additions & 14 deletions octoprint_DuCalibrator/static/js/DuCalCommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,28 +85,21 @@ class ProbePoint
}

class CollapseControl {
constructor(id) {
this.controlElement = $(id)[0];
constructor() {
this.Visible = ko.observable(false);
}

IsCollapsed() {
return this.controlElement.classList.contains("collapsed");
}

Toggle() {
this.controlElement.click();
get IsHidden()
{
return !this.Visible();
}

Hide() {
if (!this.IsCollapsed()) {
this.Toggle();
}
this.Visible(false);
}

Show() {
if (this.IsCollapsed()) {
this.Toggle();
}
this.Visible(true);
}
}

Expand Down
6 changes: 3 additions & 3 deletions octoprint_DuCalibrator/static/js/DuCalMachine.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,18 @@ class MarlinMachine extends RealMachine
idsTowerAngleOffset: "XYZ",
idsEndStopOffset: "XYZ",
idsStepsPerUnit: "XYZ",
DiagonalRodAdjust: "MNO",
DiagonalRodAdjust: "ABC",
}
}

async ProbeBed(x, y)
async ProbeBed(x, y, retract)
{
this.IsBusy(true);

const commands = [
`${this.commands.Move} Z${this.settings.SafeHeight()}`, // safe height
`${this.commands.Move} X${x.toFixed(5)} Y${y.toFixed(5)}`, // position
`${this.commands.ProbeBed}` // probe
`${this.commands.ProbeBed} E${retract ? 1 : 0}` // probe
];

const response = await this.comms.Execute(commands);
Expand Down
18 changes: 9 additions & 9 deletions octoprint_DuCalibrator/static/js/DuCalViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ class DuCalibratorViewModel {
this.isReadyToCalibrate = ko.observable(false);

this.plotDivElement = $("#surfacePlotDiv")[0];
this.GeometryControl = new CollapseControl("#collapseGeometryControl");
this.PlotControl = new CollapseControl("#collapsePlotControl");
this.CalibrationControl = new CollapseControl("#collapseCalibrationControl");
this.GeometryControl = new CollapseControl();
this.PlotControl = new CollapseControl();
this.CalibrationControl = new CollapseControl();
this.HistoryControl = new CollapseControl();

// Observable data
this.currentGeometry = ()=>this.machine()?.Geometry();
Expand Down Expand Up @@ -213,14 +214,14 @@ class DuCalibratorViewModel {

var geometry = new THREE.BufferGeometry();
var vertices = new Float32Array(probeCount * 3).fill(0); // x,y,z
geometry.addAttribute('position', new THREE.BufferAttribute(vertices, 3));
geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3));
var probedParticles = new THREE.Points(geometry, new THREE.PointsMaterial({ color: 0xff0000, size: 5, sizeAttenuation: true, transparent: true, opacity: 1 }));
probedParticles.geometry.setDrawRange(0, 0);
scene.add(probedParticles);

var correctedGeometry = new THREE.BufferGeometry();
var correctedVertices = new Float32Array(probeCount * 3).fill(0); // x,y,z
correctedGeometry.addAttribute('position', new THREE.BufferAttribute(correctedVertices, 3));
correctedGeometry.setAttribute('position', new THREE.BufferAttribute(correctedVertices, 3));
var correctedParticles = new THREE.Points(correctedGeometry, new THREE.PointsMaterial({ color: 0x00bb00, size: 5, sizeAttenuation: true }));
correctedParticles.geometry.setDrawRange(0, 0);
scene.add(correctedParticles);
Expand Down Expand Up @@ -340,14 +341,13 @@ class DuCalibratorViewModel {
zScale: 1,
normalizeTo: radius / 3
};


this.PlotControl.Show();
this.plot = this.preparePlot(
this.plotDivElement,
radius,
this.probePointCount());

this.PlotControl.Show();

var points = DuCalUtils.GetSpiralPoints(this.probePointCount(), this.probeRadius());
for(const point of points)
{
Expand All @@ -363,7 +363,7 @@ class DuCalibratorViewModel {

try
{
const probe = await this.machine().ProbeBed(point[0],point[1]);
const probe = await this.machine().ProbeBed(point[0],point[1], point === points[points.length-1]);
if(probe)
this.logProbePoint(probe[0], probe[1], probe[2]);

Expand Down
7 changes: 4 additions & 3 deletions octoprint_DuCalibrator/templates/Calibration.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@

<div class="row-fluid">
<h4>
<i class="fa fa-cog fa-lg fa-spin" data-bind="visible: isCalibrating()"></i><a href="#collapseCalibration" id="collapseCalibrationControl" data-toggle="collapse" class="collapsed" data-bind="visible: isReadyToCalibrate()"><i class="fa fa-caret-right fa-lg"></i><i class="fa fa-caret-down fa-lg"></i></a>
{{ _('Calibration') }} <span data-bind="template: { name: 'ProbingDataTemplate', if:CalibratedData , data: CalibratedData }"></span>
<i class="fa fa-cog fa-lg fa-spin" data-bind="visible: isCalibrating()"></i>
<span data-bind="template: { name: 'CollapseTemplate', if: CalibratedData, data: CalibrationControl }"></span>
{{ _('Calibration') }} <span data-bind="template: { name: 'ProbingDataTemplate', if:CalibratedData, data: CalibratedData }"></span>
<button class="btn btn-primary pull-right" data-bind="click: applyCalibration, enable: isReadyToCalibrate()" title="{{ _('Configure the machine with the calibrated geometry.') }}">{{ _('Apply') }}</button>
</h4>
<div class="row-fluid collapse" id="collapseCalibration">
<div class="row-fluid" data-bind="visible: CalibrationControl.Visible">
<div class="row-fluid">
<div class="span4">
<H5>Parameter</H5>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<input type="number" step="any" min="1" class="input-mini text-right" data-bind="value: settings.SafeHeight" id="settings_SafeHeight">
<span class="add-on">mm</span>
</div>
<span class="help-inline">Safe height that we can travel from probe point to probe point without dragging the probe across the bed.</span>
<span class="help-inline">Safe height that the nozzle can travel from probe point to probe point without dragging the probe across the bed. Should be bigger than your probe z offset.</span>
</div>
</div>
</fieldset>
Expand Down
5 changes: 5 additions & 0 deletions octoprint_DuCalibrator/templates/DuCalibrator_tab.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@
</div>
</div>
</form>

<script type="text/html" id="CollapseTemplate">
<i class="fa fa-caret-down fa-lg" data-bind="click: Hide, visible: Visible"></i>
<i class="fa fa-caret-right fa-lg" data-bind="click: Show, visible: IsHidden"></i>
</script>
7 changes: 5 additions & 2 deletions octoprint_DuCalibrator/templates/Geometry.jinja2
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<div class="row-fluid">
<h4>
<i class="fa fa-cog fa-lg fa-spin" data-bind="visible: isFetchingGeometry()"></i><a href="#collapseGeometry" id="collapseGeometryControl" data-toggle="collapse" class="collapsed" data-bind="visible: machine().Geometry()"><i class="fa fa-caret-right fa-lg"></i><i class="fa fa-caret-down fa-lg"></i></a>
<i class="fa fa-cog fa-lg fa-spin" data-bind="visible: isFetchingGeometry()"></i>
<span data-bind="template: { name: 'CollapseTemplate', if: machine().Geometry() , data: GeometryControl }"></span>
{{ _('Current Geometry') }}
<button class="btn btn-primary pull-right" data-bind="click: fetchGeometry, enable: isReadyForCommands()" title="{{ _('Reads the current geometry from the machine.') }}">{{ _('Fetch Geometry') }}</button>
</h4>
<div class="row-fluid collapse" data-bind="" id="collapseGeometry">
<div class="row-fluid" data-bind="visible: GeometryControl.Visible">
<div class="row-fluid">
<div class="span3">
<H5>Parameter</H5>
Expand Down Expand Up @@ -63,3 +65,4 @@
<div class="span2" data-bind="text: machine().Geometry()?.RadiusAdjust[2].toFixed(4)"></div>
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions octoprint_DuCalibrator/templates/History.jinja2
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div class="row-fluid">
<h4>
<a href="#collapseGeoHistry" data-toggle="collapse" class="collapsed" data-bind="visible: probedGeometries().length > 0"><i class="fa fa-caret-right fa-lg"></i><i class="fa fa-caret-down fa-lg"></i></a>
<span data-bind="template: { name: 'CollapseTemplate', if: probedGeometries().length > 0, data: HistoryControl }"></span>
{{ _('Probing history') }}</h4>

<div class="row-fluid collapse" id="collapseGeoHistry">
<div class="row-fluid" data-bind="visible: HistoryControl.Visible">
<table class="table table-striped table-hover table-condensed table-hover" id="settings_deltaCalibration_probedGeometries">
<thead>
<tr>
Expand Down
5 changes: 3 additions & 2 deletions octoprint_DuCalibrator/templates/Instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ Set the probing parameters.

* Start by running with the simulated printer first to see how things work, it won't send anything to your machine.
* A repeatable probe is essential.
* Repeatable end stops are very important, stepper phase homing is ideal. (I've recently added that to Marlin)
* Repeatable end stops are very important, stepper phase homing is ideal. (I've [recently added that to Marlin](https://github.com/MarlinFirmware/Marlin/pull/17299), look for TMC_HOME_PHASE)
* Precision of measurements is also important, Marlin's default 2 fractional digits are not enough, use SERIAL_FLOAT_PRECISION >=4 (Also [recently added to Marlin](https://github.com/MarlinFirmware/Marlin/pull/18367) bugfix branch)
* The bed must be very flat, borosilicate, or aluminum with fused pcb, or pcb should work fine, magnet mats and textured covers may introduce too much fluctuation.
* Tune down the max acceleration for best repeatability.
* Some geometry factors may be dependent or correlated so they can't be calibrated together, the ui will try to enforce what is possible.
* Not all firmware flavors support individual adjustment for arm lengths and tower radius, some don't support automated setting of them and need to recompile.
* Not all firmware flavors support individual adjustment for arm lengths and tower radius, some don't support automated setting of them and need to recompile. (M665 ABC [recently added to Marlin](https://github.com/MarlinFirmware/Marlin/pull/18423) bugfix branch.)
* More points will make calibration to offset probe noise and converge faster, 7 is too little, 50 is a good number, 500 things start to get slow, 5000 will take a while to complete and not be much better than 500.
* When probing a flat target, steps per unit errors are ambiguous to radius and arm length. I suggest you use a machinist dial to calibrate steps per unit then calibrate the other geometry factors.
* Belts significantly stretch and shrink with room temperature and humidity fluctuations, radius and arms lentgth won't change significantly, so if you see a drift on your bed flatness you can calibrate steps per unit daily without touching factors you know didn't change.
Expand Down
6 changes: 4 additions & 2 deletions octoprint_DuCalibrator/templates/Probing.jinja2
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<div class="row-fluid">
<script type="text/html" id="ProbingDataTemplate">
<span data-bind="visible: RMS">
{{ _('RMS') }}: <span data-bind="text: RMS.toFixed(3)"></span>
Expand All @@ -6,12 +7,12 @@
</span>
</script>
<h4>
<i class="fa fa-cog fa-lg fa-spin" data-bind="visible: isProbing()"></i><a href="#collapsePlot" id="collapsePlotControl" data-toggle="collapse" class="collapsed" data-bind="visible: ProbedData().RMS"><i class="fa fa-caret-right fa-lg"></i><i class="fa fa-caret-down fa-lg"></i></a>
<i class="fa fa-cog fa-lg fa-spin" data-bind="visible: isProbing()"></i><span data-bind="template: { name: 'CollapseTemplate', if: ProbedData().RMS, data: PlotControl }"></span>
{{ _('Probing') }} <span data-bind="template: { name: 'ProbingDataTemplate', if:ProbedData().RMS , data: ProbedData }"></span>
<button class="btn btn-primary pull-right" data-bind="click: probeBed, visible: !isProbing(), enable: isReadyForCommands() && isGeometryKnown()">{{ _('Probe bed') }}</button>
<button class="btn btn-danger pull-right" data-bind="click: cancelProbing, visible: isProbing()"><i class="fa fa-stop"></i> {{ _('Cancel') }}</button>
</h4>
<div class="row-fluid collapse" id="collapsePlot">
<div class="row-fluid" data-bind="visible: PlotControl.Visible">

<div class="progress progress-text-centered" style="position: relative;">
<div class="bar" id="duc_progressBar" data-bind="style: {width: probingProgressString() + '%'}" style="width: 0%;">
Expand All @@ -36,3 +37,4 @@
</div>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
plugin_name = "Delta Micro Calibrator"

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "1.0.3"
plugin_version = "1.0.4"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit 56a9eb2

Please sign in to comment.