Search code examples
pythontransformationroboticsdrakepose-estimation

How to get the transformation between two body frames in PyDrake


I have two frames at different joint locations of IIWA arm, using f1 = plant.GetFrameByName("iiwa_link_0", kuka_model) f2 = plant.GetFrameByName("iiwa_link_2", kuka_model)

I want to find the transformation between these two body frames(f1, f2).

Getting error when using f1.CalcPoseInBodyFrame() :

TypeError: CalcPoseInBodyFrame(): incompatible function arguments. The following argument types are supported: 1. (self: pydrake.multibody.tree.Frame_[float], context: pydrake.systems.framework.Context_[float]) -> pydrake.math.RigidTransform_[float]

What is the correct way to approach this problem?

Thanks, Sarvesh


Solution

  • It would be helpful if you post the actual code giving you the error.

    Worst case, you can do this:

    context = ... # assuming you have a context where things are posed.
    
    f1 = plant.GetFrameByName("iiwa_link_0", kuka_model)
    f2 = plant.GetFrameByName("iiwa_link_2", kuka_model)
    X_F2F1 = f1.CalcPose(context, f2)