lanius / tinyik

A tiny inverse kinematics solver
MIT License
120 stars 21 forks source link

wrong visualization #23

Open calx-git opened 2 years ago

calx-git commented 2 years ago

Thanks for this great tool.

However, when I try to visualize my chain, it does not work well. Would you please help me find the reason? My code is shown below:

import tinyik
import numpy as np

left_arm_idx = [15, 16, 17]
left_arm_bone1 = source_joints[ left_arm_idx[1],: ] - source_joints[ left_arm_idx[0],: ]
left_arm_bone2 = source_joints[ left_arm_idx[2],: ] - source_joints[ left_arm_idx[1],: ]

leftarm = tinyik.Actuator(['x','y','z', left_arm_bone1, 'x','y','z', left_arm_bone2])
tinyik.visualize(leftarm)

The values of the two bones are:

left_arm_bone1 = [-0.77607921, 2.00528251, -3.82166443]
left_arm_bone2 = [-4.19961586, -0.31558648, 0.79598167]

The visualization is not as expected. The direction of the bone is wrong.

Visualization of two bones

lanius commented 2 years ago

Thank you very much for trying it.

I was able to reproduce the problem you pointed out in my environment. Perhaps there is a bug in the visualization algorithm imported in PR #19. I tried it with version 2.2.0 and it rendered correctly.

pip install tinyik==2.2.0
import tinyik
import numpy as np

left_arm_bone1 = [-0.77607921, 2.00528251, -3.82166443]
left_arm_bone2 = [-4.19961586, -0.31558648, 0.79598167]

leftarm = tinyik.Actuator(['x','y','z', left_arm_bone1, 'x','y','z', left_arm_bone2])
tinyik.visualize(leftarm)

image

I will now try to figure out how to fix it. If you need it right away, try using the previous version.

calx-git commented 2 years ago

Thanks for the quick reply. I have tried the previous version, and it works. Thanks!