04-05-2023, 02:08 PM
I am trying to real-time control a kuka using a spacemouse. I can move the kuka using the mouse, but i get delays, over 1s! I am wondering why, and how i can fix this. All of this is done in the simulation, so i expect extra delay when executing it on the robotic arm, which would make this even worse.
code:
from robolink import *
from robodk import *
进口pyspacemouse
RDK = Robolink()
kuka = RDK.Item('', ITEM_TYPE_ROBOT)
RDK.setSimulationSpeed(1)
kuka.setSpeed(speed_linear=10, speed_joints=10, accel_joints=1, accel_linear=1)
mouse = pyspacemouse.open()
move_speed = 1
while 1:
data = mouse.read()
xyzinputs = [round(data.y, 1), round(-1*data.x, 1), 0]
if norm(xyzinputs) <= 0:
continue
xyz_move = mult3(xyzinputs, move_speed)
joints = kuka.Joints()
position = kuka.SolveFK(joints)
config = kuka.JointsConfig(joints)
new_position = transl(xyz_move) * position
new_joints = kuka.SolveIK(new_position)
if len(new_joints.tolist()) < 6:
print('no solution')
continue
new_config = kuka.JointsConfig(new_joints)
kuka.MoveJ(new_joints)
----
it's based on an example that uses keyboard inputs.
I have not worked with roboDK in combination with Python before, so I might be missing something obvious.
Could it have something to do with the advance that Kuka uses to precalculate movements? and this seems to work from PTP, moving just tiny steps at a time, but would there be a way to continually move?
code:
from robolink import *
from robodk import *
进口pyspacemouse
RDK = Robolink()
kuka = RDK.Item('', ITEM_TYPE_ROBOT)
RDK.setSimulationSpeed(1)
kuka.setSpeed(speed_linear=10, speed_joints=10, accel_joints=1, accel_linear=1)
mouse = pyspacemouse.open()
move_speed = 1
while 1:
data = mouse.read()
xyzinputs = [round(data.y, 1), round(-1*data.x, 1), 0]
if norm(xyzinputs) <= 0:
continue
xyz_move = mult3(xyzinputs, move_speed)
joints = kuka.Joints()
position = kuka.SolveFK(joints)
config = kuka.JointsConfig(joints)
new_position = transl(xyz_move) * position
new_joints = kuka.SolveIK(new_position)
if len(new_joints.tolist()) < 6:
print('no solution')
continue
new_config = kuka.JointsConfig(new_joints)
kuka.MoveJ(new_joints)
----
it's based on an example that uses keyboard inputs.
I have not worked with roboDK in combination with Python before, so I might be missing something obvious.
Could it have something to do with the advance that Kuka uses to precalculate movements? and this seems to work from PTP, moving just tiny steps at a time, but would there be a way to continually move?