diff --git a/invesalius/constants.py b/invesalius/constants.py index 9278b6a..a20b1fe 100644 --- a/invesalius/constants.py +++ b/invesalius/constants.py @@ -858,3 +858,7 @@ ROBOT_ARC_THRESHOLD_DISTANCE = 100 #mm ROBOT_VERSOR_SCALE_FACTOR = 70 #Robot Working Space is defined as 800mm in Elfin manual. For safety, the value is reduced by 5%. ROBOT_WORKING_SPACE = 760 #mm +ROBOT_MOVE_STATE = {"free to move": 0, + "in motion": 1009, + "waiting for execution": 1013, + "error": 1025} diff --git a/invesalius/data/elfin.py b/invesalius/data/elfin.py index 8fe34f4..eceda82 100644 --- a/invesalius/data/elfin.py +++ b/invesalius/data/elfin.py @@ -24,17 +24,19 @@ class Elfin_Server(): def Run(self): return self.cobot.ReadPcsActualPos() - def SendCoordinates(self, target, type=const.ROBOT_MOTIONS["normal"]): + def SendCoordinates(self, target, motion_type=const.ROBOT_MOTIONS["normal"]): """ It's not possible to send a move command to elfin if the robot is during a move. Status 1009 means robot in motion. """ status = self.cobot.ReadMoveState() - if status != 1009: - if type == const.ROBOT_MOTIONS["normal"] or type == const.ROBOT_MOTIONS["linear out"]: + if status == const.ROBOT_MOVE_STATE["free to move"]: + if motion_type == const.ROBOT_MOTIONS["normal"] or motion_type == const.ROBOT_MOTIONS["linear out"]: self.cobot.MoveL(target) - elif type == const.ROBOT_MOTIONS["arc"]: + elif motion_type == const.ROBOT_MOTIONS["arc"]: self.cobot.MoveC(target) + elif status == const.ROBOT_MOVE_STATE["error"]: + self.StopRobot() def StopRobot(self): # Takes some microseconds to the robot actual stops after the command. diff --git a/invesalius/navigation/robot.py b/invesalius/navigation/robot.py index 33196a2..bf9ed80 100644 --- a/invesalius/navigation/robot.py +++ b/invesalius/navigation/robot.py @@ -277,6 +277,9 @@ class ControlRobot(threading.Thread): if not self.robot_target_queue.empty(): self.robot_tracker_flag, self.m_change_robot_to_head = self.robot_target_queue.get_nowait() + self.trck_init_robot.StopRobot() + self.arc_motion_flag = False + self.arc_motion_step_flag = const.ROBOT_MOTIONS["normal"] self.robot_target_queue.task_done() if not self.object_at_target_queue.empty(): -- libgit2 0.21.2