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

[BUG] pose_jacobian_derivative() is not working properly #11

Closed juanjqo closed 5 years ago

juanjqo commented 5 years ago

Bug description

Code

from dqrobotics.robots import KukaLw4Robot
import numpy as np
from dqrobotics.robot_modeling import DQ_Kinematics
robot = KukaLw4Robot.kinematics()
q = np.array([0,0,0,0,0,0,0])
q_dot = np.array([0,0,0,0,0,0,0])

J = robot.pose_jacobian(q)
J_dot = robot.pose_jacobian_derivative(q, q_dot)

print("shapes")
print(J.shape)
print(J_dot.shape)

Output

Traceback (most recent call last):
  File "/home/juanjqo/catkin_ws/src/my_dynamixel_poppy/src/poppeye_rosPython/Pendulum_robot/test_pendulum.py", line 28, in <module>
    J_dot = robot.pose_jacobian_derivative(q, q_dot)
TypeError: pose_jacobian_derivative(): incompatible function arguments. The following argument types are supported:
    1. (self: dqrobotics.robot_modeling.DQ_SerialManipulator, arg0: numpy.ndarray[float64[m, 1]], arg1: numpy.ndarray[float64[m, 1]], arg2: int) -> numpy.ndarray[float64[m, n]]

Invoked with: <dqrobotics.robot_modeling.DQ_SerialManipulator object at 0x7fd56d40f570>, array([0, 0, 0, 0, 0, 0, 0]), array([0, 0, 0, 0, 0, 0, 0])

Process finished with exit code 1

Expected behavior

Expected output By using Matlab

 robot = KukaLwr4Robot.kinematics() % Btw, the name is different in Matlab. it is this expected?
 q = zeros(7,1);
 q_dot = [1 2 3 4 5 6 7]';
 J_dot = robot.pose_jacobian_derivative(q, q_dot)
J_dot =

   -4.0000   -1.0000   -4.0000    1.0000   -4.0000   -1.0000   -4.0000
    1.0000   -3.5000   -0.0000    2.0000    2.0000    0.5000   -1.0000
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
    0.5450    0.8400    0.7850    0.3200    1.1050    0.2750   -0.5450
   -2.2000    0.2350   -2.2000   -0.2350   -2.2000   -0.5450   -2.2000

Environment:

Additional context

from dqrobotics.robots import KukaLw4Robot
import numpy as np
from dqrobotics.robot_modeling import DQ_Kinematics
robot = KukaLw4Robot.kinematics()
q = np.array([0,0,0,0,0,0,0])
q_dot = np.array([1,2,3,4,5,6,7])

J = robot.pose_jacobian(q)
J_dot = robot.pose_jacobian_derivative(q, q_dot, 6)

print("shapes")
print(J.shape)
print(J_dot.shape)

Output:

shapes
(8, 7)
(8, 6)
mmmarinho commented 5 years ago

Hello, @juanjqo,

Thanks for the report.

That bugfix you mentioned was to make all the Python code zero-indexed as expected. Just some methods were one-indexed in prior development versions, but that was not intentional.

The signature jacobian_time_derivative(q, q_dot) doesn’t exist in Python yet and that’s where the error comes from. It has nothing to do with the indexing.

juanjqo commented 5 years ago

Hi @mmmarinho. Yes, it was what I thought. Thank you for your answer!

Cheers,

Juancho.

mmmarinho commented 5 years ago

@juanjqo

It should be working now.

About CPLEX, open a new issue and I can explain to you how to do it.

juanjqo commented 5 years ago

@mmmarinho thanks for the support!