RoboDK Forum
Function to get the pose of an object with respect to a given frame可打印版本

+- RoboDK Forum (//m.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//m.sinclairbody.com/forum/Forum-RoboDK-EN)
+--- Forum: Request new features (//m.sinclairbody.com/forum/Forum-Request-new-features)
+--- Thread: Function to get the pose of an object with respect to a given frame (/Thread-Function-to-get-the-pose-of-an-object-with-respect-to-a-given-frame)



Function to get the pose of an object with respect to a given frame-MNieland-03-10-2021

Hi,

it would be nice to have an API function to get the pose of an object with respect to a given reference frame. I don't do robot programming very often, but everytime I do, that function would have helped me. I have writen my own, but I think this function could easily provided by you and maybe help other users as well.

Or is there such a function and I just didn't see it?

Kind regards,
Martin


RE: Function to get the pose of an object with respect to a given frame-Vineet-03-10-2021

Hi Martin,
Thanks for writing in.
That's a nice suggestion. You can use the below function:


Code:
def CalculatePoseFrame2Object(frame, part):
"""Calculate the pose of any object with respect to any reference in RoboDK"""
# Get both poses with respect to the station reference (wrt-world coordinate system)
framePoseAbs = frame.PoseAbs()
partPoseAbs = part.PoseAbs()
# Calculate the pose of the object relative to the reference
pose = framePoseAbs.inv() * partPoseAbs
return pose
# Take the object
obj = RDK.Item('Sphere')
# Retrieve the reference
frame = RDK.Item('Frame 2')
# Calculate the relationship
pose = CalculatePoseFrame2Object(frame,obj)
# Display the result
print(pose)
RDK.ShowMessage("The relative pose is:\n" + str(pose))


Also, I have attached a station file where I use this function to calculate pose of a object with respect to another frame. I hope this helps you.

Let me know if you run into any other issues.

Cheers,
Vineet