dqrobotics / python

The DQ Robotics library in Python

Home Page:https://dqrobotics.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[QUESTION] Was the DQ_LinearAlgebra already included in the stable version?

marcos-pereira opened this issue · comments

Hello @mmmarinho,

I installed the DQ Robotics for python using python3 -m pip install --user dqrobotics and I also ran python3 -m pip install --user dqrobotics --upgrade. My current version is dqrobotics-19.10.0.53.

How can I add the DQ_LinearAlgebra properly? If I import it with

from dqrobotics.utils.DQ_LinearAlgebra import *

The library DQ_LinearAlgbera is not found and I get the following error when running the script with python3

Traceback (most recent call last):
  File "robot_controlling_node.py", line 3, in <module>
    from dqrobotics.utils.DQ_LinearAlgebra import *
ModuleNotFoundError: No module named 'dqrobotics.utils.DQ_LinearAlgebra'

The dqrobotics alone is found without errors.
Was the DQ_LinearAlgebra already included in the stable version?

My python3 version is 3.6.9 on Ubuntu 18.04.

Best regards,

Marcos

Hello, @marcos-pereira

The way you tried importing is somewhat different from how it should be done in the current version of the library.

To do what you want to do, you have to import the utils submodule.

import numpy
from dqrobotics.utils import *

print(DQ_LinearAlgebra.pinv(numpy.identity(2)))

The output will be

[[1. 0.]
 [0. 1.]]

Basically, the command

from X import *

on the current version will only work if X is a submodule (i.e. something similar to a folder in the cpp tree).

You can also add an alias for pinv

import numpy
from dqrobotics.utils import *
pinv = DQ_LinearAlgebra.pinv

print(pinv(numpy.identity(2)))

I don't particularly like the current way this is done so I'll work on making the imports better for the next version of dqrobotics. Meanwhile, you can use what I described above.

Thank you for the quick response @mmmarinho! Now it is working.

I would like just to point out that the python example vrep_interface_move_kuka.py is using the from dqrobotics.utils.DQ_LinearAlgebra import * command. I was using the example as a starting point.

Thanks, and happy holidays!

Hello, @marcos-pereira.

Nice to hear it's working. If there are any issues with the examples, please open a ticket so it's easier for us to keep track of what's odd. Using the issue tracker of dqrobotics/python is fine for this purpose.

Happy holidays.