Phylliade / ikpy

IKPy, an Universal Inverse Kinematics library
http://phylliade.github.io/ikpy
Apache License 2.0
733 stars 153 forks source link

Issue to reach position AND orientation (3axes) target #138

Open Benjamin797 opened 1 year ago

Benjamin797 commented 1 year ago

Hello,

I have been exploring your algorithm for more than a month and my goal is to solve the inverse kinematic for articulated arms that I create directly in python with your functions. My project requires me to solve the problem in position AND orientation on the 3 axes (orientation_mode = 'all'). However, despite several attempts, the optimization gives me results where the position is reached but not the orientation. Does IkPy work well for an orientation_mode = 'all' resolution? If yes, can you help me to solve this problem? I really need it. Here is my piece of code allowing the resolution of the ik. It is done in two steps (as indicated in your example) but it does not manage to reach the position + orientation (3 axes) even though I know that it is possible to reach it (which I managed to prove previously in my project).

Thanks in advance.

` res = chain.inverse_kinematics(target.coordToList()) res = chain.inverse_kinematics(target_position=target.coordToList(), target_orientation=targ_ori, orientation_mode= 'all', initial_position = res)

position = chain.forward_kinematics(res)[:3, 3] orientation = chain.forward_kinematics(res)[:3, :3]

np.testing.assert_almost_equal(orientation, targ_ori, decimal=5) np.testing.assert_almost_equal(position, target.coordToList(), decimal=3) `

Benjamin797 commented 1 year ago

One solution I found is the randomly change the inital position for each joint and iterate the resolution until the position and orientation is reached (with a cost fonction that compare the real position/orientation computed with the exepected one). Althought this method takes a really long time (1 minute sometimes) to reach the target wanted. Normally, if Ikpy workd for orientation_mode = all, i shoudln't iterate like that, one execution of the inverse_kinematic function should be enough. Is this orientation_mode really works? Thank you

niklasconbotics commented 1 year ago

Hi Benjamin, I have the same problem! can you provide the code? Or did you found a more convinced solution?