Update planner position correctly after stop
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Wed, 19 Dec 2018 08:33:49 +0000 (00:33 -0800)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Wed, 19 Dec 2018 08:33:49 +0000 (00:33 -0800)
src/py/bbctrl/Mach.py
src/py/bbctrl/Planner.py
src/py/bbctrl/Preplanner.py

index 7a5e9628b4d8eb82d451189b3aa127425a4ad75c..987015489d0b4403806c9e42a7950edf120c71f2 100644 (file)
@@ -170,6 +170,7 @@ class Mach(Comm):
 
         if pause_reason == 'User stop':
             self.planner.stop()
+            self.planner.update_position()
             self.ctrl.state.set('line', 0)
 
         else: self.planner.restart()
index fc6e7e9a49e255cd2717a0c6b91686ca1d68aca4..220d612f34018e7dbb2f3ca67e61b624deb57c71 100644 (file)
@@ -70,7 +70,11 @@ class Planner():
     def is_running(self): return self.planner.is_running()
 
 
-    def get_config(self, mdi, with_limits, with_position = True):
+    def update_position(self):
+        self.planner.set_position(self.ctrl.state.get_position())
+
+
+    def get_config(self, mdi, with_limits):
         state = self.ctrl.state
         config = self.ctrl.config
 
@@ -84,8 +88,6 @@ class Planner():
             # TODO junction deviation & accel
             }
 
-        if with_position: cfg['position'] = state.get_position()
-
         if with_limits:
             minLimit = state.get_soft_limit_vector('tn', -math.inf)
             maxLimit = state.get_soft_limit_vector('tm', math.inf)
@@ -289,6 +291,7 @@ class Planner():
         self.planner = gplan.Planner()
         self.planner.set_resolver(self._get_var_cb)
         self.planner.set_logger(self._log_cb, 1, 'LinePlanner:3')
+        self.update_position()
         self.cmdq.clear()
         self.reset_times()
         self.ctrl.state.reset()
index 25a60f8a4e97ade1b2e32adea5eeb69e202cace0..b2aaafc94a68b214145a65eb72ef53c56961822a 100644 (file)
@@ -148,7 +148,7 @@ class Preplanner(object):
 
         # Copy state for thread
         state = self.ctrl.state.snapshot()
-        config = self.ctrl.mach.planner.get_config(False, False, False)
+        config = self.ctrl.mach.planner.get_config(False, False)
         del config['default-units']
 
         # Start planner thread