Giter Club home page Giter Club logo

octoprint-prusameshmap's Introduction

OctoPrint-PrusaMeshMap

This plugin is undergoing beta testing!

Description

This plugin takes Prusa's G81 mesh level output and translates it into an easy to read heatmap using matplotlib.

Upon installation, you will have a "Prusa Mesh Leveling" tab:

example showing new tab in interface

Clicking "Perform Bed Level and Check" will execute a bed level operation and status check using a GCode script defined in the settings:

example showing GCode script in settings

It should be noted that the heatmap image will not reload automatically. To reload, click "Reload Heatmap Image" below the heatmap. This is to allow you to be paying attention and see how your new bed level result changes.

G81 Output Handler

It should be noted that this plugin has a handler that is watching output received from the printer at all times. This means you can place a G81 in your slicer's GCode start script and have a new heatmap generated every time you print!

Setup

Install via the bundled Plugin Manager or manually using this URL:

https://github.com/PrusaOwners/OctoPrint-PrusaMeshMap/archive/master.zip

Raspberry Pi Users

This plugin uses matplotlib and numpy packages from pip. Since wheels do not exist for these ARM packages in Python 2.7, they will need to compile. This process takes a long time (30min+). If you try to install this directly from Plugin Manager without installing these dependencies first, the compile process will take long enough that OctoPrint errors out the plugin install and quits responding while the install process continues in the background! You can monitor the process with top command via SSH, and when it finishes attempt the plugin install again per the above. It will detect that the plugin is already installed and force a reinstall, and since the dependencies will be there it will go on without issues.

A better method may be to log in to the Pi via SSH before doing the plugin install and pip install the requirements manually.

IMPORTANT! As of this writing, the current versions of matplotlib and numpy require Python3. Python3 is not (again, as of this writing) part of the OctoPrint package. In order to support the older Python 2.7 that is provided with OctoPrint, you will need to specify the older versions of matplotlib and numpy when doing pip install using the following commands:

/home/pi/oprint/bin/pip --no-cache-dir install 'numpy<1.17'
/home/pi/oprint/bin/pip --no-cache-dir install 'matplotlib<3.0'

(The --no-cache-dir is required for Pi Zero W users, may work fine without this on other Pi versions)

This will still take a long time, but will get the packages the plugin depends on in place beforehand. The plugin will then install without issues within a few seconds in Plugin Manager.

octoprint-prusameshmap's People

Contributors

chrisweiss avatar gdombiak avatar koenkooi avatar matthew-humphrey avatar thebrigandier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

octoprint-prusameshmap's Issues

Add other matplotlib color options.

Need to update colormap settings select input to include optgroups with the other color types matplotlib supports. Right now there's only support for the general heatmap specific colors, but it may be helpful and accessible to offer the other color types. The optgroups will let the default colors be sorted towards the top, with the more exotic choices in their own groups below.

7x7 Mesh freeze up

I am having a problem with the heat map freezing up and not changing. I believe it is related to using the G80 N7 command in the modified firmware made by prusa fans which only adds this command to do 7x7 mesh leveling instead of the 3x3 mesh leveling. The heat map works fine when doing the standard G80 command for 3x3. However when using the G80 N7 command it will produce the heat map from the points and then not change again, even when using the standard G80 command. I am able to correct the problem by uninstalling and reinstalling the plugin. That is until I input the G80 N7 command again. Can this be fixed somehow so I don't have to keep on uninstalling and reinstalling the plugin.

Enhancement request: Set range of color scale

I've used the plugin a while and generally have my bed dialed in where I want it. But I do like to check occasionally to make sure it's relatively level. I have GCode added to do the bed level every print. What throws me off now is the autoscaling of the color scheme for the heatmap

