Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Offset Instruction

#1
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)
#2
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
#3
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.
#4
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)
#5
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?
#6
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.
#7
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)
#8
Great, Thank you!
  




Users browsing this thread:
1 Guest(s)