dqrobotics / python

The DQ Robotics library in Python
https://dqrobotics.github.io
GNU Lesser General Public License v3.0
26 stars 9 forks source link

The pose_jacobian method of DQ_holonomicBase class returns a wrong Jacobian [BUG] #19

Closed juanjqo closed 3 years ago

juanjqo commented 4 years ago

Bug description

Code

import numpy as np
from dqrobotics.robot_modeling import DQ_HolonomicBase

q = np.array([0.0003,   -0.0003,    0.0158])
holonomic_base = DQ_HolonomicBase()
J = holonomic_base.pose_jacobian(q, 2)
print(J)

Output

[[ 0.00000000e+00  0.00000000e+00 -3.94995891e-03]
 [ 0.00000000e+00  0.00000000e+00  0.00000000e+00]
 [ 0.00000000e+00  0.00000000e+00  0.00000000e+00]
 [ 0.00000000e+00  0.00000000e+00  4.99984398e-01]
 [ 0.00000000e+00  0.00000000e+00  0.00000000e+00]
 [ 4.99984398e-01  3.94995891e-03 -7.55901535e-05]
 [-3.94995891e-03  4.99984398e-01  7.55901535e-05]
 [ 0.00000000e+00  0.00000000e+00  0.00000000e+00]]

Process finished with exit code 0

Expected behavior

Expected output

import numpy as np
from math import sin, cos

def my_holonomic_jacobian(q):

    x = q[0]
    y = q[1]
    phi = q[2]

    s = sin(phi / 2)
    c = cos(phi / 2)
    j71 = -0.5 * s
    j62 = -j71
    j13 = -j62
    j72 = 0.5 * c
    j61 = j72
    j43 = j61

    j63 = 0.25 * (-x * s + y * c)
    j73 = 0.25 * (-x * c - y * s)
    J = np.array([[0, 0, j13],
                  [0, 0, 0],
                  [0, 0, 0],
                  [0, 0, j43],
                  [0, 0, 0],
                  [j61, j62, j63],
                  [j71, j72, j73],
                  [0, 0, 0]])
    return J

q = np.array([0.0003,   -0.0003,    0.0158])
J = my_holonomic_jacobian(q)
print(J)
[[ 0.00000000e+00  0.00000000e+00 -3.94995891e-03]
 [ 0.00000000e+00  0.00000000e+00  0.00000000e+00]
 [ 0.00000000e+00  0.00000000e+00  0.00000000e+00]
 [ 0.00000000e+00  0.00000000e+00  4.99984398e-01]
 [ 0.00000000e+00  0.00000000e+00  0.00000000e+00]
 [ 4.99984398e-01  3.94995891e-03 -7.55901535e-05]
 [-3.94995891e-03  4.99984398e-01 -7.44051658e-05]
 [ 0.00000000e+00  0.00000000e+00  0.00000000e+00]]

Process finished with exit code 0

Environment:

Cheers!

Juancho.

bvadorno commented 4 years ago

Hi, @mmmarinho,

Since I already fixed it on Matlab, I can take this one, too.

Cheers, Bruno