Only enable rapid-auto-off and dynamic-power in PWM mode. #272, use new planner inter...
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Sat, 30 Jan 2021 21:16:08 +0000 (13:16 -0800)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Sat, 30 Jan 2021 21:16:22 +0000 (13:16 -0800)
25 files changed:
CHANGELOG.md
MANIFEST.in
Makefile
README.md
docs/development.md
docs/emu_chroot.md
scripts/buildbotics.gc [new file with mode: 0644]
scripts/camotics-build.sh [new file with mode: 0755]
scripts/camotics-init-build.sh [new file with mode: 0755]
scripts/camotics-init-dev-img.sh [new file with mode: 0755]
scripts/gplan-build.sh [deleted file]
scripts/gplan-init-build.sh [deleted file]
scripts/gplan-init-dev-img.sh [deleted file]
setup.py
src/avr/src/modbus.c
src/avr/src/spindle.c
src/js/axis-vars.js
src/pug/templates/settings-view.pug
src/py/bbctrl/Camera.py
src/py/bbctrl/MainLCDPage.py
src/py/bbctrl/Planner.py
src/py/bbctrl/__init__.py
src/py/bbctrl/plan.py
src/py/camotics/.gitignore [deleted file]
src/resources/config-template.json

index 6dbd8ffe076b134fb587093d3a6cb862fe43136f..0daeee969fa2dbf487716f9a355e59e3f0cc5707 100644 (file)
@@ -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>``.
index 6450ecf53c8eec3af4ef754c214fc3fd97d5312c..98cc101f431bfcb30aa5baee60ca13aa3d54366c 100644 (file)
@@ -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
index 4ecd2bfad93e83beb3166d792306a589dd04ec03..b4c63af2f4574a968c47a2d841a1d9a0e180d9c2 100644 (file)
--- 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
index cb8270fca652710fa75a187591692bd74d82eb03..eed64556b69c6dc77d4931371685b53df2df5b02 100644 (file)
--- 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/)
 