What I'd like is to be able to set my own scale, and let the min and max colors be for everything outside my the user-set range. Maybe I pretty sure I'm within 0.10. So I set that as the scale in the plugin. When the plugin gets hold of the real values, it would do something like this:

  • I'm assume the color scale has 7 values.
  • User set scale is 0.10. Let's call that uVar for user variance
  • Get values from the printer, find min and max, and calc the midpoint. Let's call that mid
  • Calc the min and max for the color scale (cMin and cMax) by doing: cMin = mid-(uVar/2) and cMax = mid+(uVar/2)
  • All values lower than cMin get the lowest color in the scale, all values higher than cMax get the highest color in the scale.
  • The remaining five colors are allocated similar to how I think they are now, but using only five values to cover the range between cMin and cMax.

If I have set my scale value wrong, this could lead to a worthless heatmap, but that's my fault. The heatmap would still show me max and min, and total variance so I have enough information to reset my scale to an appropriate value. If I do this right, I think it makes the successive runs while debugging much more intuitive, because the scale is staying constant until I change it.

Enhancement request: add option to enable auto refresh of image

I think it would be useful to have an option to enable auto-refreshing of the heatmap as an option in settings or as a checkbox near the “refresh heatmap” button. Also if it kept a record of the previous (or past few) measurements, you could get the same effect as currently allowing you to compare “before” and “after” heatmaps, while still enabling a “live” view without needing to refresh. (Disclaimer: I have yet to install this plugin, as a long print is currently

Center Relative Mesh Output

Make the bed leveling heat map relative to the center for those using nylock bed leveling. Since we know the center point to be at the proper height, you could get a better total bed variance. Here is a script that can take the results of the g81 command and convert the values to become relative to the center. https://github.com/pcboy/g81_relative

Ran exactly once

The Reload Heatmap Image worked just once, and now doesn't appear to do anything. The Perform Bed Level and Check does work every time. I have it loaded on a RPi Zero W. I am using Chrome. Also does not work using Edge or Firefox.

Issue during Installation

After installing matplotlib and numpy like explained on the front page, I am getting an error when trying to install PrusaMeshMap... Here is the text from the log:

Edit setup.cfg to change the build options
2020-04-21 16:12:10,865 >
2020-04-21 16:12:10,866 > BUILDING MATPLOTLIB
2020-04-21 16:12:10,866 > matplotlib: yes [2.2.5]
2020-04-21 16:12:10,867 > python: yes [2.7.13 (default, Sep 26 2018, 18:42:22) [GCC
2020-04-21 16:12:10,867 > 6.3.0 20170516]]
2020-04-21 16:12:10,868 > platform: yes [linux2]
2020-04-21 16:12:10,868 >
2020-04-21 16:12:10,869 > REQUIRED DEPENDENCIES AND EXTENSIONS
2020-04-21 16:12:10,869 > Traceback (most recent call last):
2020-04-21 16:12:10,869 > File "", line 1, in
2020-04-21 16:12:10,870 > File "/tmp/pip-install-PeybIj/matplotlib/setup.py", line 226, in
2020-04-21 16:12:10,870 > result = package.check()
2020-04-21 16:12:10,871 > File "setupext.py", line 1096, in check
2020-04-21 16:12:10,871 > if not is_min_version(numpy.version, min_version):
2020-04-21 16:12:10,872 > AttributeError: 'module' object has no attribute 'version'
2020-04-21 16:12:10,872 >
2020-04-21 16:12:10,872 > ----------------------------------------
2020-04-21 16:12:11,375 ! Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-PeybIj/matplotlib/

Thoughts?

Measurement Set Point

Would suggest adding the option to make measured values display relative to the center point of the bed, as the firmware z-zero reference is not always useful.

Installation fails due to Matplotlib 3.x requiring python 3.x

The new matplotlib needs python 3 so the dependency check fails and install ends in error. I encountered this while trying to install on a raspberry pi zero w.

I worked around this by manually installing marplotlib 2.x pip install ‘matplotlib<3.0’ before manually running the installer.

Installation crashes Octopi on RPi

I ran "/home/pi/oprint/bin/pip install matplotlib numpy " successfully on my RPi 3.
When I tried to install plugin it still tries to get matplotlib-2.2.4.tar.gz and at this point Octoprint server crashes...

Here's what I see in the log:

2019-03-09 20:07:00,106 /home/pi/OctoPrint/venv/bin/python -m pip install https://github.com/PrusaOwners/OctoPrint-PrusaMeshMap/archive/master.zip --no-cache-dir
2019-03-09 20:07:06,141 > Collecting https://github.com/PrusaOwners/OctoPrint-PrusaMeshMap/archive/master.zip
2019-03-09 20:07:07,144 > Downloading https://github.com/PrusaOwners/OctoPrint-PrusaMeshMap/archive/master.zip
2019-03-09 20:07:10,362 > Requirement already satisfied: OctoPrint in /home/pi/OctoPrint/venv/lib/python2.7/site-packages (from OctoPrint-PrusaMeshMap==0.3.0)
2019-03-09 20:07:11,365 > Collecting matplotlib>=2.2.0 (from OctoPrint-PrusaMeshMap==0.3.0)
2019-03-09 20:07:15,370 > Downloading https://files.pythonhosted.org/packages/1e/20/2032ad99f0dfe0f60970941af36e8d0942d3713f442bb3df37ac35d67358/matplotlib-2.2.4.tar.gz (37.0MB)

I'm running OctoPrint 1.3.10
It looks like I already have matplotlib installed:

matplotlib.version
'2.2.4'

Matplotlib needs a version check

I had matplotlib 2.0.2 installed, which triggers

Apr 02 16:54:56 raspberrypi2 octoprint[305]: Traceback (most recent call last):
Apr 02 16:54:56 raspberrypi2 octoprint[305]:   File "/usr/lib/python2.7/site-packages/octoprint/plugin/core.py", line 829, in _import_plugin
Apr 02 16:54:56 raspberrypi2 octoprint[305]:     instance = imp.load_module(key, f, filename, description)
Apr 02 16:54:56 raspberrypi2 octoprint[305]:   File "/usr/lib/python2.7/site-packages/octoprint_PrusaMeshMap/__init__.py", line 16, in <module>
Apr 02 16:54:56 raspberrypi2 octoprint[305]:     import matplotlib.pyplot as plt
Apr 02 16:54:56 raspberrypi2 octoprint[305]:   File "/usr/lib/python2.7/site-packages/matplotlib/pyplot.py", line 29, in <module>
Apr 02 16:54:56 raspberrypi2 octoprint[305]:     import matplotlib.colorbar
Apr 02 16:54:56 raspberrypi2 octoprint[305]:   File "/usr/lib/python2.7/site-packages/matplotlib/colorbar.py", line 32, in <module>
Apr 02 16:54:56 raspberrypi2 octoprint[305]:     import matplotlib.artist as martist
Apr 02 16:54:56 raspberrypi2 octoprint[305]:   File "/usr/lib/python2.7/site-packages/matplotlib/artist.py", line 15, in <module>
Apr 02 16:54:56 raspberrypi2 octoprint[305]:     from .transforms import (Bbox, IdentityTransform, TransformedBbox,
Apr 02 16:54:56 raspberrypi2 octoprint[305]:   File "/usr/lib/python2.7/site-packages/matplotlib/transforms.py", line 39, in <module>
Apr 02 16:54:56 raspberrypi2 octoprint[305]:     from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
Apr 02 16:54:56 raspberrypi2 octoprint[305]: ImportError: No module named _path

According to https://stackoverflow.com/questions/30196585/matplotlib-import-error-no-module-named-path a newer version needed, pip says 2.2.2 is the newest.

Skewed values?

I'm having issues with meshmaps looking really weird.
This is the output of the last mesh level I did:

Recv: 0.57916 0.69395 0.74104 0.72044 0.63213 0.47613 0.25244
Recv: 0.49286 0.55855 0.58028 0.55804 0.49182 0.38163 0.22747
Recv: 0.41086 0.43527 0.43449 0.40852 0.35735 0.28099 0.17944
Recv: 0.33316 0.32410 0.30367 0.27188 0.22873 0.17421 0.10833
Recv: 0.25977 0.22504 0.18782 0.14813 0.10595 0.06129 0.01414
Recv: 0.19067 0.13809 0.08695 0.03726 -0.01098 -0.05777 -0.10312
Recv: 0.12588 0.06325 0.00104 -0.06073 -0.12207 -0.18297 -0.24345

All columns have values that decrease each row. The image I got however, looks like this:

image

After much hair-tearing, I think this image only contains the first two rows of the last mesh level, and that the rest of the rows are from the previous level.

Flipped Bed

It appears that my bed is flipped on the Y axis. On the other Bed Visualizer I can flip my bed, is there a method of doing this in PrusaMeshMap? Or something I can set within OctoPrint?

Image link is broken if OctoPrint is not at root of website

Great work, thank you for sharing this!
I run my OctoPrint behind a reverse proxy and it is under the subdirectory /print. So I access it as https://mysite.com/print/. It works fine with my nginx server sending the X-Script-Name attribute correctly in the header. The image URL generated by this plugin (https://mysite.com/plugin/PrusaMeshMap/static/img/heatmap.png) is missing that subdirectory, so it won't load properly.
I confirmed that the plugin works fine when I access OctoPrint within my LAN bypassing the reverse proxy.
Thanks for looking into this!
Edit: the proxy pass header that makes my set up work is proxy_set_header X-Script-Name /print;, not X-Forwarded-For. Here are the instructions on OctoPrint.org that I followed to get the core UI and other plugins work this way.

Some sort of marlin support

i know this is for prusa printers, but i have a mendel90 with the mk42 bed on it and i have figured how to setup bi-linear leveling so that it hits the 9 probe points

but i have always missed something that could easy do a verification of how good my bed is

so i hope that some sort of marlin support could be put in to the mix

Reload Heatmap Image

I have tries many times to reload image. No response. Can not tell if the button works or is working on bringing it up. I prefer Firefox.

Try to match heatmap scale to bed dimensions

The heatmap scale currently covers approximately -1 to +7 on x and y, while the print area is approximately 20 x 25cm.

heatmap

An overlay showing the bed outline and/or screw locations would be even better :)

Installation issues with Octopi

Hi I am trying to install this plugin on my RPI Octopi and it fails. Can you offer any guidance?

First it failed because PIP was out of date so I updated it with the command..

/home/pi/oprint/bin/pip install --upgrade pip

Then had also seen the note about updating matplotlib and numpy on the raspberry pi so ran

/home/pi/oprint/bin/pip --no-cache-dir install matplotlib numpy

These both ran correctly but I get this install issue in the log file when I try and install from the octoprint plugin manager from URL.

2018-11-12 15:22:48,775   /home/pi/oprint/bin/python -m pip install https://github.com/PrusaOwners/OctoPrint-PrusaMeshMap --no-cache-dir
2018-11-12 15:22:52,114 > Collecting https://github.com/PrusaOwners/OctoPrint-PrusaMeshMap
2018-11-12 15:22:52,115 > Downloading https://github.com/PrusaOwners/OctoPrint-PrusaMeshMap
2018-11-12 15:22:52,617 ! Cannot unpack file /tmp/pip-unpack-3f5beY/OctoPrint-PrusaMeshMap (downloaded from /tmp/pip-req-build-NU5fUZ, content-type: text/html; charset=utf-8); cannot detect archive format
2018-11-12 15:22:52,617 ! Cannot determine archive format of /tmp/pip-req-build-NU5fUZ

"Reload Heatmap Image" doesn't do anything

After clicking "Perform Bed Level and Check", and the printer completes it's 7x7 grid, I see all the G81 values reported int he terminal. I click "Reload Heatmap Image", but no image is displayed (the example image disappears, and both buttons appear on above the other).

Let me know what logs (if any) I should be looking at to troubleshoot and I'll paste them here.

Not seeing plugin on one machine

I installed the plugin to my Pi Zero W from my desktop computer and it shows up there in OctoPrint, but when I open OctoPrint on my laptop (next to the printer) the plugin does not show in OctoPrint. It shouldn't have to loaded from there as I understand it.

Show total bed level variance

Like the title say it would be nice to have a number displayed that is the total variance be between the lowest and highest point on the bed

Add heatmap "averaging"

The PINDA has some variance reading to reading. Would be nice to add a function to do the G80 multiple times and average the results. This will allow us to perform even more fine tuned leveling of the bed using wave springs.

Missing dependencies in setup.py

I'm using a minimal OS to run octoprint, so only python modules in setup.py will be installed, which triggered this:

Apr 02 16:48:59 raspberrypi2 octoprint[32504]: 2018-04-02 16:48:59,568 - octoprint.plugin.core - ERROR - Error loading plugin PrusaMeshMap
Apr 02 16:48:59 raspberrypi2 octoprint[32504]: Traceback (most recent call last):
Apr 02 16:48:59 raspberrypi2 octoprint[32504]:   File "/usr/lib/python2.7/site-packages/octoprint/plugin/core.py", line 829, in _import_plugin
Apr 02 16:48:59 raspberrypi2 octoprint[32504]:     instance = imp.load_module(key, f, filename, description)
Apr 02 16:48:59 raspberrypi2 octoprint[32504]:   File "/usr/lib/python2.7/site-packages/octoprint_PrusaMeshMap/__init__.py", line 14, in <module>
Apr 02 16:48:59 raspberrypi2 octoprint[32504]:     import matplotlib
Apr 02 16:48:59 raspberrypi2 octoprint[32504]:   File "/usr/lib/python2.7/site-packages/matplotlib/__init__.py", line 124, in <module>
Apr 02 16:48:59 raspberrypi2 octoprint[32504]:     from matplotlib.rcsetup import (defaultParams,
Apr 02 16:48:59 raspberrypi2 octoprint[32504]:   File "/usr/lib/python2.7/site-packages/matplotlib/rcsetup.py", line 32, in <module>
Apr 02 16:48:59 raspberrypi2 octoprint[32504]:     from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
Apr 02 16:48:59 raspberrypi2 octoprint[32504]:   File "/usr/lib/python2.7/site-packages/matplotlib/fontconfig_pattern.py", line 25, in <module>
Apr 02 16:48:59 raspberrypi2 octoprint[32504]:     from pyparsing import Literal, ZeroOrMore, \
Apr 02 16:48:59 raspberrypi2 octoprint[32504]: ImportError: No module named pyparsing

After installing pyparsing ccycler is the next missing dep:

Apr 02 16:52:33 raspberrypi2 octoprint[32688]: 2018-04-02 16:52:33,522 - octoprint.plugin.core - ERROR - Error loading plugin PrusaMeshMap
Apr 02 16:52:33 raspberrypi2 octoprint[32688]: Traceback (most recent call last):
Apr 02 16:52:33 raspberrypi2 octoprint[32688]:   File "/usr/lib/python2.7/site-packages/octoprint/plugin/core.py", line 829, in _import_plugin
Apr 02 16:52:33 raspberrypi2 octoprint[32688]:     instance = imp.load_module(key, f, filename, description)
Apr 02 16:52:33 raspberrypi2 octoprint[32688]:   File "/usr/lib/python2.7/site-packages/octoprint_PrusaMeshMap/__init__.py", line 14, in <module>
Apr 02 16:52:33 raspberrypi2 octoprint[32688]:     import matplotlib
Apr 02 16:52:33 raspberrypi2 octoprint[32688]:   File "/usr/lib/python2.7/site-packages/matplotlib/__init__.py", line 124, in <module>
Apr 02 16:52:33 raspberrypi2 octoprint[32688]:     from matplotlib.rcsetup import (defaultParams,
Apr 02 16:52:33 raspberrypi2 octoprint[32688]:   File "/usr/lib/python2.7/site-packages/matplotlib/rcsetup.py", line 37, in <module>
Apr 02 16:52:33 raspberrypi2 octoprint[32688]:     from cycler import Cycler, cycler as ccycler
Apr 02 16:52:33 raspberrypi2 octoprint[32688]: ImportError: No module named cycler

Doesn't work with the Prusa Mini

It seems the Prusa Mini outputs the mesh after performing the bed level, which is M29, not the M80. M80 and M81 are 'Unrecognised' commands.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.