Rotation in the TCP vector space using speedl()

Hello,

I would like to implement a rotation using the speedl command. I succeeded for linear translation using the topic Move (JOG) along Base or Tool axis.

But when I implement the same script for the rotation, it is performed in the base vector space.

My script:

global pos=get_actual_tcp_pose()
global ts=pose_trans(pos, p[0,0,0,0,0,0.02])
global dir=pose_sub(ts, pos)
speedl([dir[0],dir[1],dir[2],dir[3],dir[4],dir[5]],0.1,10)

I thought the rotation would be performed in the TCP referential. But if I turn the tool in an other orientation, the rotation is performed in the same direction as previously in the base referential.

I tried to use pose_inv without success.

Has anyone any idea regarding the problem?

Thanks in advance

Aurélien

Hi,

maybe this works for you:

acc = 0.1
vel = 0.5
control_time = 0.01

Rx = 0
Ry = 0
Rz = 0.1 # put in a psoitive or negative value for direction

global pos=get_actual_tcp_pose()
global ts=get_inverse_kin(pose_trans(pos, p[0,0,0,Rx,Ry,Rz]))

servoj(ts,acc,vel,control_time,0.05)

maybe you need to play with parameters of servoj for smooth movement.
Adjust vel and Rx,Ry or Rz values for faster movement…
Just play around with parameters…I only tested it in simulator so im not sure how good it works for real robot

2 Likes

Hi,

Thank you for this solution. It’s exactly what I need and it works perfectly on my robot.

Aurélien

Hi,

Today, I test the script again and I realize that the script performs a slight translation during the rotation for a rotation in Rx or Ry.
I modified the control_time to 10 value to execute the rotation during 10 seconds. Is it the cause of my problem?
Should I loop on the servoj with a while condition and a control_time smaller? (Is the displacement recomputed at each servoj call and that’s why the rotation is not correctly performed?)

Thank you for your help.

Aurélien

The ServoJ timestep should generally be small. I.e. 2 ms on e-Series and 8 ms on CB3 is great.
You probably want to loop over this sequence with small step-size until the target is reached.

1 Like

Hi,

I’m back on the subject and I’ve implemented the solution using a loop. But I’ve still a slight translation of the position of the tool during the rotation. I need to keep the position x, y, z of the tool.
Is it possible to introduce a correction in the servoj command to compensate the deviation? By using the original position of the tool before entering in the loop and by computing the difference of the position between the current location and the original one?

Like this:

acc = 0
vel = 0
control_time = 0.8
lookahead_time = 0.1
gain = 300

Rx = 0.01
Ry = 0
Rz = 0
i = 0

pos_orig=get_actual_tcp_pose()

while i < 2500

pos=get_actual_tcp_pose()
pos_delta=pose_sub(pos_orig,pos)
ts=get_inverse_kin(pose_trans(pos, p[pos_delta[0],pos_delta[1],pos_delta[2],Rx,Ry,Rz]))

servoj(ts,acc,vel,control_time,lookahead_time,gain)
i = i+1
end

Aurélien