Skip to content

Calculate IK based on the world frame #159

@joel0115

Description

@joel0115

Hi, thanks for your impressive works, sorry for my disturbing.
I used the following code to test the IK calculator.
However, when I plot the chain, I found that the chain's base is not located at the world's origin (0,0,0).
And I realized that IK is calculated based on the chain base's frame. But I want to calculate IK based on world frame.
So, is it possible to do one of the following or both?

  1. Locate my chain at the world's origin.
  2. Calculate IK based on the world's frame. i.e. [0.6042, 0.1777, 0.3502] means the coordinate w.r.t. world frame, instead of the chain base frame.

Thanks in advance!

my_chain = ikpy.chain.Chain.from_urdf_file(urdf_path)

target_position = [0.6042, 0.1777, 0.3502]
print("The angles of each joints are : ", my_chain.inverse_kinematics(target_position))

real_frame = my_chain.forward_kinematics(my_chain.inverse_kinematics(target_position))
print("Computed position vector : %s, original position vector : %s" % (real_frame[:3, 3], target_position))

fig, ax = plot_utils.init_3d_figure()
my_chain.plot(my_chain.inverse_kinematics(target_position), ax, target=target_position)
plt.xlim(-1 ,1)
plt.ylim(-1, 1)
plt.savefig("IK.png")

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions