From edb4016b2556821fc5565f33fcae7950c35fb4bf Mon Sep 17 00:00:00 2001 From: mwinter Date: Wed, 18 Oct 2023 16:44:07 +0100 Subject: [PATCH] motions tracking now plucked in - still needs work --- arduino/multistepper/multistepper.ino | 4 +- openstagecontrol/stepper_control_gui.json | 2028 ++++++++++++++------- python/vernier_tracker.py | 32 +- supercollider/installation_control.scd | 46 +- 4 files changed, 1427 insertions(+), 683 deletions(-) diff --git a/arduino/multistepper/multistepper.ino b/arduino/multistepper/multistepper.ino index 3abf5b2..00d725b 100644 --- a/arduino/multistepper/multistepper.ino +++ b/arduino/multistepper/multistepper.ino @@ -36,8 +36,8 @@ bool ySafeMode = false; long yLimitPos = 0; int microsteps = 1; -float maxSpeedConstant = 350 * microsteps; -float accelerationConstant = 100 * microsteps; +float maxSpeedConstant = 100 * microsteps; +float accelerationConstant = 50 * microsteps; void setup() { diff --git a/openstagecontrol/stepper_control_gui.json b/openstagecontrol/stepper_control_gui.json index 51463af..033e0ca 100644 --- a/openstagecontrol/stepper_control_gui.json +++ b/openstagecontrol/stepper_control_gui.json @@ -1,666 +1,1366 @@ { - "type": "root", - "id": "root", - "linkId": "", - "color": "auto", - "css": "", - "default": "", - "value": "", - "precision": 2, - "address": "/root", - "preArgs": "", - "target": "", - "bypass": false, - "traversing": false, - "variables": {}, - "tabs": [ - { - "type": "tab", - "id": "main_tab", - "linkId": "", - "label": "a history of the domino problem", - "color": "white", - "css": ":root {\n--color-bg: black;\n--color-raised: black;\n--color-accent: grey;\n--color-light: grey;\n}", - "default": "", - "value": "", - "precision": 2, - "address": "/tab_1", - "preArgs": "", - "target": "", - "bypass": false, - "variables": "@{parent.variables}", - "widgets": [ - { - "type": "panel", - "top": "auto", - "left": "auto", - "id": "main_panel", - "linkId": "", - "width": 502, - "height": 312, - "label": false, - "color": "auto", - "css": "> .panel {\n background-color: black;\n border: 2px solid grey;\n}\n:host {\n top:calc(50% - 156rem);\n left:calc(50% - 251rem);\n z-index:15;\n}", - "scroll": true, - "border": true, - "default": "", - "value": "", - "precision": 2, - "address": "/main_panel", - "preArgs": "", - "target": "", - "bypass": true, - "variables": "@{parent.variables}", - "widgets": [ - { - "type": "text", - "top": 248, - "left": 10, - "id": "message", - "linkId": "", - "width": 478, - "height": 50, - "label": false, - "color": "white", - "css": ".text {\n background-color: black;\n border: 1px solid grey;\n}", - "vertical": false, - "wrap": false, - "align": "", - "default": " ", - "value": "", - "address": "/message", - "preArgs": "" - }, - { - "type": "panel", - "top": 10, - "left": 248, - "id": "jog", - "linkId": "", - "width": 240, - "height": 240, - "label": false, - "color": "auto", - "css": ".panel {\n background-color: black;\n border: 2px solid grey;\n}", - "value": "", - "precision": 2, - "address": "/jog", - "preArgs": "", - "target": "", - "bypass": true, - "scroll": false, - "border": false, - "default": "", - "variables": "@{parent.variables}", - "widgets": [ - { - "type": "push", - "top": 150, - "left": 90, - "id": "jog_down", - "linkId": "", - "width": 60, - "height": 60, - "label": "^arrow-alt-circle-down", - "color": "auto", - "css": ":host{\n--color-raised:#2A2A2D;\n}\n> .label {\nfont-size: 300%;\n}", - "doubleTap": false, - "on": -1, - "off": 0, - "norelease": false, - "value": "", - "precision": 1, - "address": "/jog_vertical", - "preArgs": "", - "target": "", - "bypass": false - }, - { - "type": "push", - "top": 90, - "left": 150, - "id": "jog_right", - "linkId": "", - "width": 60, - "height": 60, - "label": "^arrow-alt-circle-right", - "color": "auto", - "css": ":host{\n--color-raised:#2A2A2D;\n}\n> .label {\nfont-size: 300%;\n}", - "doubleTap": false, - "on": 1, - "off": 0, - "norelease": false, - "value": "", - "precision": 1, - "address": "/jog_horizontal", - "preArgs": "", - "target": "", - "bypass": false - }, - { - "type": "push", - "top": 90, - "left": 30, - "id": "jog_left", - "linkId": "", - "width": 60, - "height": 60, - "label": "^arrow-alt-circle-left", - "color": "auto", - "css": ":host{\n--color-raised:#2A2A2D;\n}\n> .label {\nfont-size: 300%;\n}", - "doubleTap": false, - "on": -1, - "off": 0, - "norelease": false, - "value": "", - "precision": 1, - "address": "/jog_horizontal", - "preArgs": "", - "target": "", - "bypass": false - }, - { - "type": "push", - "top": 30, - "left": 90, - "id": "jog_up", - "linkId": "", - "width": 60, - "height": 60, - "label": "^arrow-alt-circle-up", - "color": "auto", - "css": ":host{\n--color-raised:#2A2A2D;\n}\n> .label {\nfont-size: 300%;\n}", - "doubleTap": false, - "on": 1, - "off": 0, - "norelease": false, - "value": "", - "precision": 1, - "address": "/jog_vertical", - "preArgs": "", - "target": "", - "bypass": false - }, - { - "type": "toggle", - "top": 203, - "left": 203, - "id": "automate", - "linkId": "", - "width": 30, - "height": 30, - "label": "#{\n@{this} == 1 ? \"^stop\" : \"^play\"\n}", - "color": "grey", - "css": ":host{\n--color-raised:#2A2A2D;\n> .label {\nfont-size: 150%;\n}", - "doubleTap": false, - "on": 1, - "off": 0, - "value": "", - "precision": 1, - "address": "/automate", - "preArgs": "", - "target": "", - "bypass": false, - "led": false, - "default": "" - } - ], - "tabs": [] - }, - { - "type": "panel", - "top": 10, - "left": 10, - "id": "img_matrix", - "linkId": "", - "width": 240, - "height": 240, - "label": false, - "color": "auto", - "css": ".panel {\n background-color: black;\n border: 2px solid grey;\n}", - "scroll": false, - "border": false, - "default": "", - "value": "", - "precision": 2, - "address": "/image_select", - "preArgs": "", - "target": "", - "bypass": true, - "variables": "@{parent.variables}", - "widgets": [ - { - "type": "toggle", - "top": 20, - "left": 20, - "id": "img_1_select", - "linkId": "", - "width": 40, - "height": 40, - "label": false, - "color": "auto", - "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", - "doubleTap": false, - "led": false, - "on": 1, - "off": -1, - "default": "", - "value": "", - "precision": 2, - "address": "/img_select", - "preArgs": "", - "target": "", - "bypass": false - }, - { - "type": "toggle", - "top": 20, - "left": 100, - "id": "img_2_select", - "linkId": "", - "width": 40, - "height": 40, - "label": false, - "color": "auto", - "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", - "doubleTap": false, - "led": false, - "on": 2, - "off": -2, - "default": "", - "value": "", - "precision": 2, - "address": "/img_select", - "preArgs": "", - "target": "", - "bypass": false - }, - { - "type": "toggle", - "top": 20, - "left": 180, - "id": "img_3_select", - "linkId": "", - "width": 40, - "height": 40, - "label": false, - "color": "auto", - "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", - "doubleTap": false, - "led": false, - "on": 3, - "off": -3, - "default": "", - "value": "", - "precision": 2, - "address": "/img_select", - "preArgs": "", - "target": "", - "bypass": false - }, - { - "type": "toggle", - "top": 100, - "left": 20, - "id": "img_4_select", - "linkId": "", - "width": 40, - "height": 40, - "label": false, - "color": "auto", - "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", - "doubleTap": false, - "led": false, - "on": 4, - "off": -4, - "default": "", - "value": "", - "precision": 2, - "address": "/img_select", - "preArgs": "", - "target": "", - "bypass": false - }, - { - "type": "toggle", - "top": 180, - "left": 20, - "id": "img_7_select", - "linkId": "", - "width": 40, - "height": 40, - "label": false, - "color": "auto", - "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", - "doubleTap": false, - "led": false, - "on": 7, - "off": -7, - "default": "", - "value": "", - "precision": 2, - "address": "/img_select", - "preArgs": "", - "target": "", - "bypass": false - }, - { - "type": "toggle", - "top": 100, - "left": 100, - "id": "img_5_select", - "linkId": "", - "width": 40, - "height": 40, - "label": false, - "color": "auto", - "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", - "doubleTap": false, - "led": false, - "on": 5, - "off": -5, - "default": "", - "value": "", - "precision": 2, - "address": "/img_select", - "preArgs": "", - "target": "", - "bypass": false - }, - { - "type": "toggle", - "top": 100, - "left": 180, - "id": "img_6_select", - "linkId": "", - "width": 40, - "height": 40, - "label": false, - "color": "auto", - "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", - "doubleTap": false, - "led": false, - "on": 6, - "off": -6, - "default": "", - "value": "", - "precision": 2, - "address": "/img_select", - "preArgs": "", - "target": "", - "bypass": false - }, - { - "type": "toggle", - "top": 180, - "left": 100, - "id": "img_8_select", - "linkId": "", - "width": 40, - "height": 40, - "label": false, - "color": "auto", - "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", - "doubleTap": false, - "led": false, - "on": 8, - "off": -8, - "default": "", - "value": "", - "precision": 2, - "address": "/img_select", - "preArgs": "", - "target": "", - "bypass": false - }, - { - "type": "toggle", - "top": 180, - "left": 180, - "id": "img_9_select", - "linkId": "", - "width": 40, - "height": 40, - "label": false, - "color": "auto", - "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", - "doubleTap": false, - "led": false, - "on": 9, - "off": -9, - "default": "", - "value": "", - "precision": 2, - "address": "/img_select", - "preArgs": "", - "target": "", - "bypass": false - }, - { - "type": "push", - "top": 48, - "left": 22, - "id": "img_1_calibrate", - "linkId": "", - "width": 36, - "height": 10, - "label": false, - "color": "auto", - "css": ":host{\n--color-raised:grey;\n}", - "doubleTap": false, - "on": 1, - "off": 0, - "norelease": false, - "value": "", - "precision": 2, - "address": "/img_calibrate", - "preArgs": "", - "target": "", - "bypass": false - }, - { - "type": "push", - "top": 48, - "left": 102, - "id": "img_2_calibrate", - "linkId": "", - "width": 36, - "height": 10, - "label": false, - "color": "auto", - "css": ":host{\n--color-raised:grey;\n}", - "doubleTap": false, - "on": 2, - "off": 0, - "norelease": false, - "value": "", - "precision": 2, - "address": "/img_calibrate", - "preArgs": "", - "target": "", - "bypass": false - }, - { - "type": "push", - "top": 48, - "left": 182, - "id": "img_3_calibrate", - "linkId": "", - "width": 36, - "height": 10, - "label": false, - "color": "auto", - "css": ":host{\n--color-raised:grey;\n}", - "doubleTap": false, - "on": 3, - "off": 0, - "norelease": false, - "value": "", - "precision": 2, - "address": "/img_calibrate", - "preArgs": "", - "target": "", - "bypass": false - }, - { - "type": "push", - "top": 128, - "left": 22, - "id": "img_4_calibrate", - "linkId": "", - "width": 36, - "height": 10, - "label": false, - "color": "auto", - "css": ":host{\n--color-raised:grey;\n}", - "doubleTap": false, - "on": 4, - "off": 0, - "norelease": false, - "value": "", - "precision": 2, - "address": "/img_calibrate", - "preArgs": "", - "target": "", - "bypass": false - }, - { - "type": "push", - "top": 128, - "left": 102, - "id": "img_5_calibrate", - "linkId": "", - "width": 36, - "height": 10, - "label": false, - "color": "auto", - "css": ":host{\n--color-raised:grey;\n}", - "doubleTap": false, - "on": 5, - "off": 0, - "norelease": false, - "value": "", - "precision": 2, - "address": "/img_calibrate", - "preArgs": "", - "target": "", - "bypass": false - }, - { - "type": "push", - "top": 128, - "left": 182, - "id": "img_6_calibrate", - "linkId": "", - "width": 36, - "height": 10, - "label": false, - "color": "auto", - "css": ":host{\n--color-raised:grey;\n}", - "doubleTap": false, - "on": 6, - "off": 0, - "norelease": false, - "value": "", - "precision": 2, - "address": "/img_calibrate", - "preArgs": "", - "target": "", - "bypass": false - }, - { - "type": "push", - "top": 208, - "left": 22, - "id": "img_7_calibrate", - "linkId": "", - "width": 36, - "height": 10, - "label": false, - "color": "auto", - "css": ":host{\n--color-raised:grey;\n}", - "doubleTap": false, - "on": 7, - "off": 0, - "norelease": false, - "value": "", - "precision": 2, - "address": "/img_calibrate", - "preArgs": "", - "target": "", - "bypass": false - }, - { - "type": "push", - "top": 208, - "left": 102, - "id": "img_8_calibrate", - "linkId": "", - "width": 36, - "height": 10, - "label": false, - "color": "auto", - "css": ":host{\n--color-raised:grey;\n}", - "doubleTap": false, - "on": 8, - "off": 0, - "norelease": false, - "value": "", - "precision": 2, - "address": "/img_calibrate", - "preArgs": "", - "target": "", - "bypass": false - }, - { - "type": "push", - "top": 208, - "left": 182, - "id": "img_9_calibrate", - "linkId": "", - "width": 36, - "height": 10, - "label": false, - "color": "white", - "css": ":host{\n--color-raised:grey;\n}", - "doubleTap": false, - "on": 9, - "off": 0, - "norelease": false, - "value": "", - "precision": 2, - "address": "/img_calibrate", - "preArgs": "", - "target": "", - "bypass": false - } - ], - "tabs": [] - } - ], - "tabs": [] - }, - { - "type": "frame", - "top": "auto", - "left": "auto", - "id": "frame_3", - "linkId": "", - "width": 600, - "height": 400, - "label": "auto", - "css": "> .frame {\n background-color: black;\n border: 2px solid grey;\n}\n:host {\n top:calc(50% - 200rem);\n left:calc(50% - 800rem);\n z-index: 10;\n}", - "border": true, - "default": "", - "value": "http://10.0.0.5:5000", - "address": "/frame_3", - "preArgs": "" - } - ], - "tabs": [], - "scroll": true - } - ], - "scroll": true, - "label": false + "createdWith": "Open Stage Control", + "version": "1.25.2", + "type": "session", + "content": { + "type": "root", + "id": "root", + "linkId": "", + "css": "", + "default": "", + "value": "", + "address": "/root", + "preArgs": "", + "target": "", + "bypass": false, + "traversing": false, + "variables": {}, + "tabs": [ + { + "type": "tab", + "id": "main_tab", + "linkId": "", + "label": "a history of the domino problem", + "css": ":root {\n--color-bg: black;\n--color-raised: black;\n--color-accent: grey;\n--color-light: grey;\n}", + "default": "", + "value": "", + "address": "/tab_1", + "preArgs": "", + "target": "", + "bypass": false, + "variables": "@{parent.variables}", + "widgets": [ + { + "type": "panel", + "top": "auto", + "left": "auto", + "id": "main_panel", + "linkId": "", + "width": 502, + "height": 312, + "css": "> .panel {\n background-color: black;\n border: 2px solid grey;\n}\n:host {\n top:calc(50% - 156rem);\n left:calc(50% - 251rem);\n z-index:15;\n}", + "scroll": true, + "default": "", + "value": "", + "address": "/main_panel", + "preArgs": "", + "target": "", + "bypass": true, + "variables": "@{parent.variables}", + "widgets": [ + { + "type": "text", + "top": 248, + "left": 10, + "id": "message", + "linkId": "", + "width": 478, + "height": 50, + "css": ".text {\n background-color: black;\n border: 1px solid grey;\n}", + "vertical": false, + "wrap": false, + "align": "", + "default": " ", + "value": "", + "address": "/message", + "preArgs": "", + "decimals": 2, + "colorWidget": "white", + "lock": false, + "visible": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "target": "", + "onCreate": "", + "onValue": "" + }, + { + "type": "panel", + "top": 10, + "left": 248, + "id": "jog", + "linkId": "", + "width": 240, + "height": 240, + "css": ".panel {\n background-color: black;\n border: 2px solid grey;\n}", + "value": "", + "address": "/jog", + "preArgs": "", + "target": "", + "bypass": true, + "scroll": false, + "default": "", + "variables": "@{parent.variables}", + "widgets": [ + { + "type": "button", + "top": 150, + "left": 90, + "id": "jog_down", + "linkId": "", + "width": 60, + "height": 60, + "label": "^arrow-alt-circle-down", + "css": ":host{\n--color-raised:#2A2A2D;\n}\n> .label {\nfont-size: 300%;\n}", + "doubleTap": false, + "on": -1, + "off": 0, + "value": "", + "address": "/jog_vertical", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 1, + "mode": "push", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "default": "", + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "button", + "top": 90, + "left": 150, + "id": "jog_right", + "linkId": "", + "width": 60, + "height": 60, + "label": "^arrow-alt-circle-right", + "css": ":host{\n--color-raised:#2A2A2D;\n}\n> .label {\nfont-size: 300%;\n}", + "doubleTap": false, + "on": 1, + "off": 0, + "value": "", + "address": "/jog_horizontal", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 1, + "mode": "push", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "default": "", + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "button", + "top": 90, + "left": 30, + "id": "jog_left", + "linkId": "", + "width": 60, + "height": 60, + "label": "^arrow-alt-circle-left", + "css": ":host{\n--color-raised:#2A2A2D;\n}\n> .label {\nfont-size: 300%;\n}", + "doubleTap": false, + "on": -1, + "off": 0, + "value": "", + "address": "/jog_horizontal", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 1, + "mode": "push", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "default": "", + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "button", + "top": 30, + "left": 90, + "id": "jog_up", + "linkId": "", + "width": 60, + "height": 60, + "label": "^arrow-alt-circle-up", + "css": ":host{\n--color-raised:#2A2A2D;\n}\n> .label {\nfont-size: 300%;\n}", + "doubleTap": false, + "on": 1, + "off": 0, + "value": "", + "address": "/jog_vertical", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 1, + "mode": "push", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "default": "", + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "button", + "top": 203, + "left": 203, + "id": "automate", + "linkId": "", + "width": 30, + "height": 30, + "label": "#{\n@{this} == 1 ? \"^stop\" : \"^play\"\n}", + "css": ":host{\n--color-raised:#2A2A2D;\n> .label {\nfont-size: 150%;\n}", + "doubleTap": false, + "on": 1, + "off": 0, + "value": "", + "address": "/automate", + "preArgs": "", + "target": "", + "bypass": false, + "default": "", + "decimals": 1, + "colorWidget": "grey", + "mode": "toggle", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + } + ], + "tabs": [], + "decimals": 2, + "innerPadding": false, + "padding": 0, + "alphaStroke": 0, + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "html": "", + "colorBg": "auto", + "layout": "default", + "justify": "start", + "gridTemplate": "", + "contain": true, + "tabsPosition": "top", + "traversing": false, + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "panel", + "top": 10, + "left": 10, + "id": "img_matrix", + "linkId": "", + "width": 240, + "height": 240, + "css": ".panel {\n background-color: black;\n border: 2px solid grey;\n}", + "scroll": false, + "default": "", + "value": "", + "address": "/image_select", + "preArgs": "", + "target": "", + "bypass": true, + "variables": "@{parent.variables}", + "widgets": [ + { + "type": "button", + "top": 20, + "left": 20, + "id": "img_1_select", + "linkId": "", + "width": 40, + "height": 40, + "label": false, + "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", + "doubleTap": false, + "on": 1, + "off": -1, + "default": "", + "value": "", + "address": "/img_select", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "toggle", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "button", + "top": 20, + "left": 100, + "id": "img_2_select", + "linkId": "", + "width": 40, + "height": 40, + "label": false, + "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", + "doubleTap": false, + "on": 2, + "off": -2, + "default": "", + "value": "", + "address": "/img_select", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "toggle", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "button", + "top": 20, + "left": 180, + "id": "img_3_select", + "linkId": "", + "width": 40, + "height": 40, + "label": false, + "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", + "doubleTap": false, + "on": 3, + "off": -3, + "default": "", + "value": "", + "address": "/img_select", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "toggle", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "button", + "top": 100, + "left": 20, + "id": "img_4_select", + "linkId": "", + "width": 40, + "height": 40, + "label": false, + "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", + "doubleTap": false, + "on": 4, + "off": -4, + "default": "", + "value": "", + "address": "/img_select", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "toggle", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "button", + "top": 180, + "left": 20, + "id": "img_7_select", + "linkId": "", + "width": 40, + "height": 40, + "label": false, + "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", + "doubleTap": false, + "on": 7, + "off": -7, + "default": "", + "value": "", + "address": "/img_select", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "toggle", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "button", + "top": 100, + "left": 100, + "id": "img_5_select", + "linkId": "", + "width": 40, + "height": 40, + "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", + "default": "", + "value": "", + "address": "/img_select", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "push", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "wrap": false, + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "", + "label": false, + "doubleTap": false, + "on": 5, + "off": -5, + "vertical": false, + "decoupled": false + }, + { + "type": "button", + "top": 100, + "left": 180, + "id": "img_6_select", + "linkId": "", + "width": 40, + "height": 40, + "label": false, + "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", + "doubleTap": false, + "on": 6, + "off": -6, + "default": "", + "value": "", + "address": "/img_select", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "toggle", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "button", + "top": 180, + "left": 100, + "id": "img_8_select", + "linkId": "", + "width": 40, + "height": 40, + "label": false, + "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", + "doubleTap": false, + "on": 8, + "off": -8, + "default": "", + "value": "", + "address": "/img_select", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "toggle", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "button", + "top": 180, + "left": 180, + "id": "img_9_select", + "linkId": "", + "width": 40, + "height": 40, + "label": false, + "css": ":host{\n--color-raised:#2A2A2D;\n}\n:host.on{\n--color-bg:white;\n}", + "doubleTap": false, + "on": 9, + "off": -9, + "default": "", + "value": "", + "address": "/img_select", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "toggle", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "button", + "top": 48, + "left": 22, + "id": "img_1_calibrate", + "linkId": "", + "width": 36, + "height": 10, + "label": false, + "css": ":host{\n--color-raised:grey;\n}", + "doubleTap": false, + "on": 1, + "off": 0, + "value": "", + "address": "/img_calibrate", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "push", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "default": "", + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "button", + "top": 48, + "left": 102, + "id": "img_2_calibrate", + "linkId": "", + "width": 36, + "height": 10, + "label": false, + "css": ":host{\n--color-raised:grey;\n}", + "doubleTap": false, + "on": 2, + "off": 0, + "value": "", + "address": "/img_calibrate", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "push", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "default": "", + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "button", + "top": 48, + "left": 182, + "id": "img_3_calibrate", + "linkId": "", + "width": 36, + "height": 10, + "label": false, + "css": ":host{\n--color-raised:grey;\n}", + "doubleTap": false, + "on": 3, + "off": 0, + "value": "", + "address": "/img_calibrate", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "push", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "default": "", + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "button", + "top": 128, + "left": 22, + "id": "img_4_calibrate", + "linkId": "", + "width": 36, + "height": 10, + "label": false, + "css": ":host{\n--color-raised:grey;\n}", + "doubleTap": false, + "on": 4, + "off": 0, + "value": "", + "address": "/img_calibrate", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "push", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "default": "", + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "button", + "top": 128, + "left": 102, + "id": "img_5_calibrate", + "linkId": "", + "width": 36, + "height": 10, + "label": false, + "css": ":host{\n--color-raised:grey;\n}", + "doubleTap": false, + "on": 5, + "off": 0, + "value": "", + "address": "/img_calibrate", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "push", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "default": "", + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "button", + "top": 128, + "left": 182, + "id": "img_6_calibrate", + "linkId": "", + "width": 36, + "height": 10, + "label": false, + "css": ":host{\n--color-raised:grey;\n}", + "doubleTap": false, + "on": 6, + "off": 0, + "value": "", + "address": "/img_calibrate", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "push", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "default": "", + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "button", + "top": 208, + "left": 22, + "id": "img_7_calibrate", + "linkId": "", + "width": 36, + "height": 10, + "label": false, + "css": ":host{\n--color-raised:grey;\n}", + "doubleTap": false, + "on": 7, + "off": 0, + "value": "", + "address": "/img_calibrate", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "push", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "default": "", + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "button", + "top": 208, + "left": 102, + "id": "img_8_calibrate", + "linkId": "", + "width": 36, + "height": 10, + "label": false, + "css": ":host{\n--color-raised:grey;\n}", + "doubleTap": false, + "on": 8, + "off": 0, + "value": "", + "address": "/img_calibrate", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "colorWidget": "auto", + "mode": "push", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "default": "", + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "button", + "top": 208, + "left": 182, + "id": "img_9_calibrate", + "linkId": "", + "width": 36, + "height": 10, + "label": false, + "css": ":host{\n--color-raised:grey;\n}", + "doubleTap": false, + "on": 9, + "off": 0, + "default": "", + "value": "", + "address": "/img_calibrate", + "preArgs": "", + "target": "", + "bypass": false, + "decimals": 2, + "mode": "push", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "white", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorTextOn": "auto", + "vertical": false, + "wrap": false, + "decoupled": false, + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + } + ], + "tabs": [], + "decimals": 2, + "innerPadding": false, + "padding": 0, + "alphaStroke": 0, + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "html": "", + "colorBg": "auto", + "layout": "default", + "justify": "start", + "gridTemplate": "", + "contain": true, + "tabsPosition": "top", + "traversing": false, + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + } + ], + "tabs": [], + "decimals": 2, + "innerPadding": false, + "padding": 0, + "alphaStroke": 0, + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorWidget": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "html": "", + "colorBg": "auto", + "layout": "default", + "justify": "start", + "gridTemplate": "", + "contain": true, + "tabsPosition": "top", + "traversing": false, + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + }, + { + "type": "frame", + "top": "auto", + "left": "auto", + "id": "frame_3", + "linkId": "", + "width": 600, + "height": 400, + "css": "> .frame {\n background-color: black;\n border: 2px solid grey;\n}\n:host {\n top:calc(50% - 200rem);\n left:calc(50% - 800rem);\n z-index: 10;\n}", + "default": "", + "value": "http://10.0.0.5:5000", + "address": "/frame_3", + "preArgs": "", + "colorWidget": "auto", + "html": "@{this.id}", + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "expand": "false", + "colorText": "auto", + "colorStroke": "auto", + "colorFill": "auto", + "alphaStroke": "auto", + "alphaFillOff": "auto", + "alphaFillOn": "auto", + "lineWidth": "auto", + "borderRadius": "auto", + "padding": "auto", + "target": "", + "onCreate": "", + "onValue": "" + } + ], + "tabs": [], + "scroll": true, + "decimals": 2, + "colorWidget": "white", + "innerPadding": false, + "padding": 0, + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "colorText": "auto", + "colorFill": "auto", + "borderRadius": "auto", + "html": "", + "colorBg": "auto", + "layout": "default", + "justify": "start", + "gridTemplate": "", + "contain": true, + "tabsPosition": "top", + "traversing": false, + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "" + } + ], + "scroll": true, + "decimals": 2, + "lock": false, + "visible": true, + "interaction": true, + "comments": "", + "width": "auto", + "height": "auto", + "colorText": "auto", + "colorWidget": "auto", + "alphaFillOn": "auto", + "borderRadius": "auto", + "padding": "auto", + "html": "", + "colorBg": "auto", + "layout": "default", + "justify": "start", + "gridTemplate": "", + "contain": true, + "innerPadding": true, + "tabsPosition": "top", + "hideMenu": false, + "typeTags": "", + "ignoreDefaults": false, + "onCreate": "", + "onValue": "", + "widgets": [] + } } \ No newline at end of file diff --git a/python/vernier_tracker.py b/python/vernier_tracker.py index ce49587..e958e4f 100644 --- a/python/vernier_tracker.py +++ b/python/vernier_tracker.py @@ -8,6 +8,7 @@ from picamera2 import MappedArray, Picamera2, Preview from picamera2.previews.qt import QGlPicamera2 import numpy as np from pythonosc import udp_client +from libcamera import Transform def rectFromPoint(center, len, width, axis): @@ -85,9 +86,10 @@ def track(frame, roi, dKernel): replaceCrop(frame, roiFineOuter, thresh) meanCourse = pow(cropCoarse.mean(), 1) + #print(meanCourse) mean = 0 direction = 1 - if(meanCourse > 10): + if(meanCourse > 20): # this could potentially be made more efficient by cropping from cropFineOuter cropFineInner = crop(frame, roiFineInner) # this could potentially be made more efficient by cropping from cropFineInner @@ -125,9 +127,9 @@ def picameraToCVTrack(): #frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2RGB) distanceX = track(frame, roiX, dilationKernel) - distanceY = track(frame, roiY, dilationKernel) + distanceY = track(frame, roiY, dilationKernel) * -1 - oscClient.send_message("/distanceX", distanceX) + oscClient.send_message("/trackerpos", [distanceX, distanceY]) drawRoi(frame, roiX) drawRoi(frame, roiY) @@ -205,11 +207,12 @@ class MainWindow(QGlPicamera2): picam2 = Picamera2() #picam2.start_preview(Preview.QTGL) #max resolution is (4056, 3040) which is more like 10 fps -config = picam2.create_preview_configuration(main={"size": (2028, 1520)}, lores={"size": (768, 768), "format": "YUV420"}) +#config = picam2.create_preview_configuration(main={"size": (2028, 1520)}, lores={"size": (768, 768), "format": "YUV420"}, transform=Transform(vflip=False)) +config = picam2.create_preview_configuration(main={"size": (4056, 3040)}, lores={"size": (768, 768), "format": "YUV420"}, transform=Transform(vflip=False)) picam2.configure(config) app = QApplication([]) -qpicamera2 = MainWindow(picam2, width=1350, height=1350, keep_ar=False) +qpicamera2 = MainWindow(picam2, width=2000, height=2000, keep_ar=False) qpicamera2.setWindowTitle("Qt Picamera2 App") selectedAxis = 'x' @@ -218,8 +221,8 @@ l1 = 100 l2 = 300 l3 = 40 w = 20 -roiXCenter = (507, 98) -roiYCenter = (306, 275) +roiXCenter = (384, 20) +roiYCenter = (20, 384) roiX = rectsFromPoint(roiXCenter, l1, l2, l3, w, 'x') roiY = rectsFromPoint(roiYCenter, l1, l2, l3, w, 'y') dilationVal = 75 @@ -233,13 +236,22 @@ cv2.namedWindow("Frame", cv2.WINDOW_NORMAL) cv2.resizeWindow("Frame", 1350, 1350) cv2.setMouseCallback("Frame", moveROI) -picam2.controls.ScalerCrop = (800, 0, 3040, 3040) -picam2.controls.Brightness = 0.05 -picam2.controls.Contrast = 0.9 +#picam2.controls.ScalerCrop = (800, 0, 3040, 3040) +picam2.controls.ScalerCrop = (1375, 550, 1800, 1800) +picam2.controls.ScalerCrop = (1100, 400, 2125, 2125) +#picam2.controls.Brightness = 0.2 +picam2.controls.Contrast = 1.1 +#picam2.set_controls({"ExposureValue": 2}) +#picam2.set_controls({"ColourGains": (0, 0)}) +#picam2.set_controls({"Sharpness": 10}) +#picam2.set_controls({"AeEnable": False}) +#picam2.set_controls({"ExposureTime": 1700}) +picam2.set_controls({"Saturation": 0}) (w0, h0) = picam2.stream_configuration("main")["size"] (w1, h1) = picam2.stream_configuration("lores")["size"] s1 = picam2.stream_configuration("lores")["stride"] +print(h1) picam2.start() diff --git a/supercollider/installation_control.scd b/supercollider/installation_control.scd index 36ffad9..7735f56 100644 --- a/supercollider/installation_control.scd +++ b/supercollider/installation_control.scd @@ -13,7 +13,7 @@ automation = false; imgPositions = 9.collect({nil}); curPos = Point.new(0, 0); tarPos = Point.new(0, 0); -netAddress = NetAddr.new("127.0.0.1", 7777); +netAddress = NetAddr.new("127.0.0.1", 8080); ~serialPort = SerialPort("/dev/ttyACM0", baudrate: 115200, crtscts: true); // recieve motor feedback @@ -27,7 +27,7 @@ netAddress = NetAddr.new("127.0.0.1", 7777); byte = ~serialPort.read; if(byte==13, { if(str[1].asString == "[", { - valArray = str.asString.interpret; //.postln; + valArray = str.asString.interpret;//.postln; curPos = Point.new(valArray[0], valArray[1]); limitSwitchNeg = valArray[2]; limitSwitchPos = valArray[3]; @@ -68,6 +68,8 @@ netAddress = NetAddr.new("127.0.0.1", 7777); // send new coordinates to the arduino / motors moveTo = {arg point; + "move to".postln; + point.postln; ~serialPort.putAll(point.x.asInteger.asString ++ " " ++ point.y.asInteger.asString); ~serialPort.put(10); }; @@ -77,12 +79,14 @@ jogControl = {arg axis; jog = Task({ loop{ count = (count + 0.01).clip(0, 1); + count.postln; jogRate = pow(count, 2) * 500; if(axis == '/jog_horizontal', { tarPos.x = curPos.x + (jogRate * jogDirection); }, { tarPos.y = curPos.y + (jogRate * jogDirection); }); + curPos.postln; moveTo.value(tarPos); 0.1.wait }; @@ -90,10 +94,18 @@ jogControl = {arg axis; OSCFunc({arg msg; //tarPos.x = curPos.x + (1000 * msg[1]); //moveTo.value(tarPos); + msg.postln; if(msg[1] == 0, {count = 0; jogRate = 0; jog.pause()}, {jogDirection = msg[1]; jog.play(AppClock)}); automation = false; - netAddress.sendMsg("/STATE/SET", "{automate: 0}"); - }, axis, netAddress) + //netAddress.sendMsg("/STATE/SET", "{automate: 0}"); + }, axis, netAddress); + OSCFunc({arg msg; + //tarPos.x = curPos.x + (1000 * msg[1]); + //moveTo.value(tarPos); + if(msg[1] == 0, {count = 0; jogRate = 0; jog.pause()}, {jogRate = 10; jogDirection = msg[1]; jog.play(AppClock)}); + automation = false; + //netAddress.sendMsg("/STATE/SET", "{automate: 0}"); + }, axis, NetAddr.localAddr) }; jogHorizontal = jogControl.value('/jog_horizontal'); @@ -105,14 +117,15 @@ imgSelect = { var imgIndex; if(msg[1] > 0, { imgIndex = msg[1] - 1; + imgIndex.postln; if(imgPositions[imgIndex] != nil, {tarPos = imgPositions[imgIndex].deepCopy; moveTo.value(tarPos)}); 9.do({arg i; if(imgIndex != i, { netAddress.sendMsg("/STATE/SET", "{img_" ++ (i + 1).asString ++ "_select: " ++ (i + 1).neg ++ "}")})}); automation = false; - netAddress.sendMsg("/STATE/SET", "{automate: 0}"); + //netAddress.sendMsg("/STATE/SET", "{automate: 0}"); lastSelect = imgIndex; }, { - lastSelect = 0; + //lastSelect = 0; /* imgIndex = msg[1].neg - 1; if(imgIndex == lastSelect, { @@ -128,6 +141,7 @@ imgCalibrate = { calibrateHold = Routine({ 20.do({0.1.wait}); imgPositions[imgIndex] = setPos.deepCopy; + imgPositions.postln; netAddress.sendMsg("/STATE/SET", "{message: \"image calibrated\"}"); }); @@ -143,6 +157,7 @@ imgCalibrate = { }.value; automate = OSCFunc({arg msg; + msg.postln; if(msg[1] == 1, { automation = true; }, { @@ -154,7 +169,24 @@ automate = OSCFunc({arg msg; }, '/automate', netAddress); trackerPos = OSCFunc({arg msg; - msg.postln; + //imgPositions.postln[lastSelect.postln]; + if(lastSelect != nil, { + var distX, distY, isFocusing; + distX = curPos.x - imgPositions[lastSelect].x; + distY = curPos.y - imgPositions[lastSelect].y; + isFocusing = false; + if((imgPositions[lastSelect] != nil) && (distX.abs < 500) && (msg[1].abs > 6000), { + tarPos.x = curPos.x + (10 * msg[1].sign * -1); + isFocusing = true; + //NetAddr.localAddr.sendMsg('/jog_horizontal', msg[1].sign.postln * -1); + }); + if((imgPositions[lastSelect] != nil) && (distY.abs < 500) && (msg[2].abs > 6000), { + tarPos.y = curPos.y + (10 * msg[2].sign * -1); + isFocusing = true; + }); + if(isFocusing, {moveTo.value(tarPos)}); + }) + //msg.postln; }, '/trackerpos'); ) ~serialPort.close