3 from trac_ik_python.trac_ik_wrap
import TRAC_IK
5 from numpy.random
import random
9 if __name__ ==
'__main__':
12 urdf = rospy.get_param(
'/robot_description')
22 print(
"Number of joints:")
23 print(ik_solver.getNrOfJointsInChain())
25 print(ik_solver.getJointNamesInChain(urdf))
27 print(ik_solver.getLinkNamesInChain())
39 for _
in range(NUM_COORDS):
41 y = random() * 0.6 + -0.3
42 z = random() * 0.7 + -0.35
43 rand_coords.append((x, y, z))
47 num_solutions_found = 0
48 for x, y, z
in rand_coords:
50 sol = ik_solver.CartToJnt(qinit,
56 call_time = fin_t - ini_t
62 num_solutions_found += 1
63 avg_time = avg_time / NUM_COORDS
66 print(
"Found " + str(num_solutions_found) +
" of 200 random coords")
67 print(
"Average IK call time: " + str(avg_time))
72 num_solutions_found = 0
73 brx = bry = brz = 9999.0
74 for x, y, z
in rand_coords:
76 sol = ik_solver.CartToJnt(qinit,
82 call_time = fin_t - ini_t
88 num_solutions_found += 1
90 avg_time = avg_time / NUM_COORDS
92 print(
"Found " + str(num_solutions_found) +
" of 200 random coords ignoring orientation")
93 print(
"Average IK call time: " + str(avg_time))
98 num_solutions_found = 0
100 brx = bry = brz = 9999.0
101 for x, y, z
in rand_coords:
103 sol = ik_solver.CartToJnt(qinit,
109 call_time = fin_t - ini_t
111 avg_time += call_time
115 num_solutions_found += 1
117 avg_time = avg_time / NUM_COORDS
120 print(
"Found " + str(num_solutions_found) +
" of 200 random coords ignoring everything")
121 print(
"Average IK call time: " + str(avg_time))