I'm trying to simulate a KUKA KR 10 R1100-2 in RoboDK but I'm running into an issue where the MoveJ command blocks all threads trying to access RoboDK, even though blocking is set to false. The simple code shown below demonstrates the issue:
It produces the following output which shows that the first move is queued instantly but when the second move is queued RoboDK blocks until the first queued move finishes. This means that until then I cannot read any data from RoboDK during movement and only 2 moves are queueable at once.
RoboDK is Running...
Tick0: 0.01750922203063965s
Tick1: 0.4813239574432373s
Tick2: 0.46680164337158203s
Tick3: 0.4840884208679199s
Tick4: 0.47762632369995117s
Tick5: 0.4962923526763916s
Tick6: 0.5008013248443604s
Tick7: 0.5033588409423828s
Tick8: 0.5121309757232666s
Tick9: 0.5225851535797119s
RoboDK will close now.
The issue is that I need to queue multiple moves and then constantly read the robot pose as it performs them. I have tried to read the pose from another thread as shown in the code below but it is blocked from accessing RoboDK until only 1 move is queued so I only get the pose whenever the robot finishes a move, right before the next is queued and while the last move is performed.
How can I go about queuing up 2 moves and simultaneously reading the pose of the robot, and how do I queue more than 2 moves? I have also tried sending the MoveJ command from a separate thread, resulting in the same issue.
The robot item in the RDK file uses the KRC2 post processor.
Code:
from robodk.robolink import *
import time
link = Robolink()
link.AddFile("FILEPATH")
robot = link.Item('', ITEM_TYPE_ROBOT)
target = link.AddTarget("Target1", robot.Parent())
for i in range(10):
start = time.time()
target.setPose(target.Pose().Offset(10, 0, 0, 0, 0, 0))
robot.MoveJ(target = target, blocking = False)
end = time.time()
print("Tick" + str(i) + ": " + str(end-start) + "s")
link.CloseRoboDK()
It produces the following output which shows that the first move is queued instantly but when the second move is queued RoboDK blocks until the first queued move finishes. This means that until then I cannot read any data from RoboDK during movement and only 2 moves are queueable at once.
RoboDK is Running...
Tick0: 0.01750922203063965s
Tick1: 0.4813239574432373s
Tick2: 0.46680164337158203s
Tick3: 0.4840884208679199s
Tick4: 0.47762632369995117s
Tick5: 0.4962923526763916s
Tick6: 0.5008013248443604s
Tick7: 0.5033588409423828s
Tick8: 0.5121309757232666s
Tick9: 0.5225851535797119s
RoboDK will close now.
The issue is that I need to queue multiple moves and then constantly read the robot pose as it performs them. I have tried to read the pose from another thread as shown in the code below but it is blocked from accessing RoboDK until only 1 move is queued so I only get the pose whenever the robot finishes a move, right before the next is queued and while the last move is performed.
Code:
class Monitor(threading.Thread):
def __init__(self):
super().__init__()
self.stopflag = threading.Event()
def set_args(self, robot):
self.robot = robot
def run(self):
while not self.stopflag.is_set():
print(robomath.Pose_2_KUKA(robot.Pose()))
# Called before for loop:
monitor = Monitor()
monitor.set_args(robot=robot)
monitor.start()
How can I go about queuing up 2 moves and simultaneously reading the pose of the robot, and how do I queue more than 2 moves? I have also tried sending the MoveJ command from a separate thread, resulting in the same issue.
The robot item in the RDK file uses the KRC2 post processor.