Description
Describe the missing/unexpected functionality
For DQ_SerialManipulatorDH objects, I'm getting different behaviors in MATLAB and Python when trying to obtain the poses of intermediate frames. The minimum example below uses the 2-DOF planar robot shown in the figure, but I've also tried with robots available in the library, such as the KukaLw4Robot.
The Matlab behavior is what I would expect to be the correct output, since with it is possible to obtain the pose of the first and last frames when they are different from the reference and the end effector, respectively.
This is the robot of the example:
Matlab behavior
MATLAB SCRIPT
classdef Planar2DOF
methods (Static)
function ret = kinematics()
DH_theta = [0, 0];
DH_d = [0, 0];
DH_a = [1, 1];
DH_alpha = [0, 0];
DH_type = repmat(DQ_SerialManipulatorDH.JOINT_ROTATIONAL,1,2);
DH_matrix = [DH_theta; DH_d; DH_a; DH_alpha; DH_type];
obj = DQ_SerialManipulatorDH(DH_matrix,'standard');
x = 1 + DQ.E * (1/2) * DQ([0, 1, 0]);
obj.set_base_frame(x);
obj.set_reference_frame(x);
x = 1 + DQ.E * (1/2) * DQ([1, 0, 0]);
obj.set_effector(x)
ret = obj;
end
end
end
robot = Planar2DOF.kinematics();
q = [0;0];
F_ee = robot.fkm(q).translation()
F_1 = robot.fkm(q,0).translation()
F_2 = robot.fkm(q,1).translation()
F_3 = robot.fkm(q,2).translation()
MATLAB OUTPUT
F_ee =
3i + 1j
F_1 =
1j
F_2 =
1i + 1j
F_3 =
2i + 1j
Python behavior
PYTHON SCRIPT
from dqrobotics import *
from dqrobotics.robot_modeling import DQ_SerialManipulatorDH
class Planar2DOF:
def kinematics(self) -> DQ_SerialManipulatorDH:
DH_theta = [0, 0]
DH_d = [0, 0]
DH_a = [1, 1]
DH_alpha = [0, 0]
DH_type = [0, 0]
DH_matrix = [DH_theta, DH_d, DH_a, DH_alpha, DH_type]
obj = DQ_SerialManipulatorDH(DH_matrix)
x = 1 + DQ.E * (1 / 2) * DQ([0, 1, 0])
obj.set_base_frame(x)
obj.set_reference_frame(x)
x = 1 + DQ.E * (1 / 2) * DQ([1, 0, 0])
obj.set_effector(x)
return obj
robot = Planar2DOF().kinematics()
q = [0, 0]
print("F_ee: ", robot.fkm(q).translation())
print("F_1: ", robot.fkm(q, 0).translation())
print("F_2: ", robot.fkm(q, 1).translation())
print("F_3: ", robot.fkm(q, 2).translation())
PYTHON OUTPUT
F_ee: 3i + 1j
F_1: 1i + 1j
F_2: 3i + 1j
Traceback (most recent call last):
File "...", line 31, in <module>
print("F_3: ", robot.fkm(q, 2).translation())
RuntimeError: Tried to access link index 2 which is unnavailable.
Environment:
- OS: macOS Sonoma 14.5
- dqrobotics python version 23.4.0a22
- dqrobotics matlab version 20.04.0.1
- MATLAB version R2023b
- Python version 3.9.6
Additional context
I have also tried in a machine running Ubuntu 22.04 LTS, with the dqrobotics for Python versions 20.04 and 23.4.0a22, and obtained the same results.