aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MotionControl/Constraints.py0
-rw-r--r--MotionControl/MotionPlanner.py0
-rwxr-xr-xmotiond/motiond2
-rw-r--r--scratchpad.py83
4 files changed, 85 insertions, 0 deletions
diff --git a/MotionControl/Constraints.py b/MotionControl/Constraints.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/MotionControl/Constraints.py
diff --git a/MotionControl/MotionPlanner.py b/MotionControl/MotionPlanner.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/MotionControl/MotionPlanner.py
diff --git a/motiond/motiond b/motiond/motiond
new file mode 100755
index 0000000..6c2cadb
--- /dev/null
+++ b/motiond/motiond
@@ -0,0 +1,2 @@
+#!/usr/bin/python2
+# -*- encoding: utf-8 -*-
diff --git a/scratchpad.py b/scratchpad.py
index 56c886d..e5aac7b 100644
--- a/scratchpad.py
+++ b/scratchpad.py
@@ -1,5 +1,88 @@
# -*- coding: utf-8 -*-
+import Queue
+import threading
+
+class Action:
+ EXECUTING = 0
+ FINISHED = 1
+ ABORTED = 2
+ def execute(self):
+ self.aborted = False
+ self.do_execute()
+
+ def ended(self):
+ if self.aborted:
+ return True
+ return do_ended()
+
+ def abort(self):
+ self.do_abort()
+ self.aborted = True
+
+ def do_execute():
+ raise NotImplementedError
+
+ def do_abort():
+ raise NotImplementedError
+
+ def do_ended():
+ raise NotImplementedError
+
+
+class ActionMotion(Action):
+ def __init__(self, axes, target, speed = None):
+ if len(axes) != len(target):
+ raise ValueError()
+ if speed and len(speed) != len(axes):
+ raise ValueError()
+
+ self.axes = axes
+ self.target_position = target
+ self.motion_speed = speed
+
+ def do_execute(self):
+ for i, axis enumerate(self.axes):
+ if self.speed:
+ axis.
+
+class ActionExecuter(threading.Thread)
+ def __init__(self, action):
+ self.action = action
+
+ def start(self):
+ import threading, weakref
+ self.running = True
+ self.worker_thread = threading.Thread(target=ActionExecuter.run, args=(weakref.proxy(self),))
+
+ def abort(self):
+ self.running = False
+ self.worker_thread.join()
+
+ def run(self):
+ action = self.action
+ try:
+ action.execute()
+ except ReferenceError:
+ action.abort()
+
+
+class MotionControl(object):
+ def __init__(self, name):
+ self.name = name
+ self.active = True
+ self.worker_thread = threading.Thread(target = self.workerLoop, name = "MotionControl.worker_thread")
+ self.worker_thread.setDaemon(True)
+ self.worker_thread.start()
+
+ def __del__(self):
+
+ def workerLoop(self):
+ import time
+ while self.active:
+ print self.name
+ time.sleep(1)
+
import threading
import rpyc
import Phytron