From 8e14004e1a9174ab86bae928f46fe50e175740bd Mon Sep 17 00:00:00 2001 From: gobbo_a Date: Wed, 1 Feb 2023 16:47:56 +0100 Subject: [PATCH] --- plugins/RobotBernina.java | 8 ++++---- script/local.py | 7 ++++++- script/motion/move_home.py | 18 ++++++++++++++++++ script/motion/move_park.py | 18 ++++++++++++++++++ script/motion/tools.py | 32 ++++++++++++++++++++++++++++++++ script/motion/tweak.py | 36 ++++++++++++++++++++++++++++++++++++ 6 files changed, 114 insertions(+), 5 deletions(-) mode change 100755 => 100644 script/local.py create mode 100644 script/motion/move_home.py create mode 100644 script/motion/move_park.py create mode 100644 script/motion/tools.py create mode 100644 script/motion/tweak.py diff --git a/plugins/RobotBernina.java b/plugins/RobotBernina.java index 3661eca..6075c46 100755 --- a/plugins/RobotBernina.java +++ b/plugins/RobotBernina.java @@ -1040,11 +1040,11 @@ public class RobotBernina extends Panel { }// //GEN-END:initComponents private void moveParkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moveParkActionPerformed - evalCmd("robot.move_park()"); + evalCmd("move_park()"); }//GEN-LAST:event_moveParkActionPerformed private void moveHomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moveHomeActionPerformed - evalCmd("robot.move_home()"); + evalCmd("move_home()"); }//GEN-LAST:event_moveHomeActionPerformed private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed @@ -1145,11 +1145,11 @@ public class RobotBernina extends Panel { }//GEN-LAST:event_comboCamerasActionPerformed private void buttonTweakXActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonTweakXActionPerformed - evalCmd("robot.tweak_x(" + spinnerOffsetX.getValue() + ")"); + evalCmd("tweak_x(" + spinnerOffsetX.getValue() + ")"); }//GEN-LAST:event_buttonTweakXActionPerformed private void buttonTweakX1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonTweakX1ActionPerformed - evalCmd("robot.tweak_y(" + spinnerOffsetY.getValue() + ")"); + evalCmd("tweak_y(" + spinnerOffsetY.getValue() + ")"); }//GEN-LAST:event_buttonTweakX1ActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables diff --git a/script/local.py b/script/local.py old mode 100755 new mode 100644 index bb1d0eb..31ba22a --- a/script/local.py +++ b/script/local.py @@ -3,4 +3,9 @@ ################################################################################################### run("devices/RobotBernina") -run("devices/Axis") \ No newline at end of file +run("devices/Axis") +run ("motion/tools") +run ("motion/move_home") +run ("motion/move_park") +run ("motion/tweak") + diff --git a/script/motion/move_home.py b/script/motion/move_home.py new file mode 100644 index 0000000..a0dfede --- /dev/null +++ b/script/motion/move_home.py @@ -0,0 +1,18 @@ +def move_home(): + """ + """ + print "move_home" + + #Initial checks + robot.assert_no_task() + robot.reset_motion() + robot.wait_ready() + #robot.assert_cleared() + #robot.assert_in_known_point() + + #Enabling + enable_motion() + + + if not robot.is_home(): + robot.move_home() diff --git a/script/motion/move_park.py b/script/motion/move_park.py new file mode 100644 index 0000000..eadc7f6 --- /dev/null +++ b/script/motion/move_park.py @@ -0,0 +1,18 @@ +def move_park(): + """ + """ + print "move_park" + + #Initial checks + robot.assert_no_task() + robot.reset_motion() + robot.wait_ready() + #robot.assert_cleared() + #robot.assert_in_known_point() + + #Enabling + enable_motion() + + + if not robot.is_park(): + robot.move_park() diff --git a/script/motion/tools.py b/script/motion/tools.py new file mode 100644 index 0000000..17fcbf3 --- /dev/null +++ b/script/motion/tools.py @@ -0,0 +1,32 @@ +POSITION_TOLERANCE = 50 + + +def is_manual_mode(): + """ + return if operating in local mode. TODO: should be based on IO, not on robot flag. + """ + return robot.working_mode == "manual" + +def enable_motion(): + """ + Check safety and enable arm power if in remote mode + """ + release_safety() + system_check(robot_move=True) + auto = not is_manual_mode() + if auto: + if not robot.state.isNormal(): + raise Exception("Cannot enable power: robot state is " + str(robot.state)) + robot.enable() + + +def wait_end_of_move(): + robot.update() + while (not robot.settled) or (not robot.empty) or (not robot.isReady()) : + time.sleep(0.01) + +def release_safety(): + pass + +def system_check(robot_move=True): + pass \ No newline at end of file diff --git a/script/motion/tweak.py b/script/motion/tweak.py new file mode 100644 index 0000000..aabe357 --- /dev/null +++ b/script/motion/tweak.py @@ -0,0 +1,36 @@ +def tweak_x(offset): + """ + """ + print "tweak_x", offset + + #Initial checks + robot.assert_no_task() + robot.reset_motion() + robot.wait_ready() + #robot.assert_cleared() + #robot.assert_in_known_point() + + #Enabling + enable_motion() + + robot.tweak_x(offset) + + + +def tweak_y(offset): + """ + """ + print "tweak_y", offset + + #Initial checks + robot.assert_no_task() + robot.reset_motion() + robot.wait_ready() + #robot.assert_cleared() + #robot.assert_in_known_point() + + #Enabling + enable_motion() + + + robot.tweak_y(offset)