rojas70 / rvc_python_notebooks

4 stars 2 forks source link

When use ikine_a function to solve the analytic inverse kinemtic for sequence solutions, the function only return the success IKsolutions. #1

Open robot-chenwei opened 3 years ago

robot-chenwei commented 3 years ago

When I use ikine_a function to solve the analytic inverse kinemtic for sequence solutions, the function only return the success IKsolutions, which is less than expected. It expected that there are five IKsolutions and the last twos are returned as failed IKsolutions , but there are only three success IKsolutions.

Python code:

T = SE3(0.5, 0.1, 0.1)*SE3().RPY([0, 0, 0], unit='deg')
TF = SE3(0.5, 0.1, -0.1)*SE3().RPY([0, 0, 0], unit='deg')
des_T = ctraj(T, TF, 5)
des_q = puma.ikine_a(des_T, config='ruw')

# Here only gets three success IKsolutions
print('des_q:', des_q)

q = np.array([des_q[i].q for i in range(0, len(des_q))])
puma.plot(q)

The information return from the jupyter-notebook are shown below: image

mfkenson commented 3 years ago

I just noticed the config 'ruw' seems invalud.

Anyway you could look into des_T and see which two causing the issue.

SE3:[0] =
       1           0           0           0.5          
       0           1           0           0.1          
       0           0           1           0.1          
       0           0           0           1            
    [1] =
       1           0           0           0.5          
       0           1           0           0.1          
       0           0           1           0.071875     
       0           0           0           1            
    [2] =
       1           0           0           0.5          
       0           1           0           0.1          
       0           0           1           0            
       0           0           0           1            
    [3] =
       1           0           0           0.5          
       0           1           0           0.1          
       0           0           1          -0.071875     
       0           0           0           1            
    [4] =   1           0           0           0.5          
       0           1           0           0.1          
       0           0           1          -0.1          
       0           0           0           1           

It should be des_T[3] and des_T[4]. Then you may try to look into the ikine_a des_T[3] and des_T[4] with one by one. I tried and the function call throw an exception error below.

TypeError                                 Traceback (most recent call last)
<ipython-input-15-656b8a5f7ba0> in <module>
----> 1 puma.ikine_a(des_T[3])

~/Desktop/maeg5755/robotics-toolbox-python/roboticstoolbox/models/DH/Puma560.py in ikine_a(self, T, config)
    302             return theta
    303 
--> 304         return self.ikine_6s(T, config, ik3)
    305 
    306 

~/Desktop/maeg5755/robotics-toolbox-python/roboticstoolbox/robot/DHRobot.py in ikine_6s(self, T, config, ikfunc)
   1609         for k, Tk in enumerate(T):
   1610             # get model specific solution for first 3 joints
-> 1611             theta = ikfunc(self, Tk, config)
   1612 
   1613             if theta is None or np.any(np.isnan(theta)):

~/Desktop/maeg5755/robotics-toolbox-python/roboticstoolbox/models/DH/Puma560.py in ik3(robot, T, config)
    298                 theta[2] = np.arctan2(a3, d4) - np.arctan2(num, den)
    299 
--> 300             theta = base.angdiff(theta)
    301 
    302             return theta

~/Desktop/maeg5755/spatialmath-python/spatialmath/base/vectors.py in angdiff(a, b)
    526     """
    527     if b is None:
--> 528         return np.mod(a + math.pi, 2 * math.pi) - math.pi
    529     else:
    530         return np.mod(a - b + math.pi, 2 * math.pi) - math.pi

TypeError: unsupported operand type(s) for +: 'NoneType' and 'float'

In this case the robotics-toolbox did not handle the exception properly. You may submit a issue reporting relevant error to the git repo here: https://github.com/petercorke/robotics-toolbox-python.