Posts: 16
Threads: 5
Joined: Mar 2019
Reputation:
0
Hello,
I'm trying to use the Offset instruction, but not sure how. Below is my code and I get an error when I run my program. Clearly, the code is wrong but I don't know how the offset instruction works. I appreciate the help.
Code: # Retrieve the robot reference frame
reference = robot.Parent()
# Use the robot base frame as the active reference
robot.setPoseFrame(reference)
# get the current orientation of the robot (with respect to the active reference frame and tool frame)
pose_ref = robot.Pose()
pos_ref = pose_ref.Pos()
print(Pose_2_TxyzRxyz(pose_ref))
pose_i = pose_ref
#pose_i.setPos(Offset(pose_ref, vetor.x,vetor.y, vetor.z, vetor.rx,vetor.ry, vetor.rz ))
pos_n = Offset(pose_ref,10,10,10,0,0,0)
pose_i.setPos(pos_n)
robot.MoveL(pose_i)
Posts: 1,829
Threads: 2
Joined: Oct 2018
Reputation:
74
Hi rett84,
If you look closely at your code, you didn't write your setPose function call correctly.
There is an "e" missing at the end...
https://robodk.com/doc/en/PythonAPI/robo...em.setPose
Other than that, your code seems to work on my end.
Jeremy
Posts: 16
Threads: 5
Joined: Mar 2019
Reputation:
0
03-06-2019, 03:03 AM
(This post was last modified: 03-06-2019, 04:01 AM by rett84.)
Thanks for your reply Jeremry. Unfortunately adding an 'e' did not work. Actually, my code is based on this example:
https://robodk.com/doc/en/PythonAPI/exam...ugh-points
Where there is no 'e' for SetPos. Running the code with Setpos I get the following error:
Code: raise Exception(MatrixError, "Submatrix indices does not match the new matrix sizes",itmsz[0],"x",itmsz[1],"<-",newm,"x",newn)
Exception: (<class 'robodk.MatrixError'>, 'Submatrix indices does not match the new matrix sizes', 1, 'x', 4, '<-', range(0, 1), 'x', range(3, 4))
and running Setpose the following error:
Code: pose_i.setPose(pos_n)
AttributeError: 'Mat' object has no attribute 'setPose'
Looks like Setpose is not an attribute?
Thanks for the help.
I got it to work, below is the code that I needed:
Code: pose_n = pose_i.Offset(500,500,500,0,0,0)
robot.MoveL(pose_n)
Now my next question, is it possible to combine the Offset with Reltool instruction?
in ABB Rapid I would do this:
Code: MoveL Offs(RelTool(robot_cur,0,0,0\Rx:=0\Ry:=0\Rz:=5),500,500,500)
Thank you.
Posts: 1,829
Threads: 2
Joined: Oct 2018
Reputation:
74
03-06-2019, 03:13 PM
(This post was last modified: 03-06-2019, 08:31 PM by Jeremy.)
I answer you that because I tested your code myself and applied that simple correction :
Code: robot = RDK.Item('ABB IRB 120-3/0.6')
# Retrieve the robot reference frame
reference = robot.Parent()
# Use the robot base frame as the active reference
robot.setPoseFrame(reference)
# get the current orientation of the robot (with respect to the active reference frame and tool frame)
pose_ref = robot.Pose()
pos_ref = pose_ref.Pos()
print(Pose_2_TxyzRxyz(pose_ref))
Target2 = RDK.AddTarget('Target 2')
Target2.setPose(Offset(pose_ref, -300, 10, 10, 0, 0, 0))
robot.MoveL(Target2)
Posts: 16
Threads: 5
Joined: Mar 2019
Reputation:
0
Thanks Jeremy. Sorry for the misunderstanding. In regards to my second question, do you know if it is possible to combine the Offset with Reltool instruction?
Posts: 1,829
Threads: 2
Joined: Oct 2018
Reputation:
74
It's highly possible.
At the end, in RAPID or with RDK, Offset and Reltool are only Matrix that you multiply with your target pose (matrix).
You just have to figure out the right order of multiplication.
Posts: 3,470
Threads: 2
Joined: Apr 2018
Reputation:
165
Yes, this is possible. We have a similar function to ABB's RAPID Offset and RelTool commands.
You can calculate a relative position with respect to the tool in XYZ coordinates (mm) and optionally rx,ry,rz in degrees:
Code: # Movement relative to the tool
new_pose = robot.Pose().RelTool(100,200,300,rz=0)
robot.MoveJ(new_pose)
# Movement relative to the reference frame:
new_pose = robot.Pose().Offset(100,200,300)
robot.MoveJ(new_pose)
#You can also concatenate both:
new_pose = pose.Offset(10,20,30).RelTool(0,0,100)
Posts: 16
Threads: 5
Joined: Mar 2019
Reputation:
0
|