support klipper input-shaper

* adds numpy to klipper runtime image
  * adds numpy and matplotlib to mcu image
  * add docker-compose.calibrate-shaper.yaml to simplify data processing
  * updates docs
This commit is contained in:
Markus Küffner
2022-07-08 16:30:23 +02:00
parent 9d5432f435
commit 14b89b0b0b
4 changed files with 44 additions and 1 deletions

3
.gitignore vendored
View File

@@ -1,4 +1,5 @@
klippy-env klippy-env
*_history *_history
out out
*.bkp *.bkp
resonances

View File

@@ -129,6 +129,38 @@ docker compose --profile <profile> up -d
``` ```
## Advanced Topics ## Advanced Topics
### Input Shaper Calibration
Note:
>Running a host_mcu process on a RaspberryPi to access its GPIO pins is currently not possible when running in Docker.
Feel free to contribute if you have a Solution for this.
Using input shaper requires an accelerometer that is directly connected to your printers mainboard. Follow the Docs on [Measuring Resonances](https://www.klipper3d.org/Measuring_Resonances.html), to set up your Printer accordingly.
After running `TEST_RESONANCES` or `SHAPER_CALIBRATE`, Klipper generates csv output in /tmp. To further analyze this data, it has to be extracted from the running klipper container.
```
mkdir ./resonances
docker compose exec klipper ls /tmp
resonances_x_20220708_124515.csv resonances_y_20220708_125150.csv
docker compose cp klipper:/tmp/resonances_x_20220708_124515.csv ./resonances/
docker compose cp klipper:/tmp/resonances_y_20220708_125150.csv ./resonances/
```
`docker-compose.calibrate-shaper.yaml` is set up to run `calibrate_shaper.py`, so any options supported by the script can also be used with the container.
Set an alias to save yourself from typing the the docker compose command multiple times. The generated Images are located besides the csv files in `./resonances`
```
alias calibrate_shaper="docker compose -f docker-compose.calibrate-shaper.yaml run --rm calibrate_shaper"
calibrate_shaper resonances_x_20220708_124515.csv -o cal_x.png
[...]
Recommended shaper is ei @ 90.2 Hz
calibrate_shaper resonances_y_20220708_125150.csv -o cal_y.png
[...]
Recommended shaper is mzv @ 48.2 Hz
```
### Change Execution Options ### Change Execution Options
The Entrypoint for all Docker Images within this Repo are the actual Applications, which are run at container execution time. The Entrypoint for all Docker Images within this Repo are the actual Applications, which are run at container execution time.
This makes it possible to set command line Arguments for the Apps as Docker Command. This makes it possible to set command line Arguments for the Apps as Docker Command.

View File

@@ -0,0 +1,7 @@
services:
calibrate_shaper:
image: mkuf/klipper:${TAG:-latest}-mcu
entrypoint: python3 /opt/klipper/scripts/calibrate_shaper.py
working_dir: /opt/resonances
volumes:
- ./resonances:/opt/resonances

View File

@@ -12,6 +12,7 @@ RUN git clone ${REPO} klipper \
RUN virtualenv -p python2 venv \ RUN virtualenv -p python2 venv \
&& venv/bin/pip install -r klipper/scripts/klippy-requirements.txt \ && venv/bin/pip install -r klipper/scripts/klippy-requirements.txt \
&& venv/bin/pip install numpy \
&& venv/bin/python -m compileall klipper/klippy \ && venv/bin/python -m compileall klipper/klippy \
&& venv/bin/python klipper/klippy/chelper/__init__.py && venv/bin/python klipper/klippy/chelper/__init__.py
@@ -40,6 +41,7 @@ WORKDIR /opt
COPY --from=build /opt/klipper ./klipper COPY --from=build /opt/klipper ./klipper
COPY --from=build /opt/venv ./venv COPY --from=build /opt/venv ./venv
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update \ RUN apt update \
&& apt install -y \ && apt install -y \
virtualenv python-dev libffi-dev build-essential \ virtualenv python-dev libffi-dev build-essential \
@@ -48,6 +50,7 @@ RUN apt update \
avrdude gcc-avr binutils-avr avr-libc \ avrdude gcc-avr binutils-avr avr-libc \
stm32flash libnewlib-arm-none-eabi \ stm32flash libnewlib-arm-none-eabi \
gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0 \ gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0 \
python3-numpy python3-matplotlib \
&& apt clean && apt clean
## Build klipper.elf for Simulavr and Simulavr itself ## Build klipper.elf for Simulavr and Simulavr itself