index 6a82eb51772b8169eff964382139fae5eeaf63ad..bde4c85a114a4cbea1c7479fa577427aec08e1a1 100644 (file)
@@ -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
index 348ed821080f08df36f1c0f7b5519c60c6b79c1c..5bb3442696d3d9dc1f746bd7340840e7bf4e51b0 100644 (file)
@@ -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 (file)
index 0000000..8c5ddb0
--- /dev/null
@@ -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 (executable)
index 0000000..97b419f
--- /dev/null
@@ -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/camotics-init-build.sh b/scripts/camotics-init-build.sh
new file mode 100755 (executable)
index 0000000..006a9f9
--- /dev/null
@@ -0,0 +1,59 @@
+#!/bin/bash -ex
+
+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
+CAMOTICS_IMG=camotics-dev.img
+
+# Create dev image
+if [ ! -e $CAMOTICS_IMG ]; then
+
+    # Get base image
+    if [ ! -e $IMG_BASE.img ]; then
+        if [ ! -e $IMG_BASE.zip ]; then
+            wget $IMG_URL
+        fi
+
+        unzip $IMG_BASE.zip
+    fi
+
+    # Copy base image
+    cp $IMG_BASE.img $CAMOTICS_IMG.tmp
+
+    # Init image
+    mkdir -p rpi-share
+    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 $CAMOTICS_IMG.tmp $CAMOTICS_IMG
+fi
+
+# Get repos
+function fetch_local_repo() {
+    mkdir -p $1
+    git -C $1 init
+    git -C $1 fetch -t "$2" $3
+    git -C $1 reset --hard FETCH_HEAD
+}
+
+mkdir -p rpi-share || true
+
+if [ ! -e rpi-share/cbang ]; then
+    if [ "$CBANG_HOME" != "" ]; then
+        fetch_local_repo rpi-share/cbang "$CBANG_HOME" master
+    else
+        git clone https://github.com/CauldronDevelopmentLLC/cbang \
+            rpi-share/cbang
+    fi
+fi
+
+if [ ! -e rpi-share/camotics ]; then
+    if [ "$CAMOTICS_HOME" != "" ]; then
+        fetch_local_repo rpi-share/camotics "$CAMOTICS_HOME" master
+    else
+        git clone https://github.com/CauldronDevelopmentLLC/camotics \
+            rpi-share/camotics
+    fi
+fi
diff --git a/scripts/camotics-init-dev-img.sh b/scripts/camotics-init-dev-img.sh
new file mode 100755 (executable)
index 0000000..bd53de8
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash -e
+
+export LC_ALL=C
+cd /mnt/host
+
+# Update the system
+apt-get update
+#apt-get dist-upgrade -y
+
+# Install packages
+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 (executable)
index a21237d..0000000
+++ /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/scripts/gplan-init-build.sh b/scripts/gplan-init-build.sh
deleted file mode 100755 (executable)
index 6459f49..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/bash -ex
-
-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
-
-# Create dev image
-if [ ! -e $GPLAN_IMG ]; then
-
-    # Get base image
-    if [ ! -e $IMG_BASE.img ]; then
-        if [ ! -e $IMG_BASE.zip ]; then
-            wget $IMG_URL
-        fi
-
-        unzip $IMG_BASE.zip
-    fi
-
-    # Copy base image
-    cp $IMG_BASE.img $GPLAN_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
-
-    # Move image
-    mv $GPLAN_IMG.tmp $GPLAN_IMG
-fi
-
-# Get repos
-function fetch_local_repo() {
-    mkdir -p $1
-    git -C $1 init
-    git -C $1 fetch -t "$2" $3
-    git -C $1 reset --hard FETCH_HEAD
-}
-
-mkdir -p rpi-share || true
-
-if [ ! -e rpi-share/cbang ]; then
-    if [ "$CBANG_HOME" != "" ]; then
-        fetch_local_repo rpi-share/cbang "$CBANG_HOME" master
-    else
-        git clone https://github.com/CauldronDevelopmentLLC/cbang \
-            rpi-share/cbang
-    fi
-fi
-
-if [ ! -e rpi-share/camotics ]; then
-    if [ "$CAMOTICS_HOME" != "" ]; then
-        fetch_local_repo rpi-share/camotics "$CAMOTICS_HOME" master
-    else
-        git clone https://github.com/CauldronDevelopmentLLC/camotics \
-            rpi-share/camotics
-    fi
-fi
diff --git a/scripts/gplan-init-dev-img.sh b/scripts/gplan-init-dev-img.sh
deleted file mode 100755 (executable)
index cfa9d4e..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/bash -e
-
-export LC_ALL=C
-cd /mnt/host
-
-# Update the system
-apt-get update
-#apt-get dist-upgrade -y
-
-# Install packages
-apt-get install -y scons build-essential libssl-dev python3-dev
index cf4069dd5f7da577eb81e135b71dee07e990651b..efe8c5320c95a853f200da11d34a4d0dd016dcfb 100755 (executable)
--- 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': [
index 56782116e64cb5f3251a25755c4ac0cf69cb96f0..a9bbd0bee25e69d81c8f55bd6bda8141c59824bc 100644 (file)
@@ -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();
 }
 
 
index 41c28757ffea0ceba4c21c409177fd5cc82409bd..1684fe05616b148973e545a19abf77b2f83badc5 100644 (file)
@@ -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;
   }
index 1140ecd2f083108b9243c2fce5812cde6e543ff8..489d074deca7ce38de94cf3f1c4b30352ce7dba1 100644 (file)
@@ -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':
index aa4ae9632cc667589999e4be1c6f4bc31cf95056..7d806ba0bc0be5d555a785e829cc3875aae90a0b 100644 (file)
@@ -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']",
index 9273757c1935ae0070cc7d839b63553995732664..ceb8f3f2f86160f32fdd08bf8efbdcbddc8fbf61 100644 (file)
@@ -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
 
index 81a1bc212f48255f08fb2047fc63fabaa7079bc7..7039ea019d0c6119599dc6fd9444439b79c232f6 100644 (file)
@@ -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
index 0a3e4784b21d05ca8eff051d5ba2f78dd8f237d2..863ad4b14a3cf1c6f249f72a3fe16a3c463ab470 100644 (file)
@@ -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')
index da3cb0ea614d04083f77beb38b2b79428947f537..1832fb4745db3f6d894e9e5b1134a482d95f1010 100644 (file)
@@ -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
index f0bf413667de2047a175bc3b4adb2db575ffce43..71eaacba6c0484671608cbe5d59a8ab2eb88454a 100644 (file)
@@ -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 (file)
index e69de29..0000000
index d21bc132781c6ea1d49f9ea10140ed9ed49fbbcf..4a721768114b996115f7813a2b5a663c27bdb773 100644 (file)
       "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"
     }
   },
 
       "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"
     }
   },