Script Code pose_add and pose_trans

Hi,
Can someone explain me about pose_trans and pose_add commands. I don’t exactly understand the difference between both the commands.When I tried to use pose_add command, the values of Rx, Ry and Rz are getting inversed.
Eg. Consider having a pose1[0.2,1.0.0.9,2.22,2.22,0]. Now I created a script code as follows,
pose2:=pose_add(pose1,p[0,0,-0.5,0,0,0]). When I looked into the pose1 variable value it was as follows pose1 = p[0.2,1.0,0.4,-2.22,-2.22,0]. Here the values in Rx and Ry has got a negative sign after executing pose_add command. I have not added any values to Rx and Ry. Can someone help me to find out why did this happen?
And regarding pose_trans can someone help me to understand how this works ?

It may seem unintuitive, but the negative sign has no influence on the resulting pose in this case. The two negative signs basically cancel each other.
[0.2, 1.0, 0.9, 2.22, 2.22, 0] and
[0.2, 1.0, 0.9, -2.22,- 2.22, 0] Are the same pose.

My rule of thumb is that 9/10 times you will want to use pose_trans, this is because pose_trans is an actual matrix transformation where pose_add is a much close to a simpler vector addition.

pose_trans actually treat the combined position and rotation as a whole where the pose add do the calculation individually on each.

because of this pose_add(A, B) == pose_add(B, A) while pose_trans(A,B) == pose_trans(B,A), is only the case in very simple scenarios and should in general just be assumed false

so it would be more correct to assume → pose_trans(A,B) != pose_trans(B,A).

– side Note–
just as a little side note avoid using pose_sub to remove one reference frame from another instead use a combinations of pose_inv and pose_trans to “subtract/remove” a pose from another.

the classic example would be a the calculation from the robot base to the TCP.
lets say we only know the actual_tcp_pose (denoted A) and the flange_pose (denoted F)
and we the want to find the tcp_offset (denoted O)

we know A = F*O
where we use * to represent a matrix transformation aka pose_trans

as all of these poses are actually represented as matrices we need to use matrix multiplications Rules

O = F^(-1)*A

so the final result become O = pose_trans(pose_inv(F), A)

best Regards

Robin

Thanks for the reply. I will check that.

Hi

Thanks for the reply.

You are correct on pose_trans. I use that extensively over my program. No my question is with the same above example which I mentioned.
Consider pose1[0.2,1.0.0.9,2.22,2.22,0].
Now I need to move my Z Axis Up(w.r.t base coordinate) without changing my other axes. For that I tried the command pose2:=pose_add(pose1,p[0,0,-0.5,0,0,0]). The pose2 variable with coordinates totally change since it is a kinematic calculation(as per what I understood). All the axis values changes, which causes hitting of nearby objects. So, can you please help me out how to move individual Z axis alone up ? I’m not sure of which command I need to use for moving Z axis aloe up.

You want to use a pose_trans(p[0,0,-0.5,0,0,0], pose1)

because we are working in the base reference frame what you actually what is to move up z_base before applying the pose, not the other way around as you would end up applying it in the TCP reference frame instead.

Can you post the exact code you use in URscript?

What you want to do can be achieved with pose_add:

current_pose= get_actual_tcp_pose()
z_up_pose = p[0, 0, 0.1, 0, 0, 0] # will move up by 100mm
new_pose = pose_add(current_pose, z_up_pose)
movel(new_pose) 

I am having the same issue, I am trying to amend the z coordinate of a waypoint variable by 15mm but couldnt get it to work in either of the below ways:
new_waypoint = old_waypoint + [0,0,0.015,0,0,0]

new_waypoint = pose_add(old_waypoint, [0,0,0.015,0,0,0])

new_waypoint = pose_add([0,0,0.015,0,0,0], old_waypoint)

new_waypoint = pose_add(old_waypoint, p[0,0,0.015,0,0,0])

v=0.015
new_waypoint = pose_add(old_waypoint, [0,0,0.v,0,0,0])

Could someone hwlp me with the right way to do it?

@c2034773 what errors are you getting or what is the result of your code currently?

The program starts running and shows an error while trying to move to the waypoint I just altered.
Value error: ‘fix_clr’ is not initialized to a value.

fix_clr is the variable waypoint.

well, in that case your problem is not with the pose_add function but with another part of your code.
If you can post the full code it might become clear what could be happening



Thankyou for helping out robin_gdwl,
I am new to using urscript, here are some pictures attached.

Showing the line numbers would be helpful. Likely you’re just trying to actually move to “fix_clr” or else are using it in a calculation somewhere before you’ve actually assigned it a value.

I am having the same issue want to leave all the pose the same just move the z or just the y and z. using the add or trans I get no inverse kin… found. I can use the move command(on the pendant), and it will go there, but the numbers are not what is calculated with the add or the trans. I just want to change the z or y numbers with a variable and leave the rest alone.

My bad was missing a decimal point. in one of my variables poses. to blind guys comas look a lot like decimals. :slight_smile: