Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ik calculation time varies widely #10

Open
robin-gdwl opened this issue Aug 23, 2024 · 2 comments
Open

Ik calculation time varies widely #10

robin-gdwl opened this issue Aug 23, 2024 · 2 comments

Comments

@robin-gdwl
Copy link

Thank you very much for this repo. It helped me a lot in setting up ikfast for my usecase.

I have ran into an issue and would be interested to know wether its normal behaviour or an issue on my end:

The execution time for ik calculations varies widely.
Sometimes it executes in 0.005 seconds sometimes it only takes 0.00003 seconds which is more than 100x faster.
I am always solving the same pose, calculating all solutions without a q_guess pose.

Calculating 100_000 IK solutions usually takes around 10 seconds but sometimes it takes up to 50 seconds.
I was wondering where this discrepancy might come from and if there is anything I can do on my end that can speed up the calculation. Is this a normal range for the execution time?

I am using an M1Pro Macbook.

Thank you very much for any hints.

@cambel
Copy link
Owner

cambel commented Aug 30, 2024

@robin-gdwl
Hi!,
could you share the scripts you are using for the measurements?

@robin-gdwl
Copy link
Author

robin-gdwl commented Aug 30, 2024

Here is my test file

import ur_ikfast
import time
import numpy as np

ur5e_arm = ur_ikfast.URKinematics('ur5e')

joint_angles = [-3.1, -1.6, 1.6, -1.6, -1.6, 0.]  # in radians
print("joint angles", joint_angles)

pose_matrix = ur5e_arm.forward(joint_angles, 'matrix')

print("--"*20)
p = time.perf_counter()
ur5e_arm.inverse(pose_matrix, True)
#print("inverse() one from matrix", ur3e_arm.inverse(pose_matrix, True))
print("timer first time: ", time.perf_counter()-p)
print("---")

p = time.perf_counter()
ur5e_arm.inverse(pose_matrix, True)
#print("inverse() one from matrix", ur3e_arm.inverse(pose_matrix, True))
print("timer sec time: ", time.perf_counter()-p)
print("---")

p = time.perf_counter()
ur5e_arm.inverse(pose_matrix, True)
#print("inverse() one from matrix", ur3e_arm.inverse(pose_matrix, True))
print("timer third time: ", time.perf_counter()-p)
print("---")

#Loop
repetitions = 100_000
p = time.perf_counter()
timesum = 0
for i in range(repetitions):
    pi = time.perf_counter()
    sols = ur5e_arm.inverse(pose_matrix, True)
    timesum += time.perf_counter()-pi
#print("inverse() one from matrix", ur3e_arm.inverse(pose_matrix, True))
print("timer loop: ", time.perf_counter()-p)
print("average = ", timesum/repetitions)
#print(sols)
print("---")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants