From 6aac3b3ed41e184d62ae35df51eefc08deb9f028 Mon Sep 17 00:00:00 2001 From: Joseph Coffland Date: Sat, 30 Jan 2021 13:16:08 -0800 Subject: [PATCH] Only enable rapid-auto-off and dynamic-power in PWM mode. #272, use new planner interface, Set max-arc-error with max-deviation, Fixed LCD axis offset position display, Improved modbus debugging, --- CHANGELOG.md | 6 +- MANIFEST.in | 2 +- Makefile | 24 +- README.md | 2 +- docs/development.md | 6 +- docs/emu_chroot.md | 4 +- scripts/buildbotics.gc | 403 ++++++++++++++++++ scripts/camotics-build.sh | 7 + ...n-init-build.sh => camotics-init-build.sh} | 12 +- ...it-dev-img.sh => camotics-init-dev-img.sh} | 2 +- scripts/gplan-build.sh | 6 - setup.py | 2 +- src/avr/src/modbus.c | 27 +- src/avr/src/spindle.c | 3 +- src/js/axis-vars.js | 2 +- src/pug/templates/settings-view.pug | 4 + src/py/bbctrl/Camera.py | 5 +- src/py/bbctrl/MainLCDPage.py | 2 +- src/py/bbctrl/Planner.py | 24 +- src/py/bbctrl/__init__.py | 1 + src/py/bbctrl/plan.py | 4 +- src/py/camotics/.gitignore | 0 src/resources/config-template.json | 24 +- 23 files changed, 507 insertions(+), 65 deletions(-) create mode 100644 scripts/buildbotics.gc create mode 100755 scripts/camotics-build.sh rename scripts/{gplan-init-build.sh => camotics-init-build.sh} (80%) rename scripts/{gplan-init-dev-img.sh => camotics-init-dev-img.sh} (62%) delete mode 100755 scripts/gplan-build.sh delete mode 100644 src/py/camotics/.gitignore diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dbd8ff..0daeee9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,15 @@ Buildbotics CNC Controller Firmware Changelog ## v0.4.16 - Improved axis under/over warning tooltip. - Added support for DMM DYN4 VFD. - - Only enable ``rapid-auto-off`` in PWM mode. #272 + - Only enable ``rapid-auto-off`` and ``dynamic-power`` in PWM mode. #272 - Support more gamepads. - Added copyright to LCD boot up. - Fixed default units handling. #206 - Fix zero-all when some axes are homed and some are unhomed. + - Fixed LCD axis offset position display. + - Set ``max-arc-error`` with ``max-deviation``. + - Improved modbus debugging. + - Fixed demo estop. ## v0.4.15 - Set GCode variables ``#5400`` and ``#<_tool>``. diff --git a/MANIFEST.in b/MANIFEST.in index 6450ecf..98cc101 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,5 @@ recursive-include src/py/bbctrl/http * +include src/py/bbctrl/camotics.so include package.json README.md scripts/install.sh include src/avr/bbctrl-avr-firmware.hex include src/bbserial/bbserial.ko @@ -8,5 +9,4 @@ include scripts/xinitrc include scripts/rc.local include scripts/bbctrl.service include scripts/11-automount.rules -recursive-include src/py/camotics * global-exclude .gitignore diff --git a/Makefile b/Makefile index 4ecd2bf..b4c63af 100644 --- a/Makefile +++ b/Makefile @@ -12,9 +12,9 @@ RESOURCES := $(patsubst src/resources/%,$(TARGET_DIR)/%,$(RESOURCES)) TEMPLS := $(wildcard src/pug/templates/*.pug) AVR_FIRMWARE := src/avr/bbctrl-avr-firmware.hex -GPLAN_MOD := rpi-share/camotics/gplan.so -GPLAN_TARGET := src/py/camotics/gplan.so -GPLAN_IMG := gplan-dev.img +CAMOTICS_MOD := rpi-share/camotics/build/camotics.so +CAMOTICS_TARGET := src/py/bbctrl/camotics.so +CAMOTICS_IMG := camotics-dev.img RSYNC_EXCLUDE := \*.pyc __pycache__ \*.egg-info \\\#* \*~ .\\\#\* RSYNC_EXCLUDE := $(patsubst %,--exclude %,$(RSYNC_EXCLUDE)) @@ -51,22 +51,22 @@ beta-pkg: pkg bbserial: $(MAKE) -C src/bbserial -gplan: $(GPLAN_TARGET) +camotics: $(CAMOTICS_TARGET) -$(GPLAN_TARGET): $(GPLAN_MOD) +$(CAMOTICS_TARGET): $(CAMOTICS_MOD) cp $< $@ -$(GPLAN_MOD): $(GPLAN_IMG) - ./scripts/gplan-init-build.sh +$(CAMOTICS_MOD): $(CAMOTICS_IMG) + ./scripts/camotics-init-build.sh git -C rpi-share/cbang fetch git -C rpi-share/cbang reset --hard FETCH_HEAD git -C rpi-share/camotics fetch git -C rpi-share/camotics reset --hard FETCH_HEAD - cp ./scripts/gplan-build.sh rpi-share/ - sudo ./scripts/rpi-chroot.sh $(GPLAN_IMG) /mnt/host/gplan-build.sh + cp ./scripts/camotics-build.sh rpi-share/ + sudo ./scripts/rpi-chroot.sh $(CAMOTICS_IMG) /mnt/host/camotics-build.sh -$(GPLAN_IMG): - ./scripts/gplan-init-build.sh +$(CAMOTICS_IMG): + ./scripts/camotics-init-build.sh .PHONY: $(AVR_FIRMWARE) $(AVR_FIRMWARE): @@ -139,4 +139,4 @@ clean: tidy dist-clean: clean rm -rf node_modules -.PHONY: all install clean tidy pkg gplan lint pylint jshint bbserial +.PHONY: all install clean tidy pkg camotics lint pylint jshint bbserial diff --git a/README.md b/README.md index cb8270f..eed6455 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ they are built with are as follows: * [Python 3](https://www.python.org/) * [Tornado Web](https://www.tornadoweb.org/) - * GPlan - Path Planner Python Module + * CAMotics - Path Planner Python Module * [C++](http://www.cplusplus.com/) * [CAMotics](https://camotics.org/) diff --git a/docs/development.md b/docs/development.md index 6a82eb5..bde4c85 100644 --- a/docs/development.md +++ b/docs/development.md @@ -24,14 +24,14 @@ On a Debian Linux (9.6.0 stable) system install the required packages: cd bbctrl-firmware make -## Build GPlan Module +## Build CAMotics Module -GPlan is a Python module written in C++. It must be compiled for ARM so that +CAMotics is a Python module written in C++. It must be compiled for ARM so that it can be used on the Raspberry Pi. This is accomplished using a chroot, qemu and binfmt to create an emulated ARM build environment. This is faster and more convenient than building on the RPi itself. All of this is automated. - make gplan + make camotics The first time this is run it will take quite awhile as it setups up the build environment. You can run the above command again later to build the latest diff --git a/docs/emu_chroot.md b/docs/emu_chroot.md index 348ed82..5bb3442 100644 --- a/docs/emu_chroot.md +++ b/docs/emu_chroot.md @@ -35,11 +35,11 @@ Setup the demo system: git clone --depth=1 https://github.com/CauldronDevelopmentLLC/camotics export CBANG_HOME=/opt/cbang scons -C cbang -j8 disable_local="re2 libevent" - scons -C camotics -j8 gplan.so with_gui=False + scons -C camotics -j8 build/camotics.so with_gui=False cd bbctrl python3 setup.py install - cp /opt/camotics/gplan.so /usr/local/lib/python*/dist-packages/bbctrl-$VERSION-py*.egg/camotics/gplan.so + cp /opt/camotics/build/camotics.so /usr/local/lib/python*/dist-packages/bbctrl-$VERSION-py*.egg/camotics.so mkdir -p /var/lib/bbctrl/upload useradd -u 1001 bbmc diff --git a/scripts/buildbotics.gc b/scripts/buildbotics.gc new file mode 100644 index 0000000..8c5ddb0 --- /dev/null +++ b/scripts/buildbotics.gc @@ -0,0 +1,403 @@ +G21 +(File: 'buildbotics_logo.tpl') +G0 Z3 +F1600 +M3 S10000 +M6 T2 +G0 X59.25 Y5.85 +G1 Z-1.5 +G1 X61.68 Y6.7 +G1 X63.86 Y8.07 +G1 X65.68 Y9.89 +G1 X67.05 Y12.07 +G1 X67.9 Y14.5 +G1 X68.2 Y17.09 +G1 Y56.6 +G1 X67.73 Y59.04 +G1 X50.8 +G1 Y34.9 +G1 X50.65 Y34.55 +G1 X50.3 Y34.4 +G1 X23.46 +G1 X23.1 Y34.55 +G1 X22.96 Y34.9 +G1 X22.98 Y49.88 +G1 X22.96 Y59.05 +G1 X22.41 +G1 X19.26 +G1 X6.04 +G1 X5.56 Y56.53 +G1 Y17.09 +G1 X5.85 Y14.5 +G1 X6.7 Y12.07 +G1 X8.07 Y9.89 +G1 X9.89 Y8.07 +G1 X12.07 Y6.7 +G1 X14.5 Y5.85 +G1 X17.09 Y5.56 +G1 X56.67 +G1 X59.25 Y5.85 +G0 Z3 +G0 X64.26 Y64.72 +G1 Z-1.5 +G1 X61.78 Y66.52 +G1 X58.91 Y67.68 +G1 X56.54 Y68.08 +G1 X17.22 +G1 X14.84 Y67.68 +G1 X11.97 Y66.52 +G1 X9.49 Y64.72 +G1 X8.08 Y63.16 +G1 X27.35 +G1 X27.89 Y63.45 +G1 X27.96 Y63.48 +G1 X31.48 Y64.75 +G1 X31.52 Y64.76 +G1 X31.56 Y64.77 +G1 X35.19 Y65.41 +G1 X35.26 +G1 X35.97 Y65.44 +G1 X36.04 Y65.45 +G1 X36.07 +G1 X36.82 Y65.44 +G1 X36.83 +G1 X36.89 +G1 X36.95 +G1 X36.97 +G1 X37.72 Y65.43 +G1 X37.74 +G1 X37.8 +G1 X37.81 +G1 X37.88 +G1 X37.89 +G1 X38.65 Y65.38 +G1 X38.68 +G1 X38.75 Y65.37 +G1 X39.38 Y65.32 +G1 X39.44 Y65.31 +G1 X42.68 Y64.64 +G1 X42.76 Y64.62 +G1 X45.87 Y63.44 +G1 X45.93 Y63.41 +G1 X46.4 Y63.16 +G1 X65.67 +G1 X64.26 Y64.72 +G0 Z3 +G0 X36.88 Y9.4 +G1 Z-1.5 +G1 X37.31 Y9.64 +G1 X39.58 Y13.48 +G1 X39.63 Y13.6 +G1 X39.65 Y13.73 +G1 Y27.54 +G1 X41.67 +G1 Y25.39 +G1 X41.75 Y25.12 +G1 X41.97 Y24.93 +G1 X46.41 Y22.92 +G1 Y19.97 +G1 X45.44 +G1 X45.08 Y19.82 +G1 X44.94 Y19.47 +G1 Y13.73 +G1 X45.08 Y13.38 +G1 X45.44 Y13.23 +G1 X49.94 Y13.24 +G1 X50.29 Y13.39 +G1 X50.44 Y13.74 +G1 Y19.47 +G1 X50.29 Y19.83 +G1 X49.93 Y19.97 +G1 X48.92 +G1 Y23.61 +G1 X48.84 Y23.88 +G1 X48.63 Y24.06 +G1 X44.19 Y26.12 +G1 Y27.54 +G1 X49.22 +G1 X49.33 Y27.56 +G1 X49.44 Y27.6 +G1 X50.13 Y27.94 +G1 X50.25 Y28.02 +G1 X50.34 Y28.13 +G1 X50.73 Y28.77 +G1 X50.78 Y28.89 +G1 X50.8 Y29.03 +G1 Y33.05 +G1 Y34.25 +G1 Y34.65 +G1 X50.66 Y35.01 +G1 X50.3 Y35.15 +G1 X23.46 +G1 X23.1 Y35.01 +G1 X22.96 Y34.65 +G1 Y29.07 +G1 X22.97 Y28.94 +G1 X23.02 Y28.82 +G1 X23.4 Y28.17 +G1 X23.49 Y28.06 +G1 X23.6 Y27.98 +G1 X24.29 Y27.6 +G1 X24.4 Y27.56 +G1 X24.52 Y27.54 +G1 X25.55 +G1 Y26.4 +G1 X23.4 Y25.52 +G1 X23.17 Y25.33 +G1 X23.09 Y25.06 +G1 Y17.54 +G1 X23.23 Y17.19 +G1 X23.59 Y17.04 +G1 X24.6 +G1 Y10.36 +G1 X24.62 Y10.23 +G1 X24.66 Y10.11 +G1 X24.8 Y9.88 +G1 X24.88 Y9.77 +G1 X24.99 Y9.68 +G1 X25.25 Y9.54 +G1 X25.37 Y9.5 +G1 X25.49 Y9.48 +G1 X26.53 +G1 X26.65 Y9.49 +G1 X26.76 Y9.54 +G1 X27.01 Y9.66 +G1 X27.12 Y9.74 +G1 X27.21 Y9.85 +G1 X27.35 Y10.09 +G1 X27.41 Y10.22 +G1 X27.43 Y10.35 +G1 Y10.43 +G1 X27.47 Y17.04 +G1 X28.57 +G1 X28.92 Y17.19 +G1 X29.07 Y17.54 +G1 Y24.64 +G1 X30.72 Y25.3 +G1 X30.95 Y25.49 +G1 X31.03 Y25.77 +G1 X31.02 Y27.54 +G1 X34.03 +G1 Y13.73 +G1 X34.05 Y13.59 +G1 X34.1 Y13.47 +G1 X36.45 Y9.64 +G1 X36.88 Y9.4 +G0 Z3 +G0 X49.94 Y10.82 +G1 Z-1.5 +G1 X50.29 Y10.97 +G1 X50.44 Y11.32 +G1 Y13.34 +G1 X50.29 Y13.69 +G1 X49.94 Y13.84 +G1 X45.44 +G1 X45.08 Y13.69 +G1 X44.94 Y13.34 +G1 Y11.32 +G1 X45.08 Y10.97 +G1 X45.44 Y10.82 +G1 X49.94 +G0 Z3 +G0 X48.46 Y9.7 +G1 Z-1.5 +G1 X48.59 Y9.72 +G1 X48.71 Y9.77 +G1 X50.03 Y10.53 +G1 X50.21 Y10.71 +G1 X50.28 Y10.96 +G1 X50.14 Y11.31 +G1 X49.78 Y11.46 +G1 X45.62 +G1 X45.14 Y11.09 +G1 X45.37 Y10.53 +G1 X46.69 Y9.77 +G1 X46.81 Y9.72 +G1 X46.94 Y9.7 +G1 X48.46 +G0 Z3 +G0 X50.3 Y34.4 +G1 Z-1.5 +G1 X50.66 Y34.55 +G1 X50.8 Y34.9 +G1 Y49.88 +G1 X50.79 Y59.52 +G1 X50.76 Y59.69 +G1 X50.67 Y59.84 +G1 X50.09 Y60.52 +G1 X50.06 Y60.55 +G1 X50.02 Y60.58 +G1 X47.89 Y62.26 +G1 X47.85 Y62.28 +G1 X47.81 Y62.31 +G1 X44.46 Y64.03 +G1 X44.41 Y64.05 +G1 X44.37 Y64.06 +G1 X40.69 Y65.1 +G1 X40.62 Y65.12 +G1 X37.86 Y65.45 +G1 X37.8 Y65.46 +G1 X36.89 Y65.44 +G1 X36.83 +G1 X36.82 +G1 X36.07 Y65.45 +G1 X36.04 Y65.44 +G1 X35.97 +G1 X35.1 Y65.41 +G1 X35.04 Y65.4 +G1 X32.44 Y64.99 +G1 X32.37 Y64.97 +G1 X28.94 Y63.9 +G1 X28.89 Y63.88 +G1 X28.85 Y63.86 +G1 X25.74 Y62.2 +G1 X25.7 Y62.18 +G1 X25.66 Y62.15 +G1 X23.68 Y60.56 +G1 X23.65 Y60.53 +G1 X23.62 Y60.5 +G1 X23.08 Y59.87 +G1 X22.99 Y59.71 +G1 X22.96 Y59.54 +G1 X22.98 Y49.88 +G1 X22.96 Y34.9 +G1 X23.1 Y34.55 +G1 X23.46 Y34.4 +G1 X50.3 +G0 Z3 +G0 X55.2 Y43.67 +G1 Z-1.5 +G1 Y51.34 +G1 X55.11 Y51.94 +G1 X54.83 Y52.88 +G1 X54.39 Y53.88 +G1 X53.8 Y54.85 +G1 X53.09 Y55.74 +G1 X52.28 Y56.47 +G1 X51.41 Y56.98 +G1 X51.07 Y57.09 +G1 Y43.67 +G1 X55.2 +G0 Z3 +G0 X22.69 Y43.63 +G1 Z-1.5 +G1 Y57.09 +G1 X22.35 Y56.98 +G1 X21.47 Y56.47 +G1 X20.67 Y55.74 +G1 X19.95 Y54.85 +G1 X19.36 Y53.88 +G1 X18.92 Y52.88 +G1 X18.64 Y51.94 +G1 X18.55 Y51.34 +G1 Y43.63 +G1 X22.69 +G0 Z3 +G0 X28.55 Y35.84 +G1 Z-0.99 +G1 X30.11 Y36.15 +G1 X31.43 Y37.03 +G1 X32.32 Y38.35 +G1 X32.63 Y39.91 +G1 X32.32 Y41.47 +G1 X31.43 Y42.79 +G1 X30.11 Y43.68 +G1 X28.55 Y43.99 +G1 X26.99 Y43.68 +G1 X25.67 Y42.79 +G1 X24.79 Y41.47 +G1 X24.48 Y39.91 +G1 X24.79 Y38.35 +G1 X25.67 Y37.03 +G1 X26.99 Y36.15 +G1 X28.55 Y35.84 +G0 Z3 +G0 X45.33 Y35.93 +G1 Z-0.99 +G1 X46.88 Y36.24 +G1 X48.21 Y37.12 +G1 X49.09 Y38.45 +G1 X49.4 Y40 +G1 X49.09 Y41.56 +G1 X48.21 Y42.88 +G1 X46.88 Y43.77 +G1 X45.33 Y44.08 +G1 X43.77 Y43.77 +G1 X42.45 Y42.88 +G1 X41.56 Y41.56 +G1 X41.25 Y40 +G1 X41.56 Y38.45 +G1 X42.45 Y37.12 +G1 X43.77 Y36.24 +G1 X45.33 Y35.93 +G0 Z3 +G0 X45.2 Y39.12 +G1 Z-0.99 +G1 X45.7 Y39.19 +G1 X46.07 Y39.52 +G1 X46.22 Y40 +G1 X46.07 Y40.49 +G1 X45.7 Y40.81 +G1 X45.2 Y40.89 +G1 X44.74 Y40.68 +G1 X44.47 Y40.26 +G1 Y39.75 +G1 X44.74 Y39.33 +G1 X45.2 Y39.12 +G0 Z3 +G0 X28.43 Y39.03 +G1 Z-0.99 +G1 X28.92 Y39.1 +G1 X29.3 Y39.43 +G1 X29.44 Y39.91 +G1 X29.3 Y40.4 +G1 X28.92 Y40.72 +G1 X28.43 Y40.8 +G1 X27.97 Y40.59 +G1 X27.7 Y40.16 +G1 Y39.66 +G1 X27.97 Y39.24 +G1 X28.43 Y39.03 +G0 Z3 +G0 X55.76 Y0 +G1 Z-1.5 +G1 X59.27 Y0.35 +G1 X62.65 Y1.37 +G1 X65.76 Y3.03 +G1 X68.49 Y5.27 +G1 X70.73 Y8 +G1 X72.39 Y11.11 +G1 X73.42 Y14.49 +G1 X73.76 Y18 +G1 Y55.69 +G1 X73.42 Y59.2 +G1 X72.39 Y62.57 +G1 X70.73 Y65.69 +G1 X68.49 Y68.41 +G1 X65.76 Y70.65 +G1 X62.65 Y72.31 +G1 X59.27 Y73.34 +G1 X55.76 Y73.69 +G1 X18 +G1 X14.49 Y73.34 +G1 X11.11 Y72.31 +G1 X8 Y70.65 +G1 X5.27 Y68.41 +G1 X3.03 Y65.69 +G1 X1.37 Y62.57 +G1 X0.35 Y59.2 +G1 X0 Y55.69 +G1 Y18 +G1 X0.35 Y14.49 +G1 X1.37 Y11.11 +G1 X3.03 Y8 +G1 X5.27 Y5.27 +G1 X8 Y3.03 +G1 X11.11 Y1.37 +G1 X14.49 Y0.35 +G1 X18 Y0 +G1 X55.76 +G0 Z3 +M5 +G0 X40 Y75 +M2 diff --git a/scripts/camotics-build.sh b/scripts/camotics-build.sh new file mode 100755 index 0000000..97b419f --- /dev/null +++ b/scripts/camotics-build.sh @@ -0,0 +1,7 @@ +#!/bin/bash -ex + +cd /mnt/host +export V8_INCLUDE=/opt/embedded-v8/include/ V8_LIBPATH=/opt/embedded-v8/out/ +scons -C cbang disable_local="re2 libevent" +export CBANG_HOME="/mnt/host/cbang" +scons -C camotics build/camotics.so with_gui=0 diff --git a/scripts/gplan-init-build.sh b/scripts/camotics-init-build.sh similarity index 80% rename from scripts/gplan-init-build.sh rename to scripts/camotics-init-build.sh index 6459f49..006a9f9 100755 --- a/scripts/gplan-init-build.sh +++ b/scripts/camotics-init-build.sh @@ -4,10 +4,10 @@ IMG_DATE=2017-11-29 IMG_BASE=${IMG_DATE}-raspbian-stretch-lite BASE_URL=https://downloads.raspberrypi.org/raspbian_lite/images IMG_URL=$BASE_URL/raspbian_lite-2017-12-01/$IMG_BASE.zip -GPLAN_IMG=gplan-dev.img +CAMOTICS_IMG=camotics-dev.img # Create dev image -if [ ! -e $GPLAN_IMG ]; then +if [ ! -e $CAMOTICS_IMG ]; then # Get base image if [ ! -e $IMG_BASE.img ]; then @@ -19,15 +19,15 @@ if [ ! -e $GPLAN_IMG ]; then fi # Copy base image - cp $IMG_BASE.img $GPLAN_IMG.tmp + cp $IMG_BASE.img $CAMOTICS_IMG.tmp # Init image mkdir -p rpi-share - cp ./scripts/gplan-init-dev-img.sh rpi-share - sudo ./scripts/rpi-chroot.sh $GPLAN_IMG.tmp /mnt/host/gplan-init-dev-img.sh + cp ./scripts/camotics-init-dev-img.sh rpi-share + sudo ./scripts/rpi-chroot.sh $CAMOTICS_IMG.tmp /mnt/host/camotics-init-dev-img.sh # Move image - mv $GPLAN_IMG.tmp $GPLAN_IMG + mv $CAMOTICS_IMG.tmp $CAMOTICS_IMG fi # Get repos diff --git a/scripts/gplan-init-dev-img.sh b/scripts/camotics-init-dev-img.sh similarity index 62% rename from scripts/gplan-init-dev-img.sh rename to scripts/camotics-init-dev-img.sh index cfa9d4e..bd53de8 100755 --- a/scripts/gplan-init-dev-img.sh +++ b/scripts/camotics-init-dev-img.sh @@ -8,4 +8,4 @@ apt-get update #apt-get dist-upgrade -y # Install packages -apt-get install -y scons build-essential libssl-dev python3-dev +apt-get install -y scons build-essential libssl-dev python3-dev nodejs-dev diff --git a/scripts/gplan-build.sh b/scripts/gplan-build.sh deleted file mode 100755 index a21237d..0000000 --- a/scripts/gplan-build.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -ex - -cd /mnt/host -scons -C cbang disable_local="re2 libevent" -export CBANG_HOME="/mnt/host/cbang" -scons -C camotics gplan.so with_gui=0 with_tpl=0 diff --git a/setup.py b/setup.py index cf4069d..efe8c53 100755 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ setup( license = pkg['license'], url = pkg['homepage'], package_dir = {'': 'src/py'}, - packages = ['bbctrl', 'inevent', 'lcd', 'camotics'], + packages = ['bbctrl', 'inevent', 'lcd'], include_package_data = True, entry_points = { 'console_scripts': [ diff --git a/src/avr/src/modbus.c b/src/avr/src/modbus.c index 5678211..a9bbd0b 100644 --- a/src/avr/src/modbus.c +++ b/src/avr/src/modbus.c @@ -130,6 +130,18 @@ static uint16_t _read_word(const uint8_t *data, bool little_endian) { } +static void _debug_transfer() { + if (!cfg.debug) return; + + char out[state.command_length * 2 + 1]; + char in[state.response_length * 2 + 1]; + format_hex_buf(out, state.command, state.command_length); + format_hex_buf(in, state.response, state.response_length); + + STATUS_DEBUG("modbus: out=0x%s in=0x%s", out, in); +} + + static bool _check_response() { // Check CRC uint16_t computed = _crc16(state.response, state.response_length - 2); @@ -138,14 +150,9 @@ static bool _check_response() { if (computed != expected) { if (cfg.debug) { - char sent[state.command_length * 2 + 1]; - char response[state.response_length * 2 + 1]; - format_hex_buf(sent, state.command, state.command_length); - format_hex_buf(response, state.response, state.response_length); - STATUS_WARNING(STAT_OK, "modbus: invalid CRC, received=0x%04x " - "computed=0x%04x sent=0x%s received=0x%s", - expected, computed, sent, response); + "computed=0x%04x", expected, computed); + _debug_transfer(); } state.crc_errs++; @@ -157,6 +164,7 @@ static bool _check_response() { if (state.command[0] != state.response[0]) { STATUS_WARNING(STAT_OK, "modbus: unexpected slave id, expected=%u got=%u", state.command[0], state.response[0]); + _debug_transfer(); state.status = MODBUS_INVALID; return false; } @@ -165,6 +173,7 @@ static bool _check_response() { if (state.command[1] != state.response[1]) { STATUS_WARNING(STAT_OK, "modbus: invalid function code, expected=%u got=%u", state.command[1], state.response[1]); + _debug_transfer(); state.status = MODBUS_INVALID; return false; } @@ -245,6 +254,8 @@ static void _read_cb(uint8_t func, uint8_t bytes, const uint8_t *data) { } if (state.rw_cb) state.rw_cb(false, state.addr, 0); + STATUS_WARNING(STAT_OK, "modbus: unexpected response to read"); + _debug_transfer(); } @@ -258,6 +269,8 @@ static void _write_cb(uint8_t func, uint8_t bytes, const uint8_t *data) { } if (state.rw_cb) state.rw_cb(false, state.addr, 0); + STATUS_WARNING(STAT_OK, "modbus: unexpected response to write"); + _debug_transfer(); } diff --git a/src/avr/src/spindle.c b/src/avr/src/spindle.c index 41c2875..1684fe0 100644 --- a/src/avr/src/spindle.c +++ b/src/avr/src/spindle.c @@ -147,7 +147,8 @@ static power_update_t _get_power_update() { float power = _speed_to_power(spindle.speed); // Handle dynamic power - if (spindle.dynamic_power && spindle.inv_feed) { + if (spindle.type == SPINDLE_TYPE_PWM && spindle.dynamic_power && + spindle.inv_feed) { float scale = spindle.inv_feed * exec_get_velocity(); if (scale < 1) power *= scale; } diff --git a/src/js/axis-vars.js b/src/js/axis-vars.js index 1140ecd..489d074 100644 --- a/src/js/axis-vars.js +++ b/src/js/axis-vars.js @@ -115,7 +115,7 @@ module.exports = { case 'UNDER': title = 'Current program would move ' + this._length_str(min - pathMin - off) + ' below axis bounds. ' + - 'Offsets must be adjusted of soft limits set correctly.'; + 'Offsets must be adjusted or soft limits set correctly.'; break; case 'NO FIT': diff --git a/src/pug/templates/settings-view.pug b/src/pug/templates/settings-view.pug index aa4ae96..7d806ba 100644 --- a/src/pug/templates/settings-view.pug +++ b/src/pug/templates/settings-view.pug @@ -89,6 +89,10 @@ script#settings-view-template(type="text/x-template") #[a(href=base + "#gcode:g64", target="_blank") G64] also affect path planning accuracy. + p. + This also affects the maimum error when interpolating + #[a(href=base + "#gcode:g2-g3", target="_blank") G2 and G3] arcs. + h2 Cornering Speed (Advanced) templated-input(name="junction-accel", :model.sync="config.settings['junction-accel']", diff --git a/src/py/bbctrl/Camera.py b/src/py/bbctrl/Camera.py index 9273757..ceb8f3f 100644 --- a/src/py/bbctrl/Camera.py +++ b/src/py/bbctrl/Camera.py @@ -423,7 +423,7 @@ class Camera(object): except: pass self._close_dev() - self.log.info('Closed camera\n') + self.log.info('Closed camera') except: self.log.exception('Exception while closing camera') finally: self.dev = None @@ -465,6 +465,9 @@ class VideoHandler(web.RequestHandler): self.camera = app.camera + def finish(self): pass # Don't let it finish and end the response + + def get(self): self.request.connection.stream.max_write_buffer_size = 10000 diff --git a/src/py/bbctrl/MainLCDPage.py b/src/py/bbctrl/MainLCDPage.py index 81a1bc2..7039ea0 100644 --- a/src/py/bbctrl/MainLCDPage.py +++ b/src/py/bbctrl/MainLCDPage.py @@ -60,7 +60,7 @@ class MainLCDPage(bbctrl.LCDPage): elif state.is_axis_enabled(axis): position = state.get(axis + 'p', 0) - position += state.get('offset_' + axis, 0) + position -= state.get('offset_' + axis, 0) position /= scale self.text('% 10.3f%s' % (position, axis.upper()), 9, row) row += 1 diff --git a/src/py/bbctrl/Planner.py b/src/py/bbctrl/Planner.py index 0a3e478..863ad4b 100644 --- a/src/py/bbctrl/Planner.py +++ b/src/py/bbctrl/Planner.py @@ -31,7 +31,12 @@ import re import time import datetime from collections import deque -import camotics.gplan as gplan # pylint: disable=no-name-in-module,import-error + +try: + import bbctrl.camotics as camotics # pylint: disable=no-name-in-module,import-error +except: + print('Error loading camotics') + import bbctrl.Cmd as Cmd from bbctrl.CommandQueue import CommandQueue @@ -65,8 +70,11 @@ class Planner(): ctrl.state.add_listener(self._update) - self.reset(False) - self._report_time() + try: + self.reset(False) + self._report_time() + except Exception as e: + self.log.exception() def is_busy(self): return self.is_running() or self.cmdq.is_active() @@ -84,6 +92,7 @@ class Planner(): state = self.ctrl.state config = self.ctrl.config is_pwm = config.get('tool-type') == 'PWM Spindle' + deviation = config.get('max-deviation') cfg = { # NOTE Must get current units not configured default units @@ -92,8 +101,9 @@ class Planner(): 'max-accel': state.get_axis_vector('am', 1000000), 'max-jerk': state.get_axis_vector('jm', 1000000), 'rapid-auto-off': config.get('rapid-auto-off') and is_pwm, - 'max-blend-error': config.get('max-deviation'), - 'max-merge-error': config.get('max-deviation'), + 'max-blend-error': deviation, + 'max-merge-error': deviation, + 'max-arc-error': deviation / 10, 'junction-accel': config.get('junction-accel'), } @@ -240,6 +250,8 @@ class Planner(): def __encode(self, block): type, id = block['type'], block['id'] + if type == 'start': return # ignore + if type != 'set': self.log.info('Cmd:' + log_json(block)) if type == 'line': @@ -327,7 +339,7 @@ class Planner(): def reset(self, stop = True): if stop: self.ctrl.mach.stop() - self.planner = gplan.Planner() + self.planner = camotics.Planner() self.planner.set_resolver(self._get_var_cb) # TODO logger is global and will not work correctly in demo mode self.planner.set_logger(self._log_cb, 1, 'LinePlanner:3') diff --git a/src/py/bbctrl/__init__.py b/src/py/bbctrl/__init__.py index da3cb0e..1832fb4 100644 --- a/src/py/bbctrl/__init__.py +++ b/src/py/bbctrl/__init__.py @@ -63,6 +63,7 @@ import bbctrl.Cmd as Cmd import bbctrl.v4l2 as v4l2 import bbctrl.Log as log import bbctrl.ObjGraph as ObjGraph +import bbctrl.camotics as camotics ctrl = None diff --git a/src/py/bbctrl/plan.py b/src/py/bbctrl/plan.py index f0bf413..71eaacb 100644 --- a/src/py/bbctrl/plan.py +++ b/src/py/bbctrl/plan.py @@ -37,7 +37,7 @@ import re import gzip import struct import math -import camotics.gplan as gplan # pylint: disable=no-name-in-module,import-error +import bbctrl.camotics as camotics # pylint: disable=no-name-in-module,import-error reLogLine = re.compile( @@ -87,7 +87,7 @@ class Plan(object): self.lines = sum(1 for line in open(path, 'rb')) - self.planner = gplan.Planner() + self.planner = camotics.Planner() self.planner.set_resolver(self.get_var_cb) self.planner.set_logger(self._log_cb, 1, 'LinePlanner:3') self.planner.load(self.path, config) diff --git a/src/py/camotics/.gitignore b/src/py/camotics/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/src/resources/config-template.json b/src/resources/config-template.json index d21bc13..4a72176 100644 --- a/src/resources/config-template.json +++ b/src/resources/config-template.json @@ -292,18 +292,6 @@ "default": "lo-hi", "code": "dom", "pin": 16 - }, - "rapid-auto-off": { - "help": "Turn tool off during rapid moves. Useful for LASERs.", - "type": "bool", - "default": false - }, - "dynamic-power": { - "help": - "Adjust tool power based on velocity and feed rate. Useful for LASERs.", - "type": "bool", - "default": false, - "code": "dp" } }, @@ -398,6 +386,18 @@ "max": 320000, "default": 1000, "code": "sf" + }, + "rapid-auto-off": { + "help": "Turn tool off during rapid moves. Useful for LASERs.", + "type": "bool", + "default": false + }, + "dynamic-power": { + "help": + "Adjust tool power based on velocity and feed rate. Useful for LASERs.", + "type": "bool", + "default": false, + "code": "dp" } }, -- 2.27.0