kjyv / FloBaRoID

Framework for dynamical system identification of floating-base rigid body tree structures
GNU Lesser General Public License v3.0
61 stars 26 forks source link

ImportError: cannot import name transform (fcl) #12

Closed geekayman closed 4 years ago

geekayman commented 4 years ago

Hi, I'm trying to identify the dynamic parameters of the ABB irb 6640 robot for my research internship with Flobaroid. when I execute the trajectory.py script to generate an optimal exciting trajectory, an import error block the execution of the script.

from fcl import fcl, collision_data, transform
ImportError: cannot import name transform

I've searched in the library fcl but I can't find the transform module. I'm using :

geekayman@geekayman-Lenovo-ideapad-330-15ICH:~/robot_iden/FloBaRoID$ ./trajectory.py --config configs/kuka_lwr4.yaml --model model/kuka_lwr4.urdf --world model/world_kuka.urdf
Error: IPOPT shared library failed to import
./trajectory.py:30: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  config = yaml.load(stream)
loaded model model/kuka_lwr4.urdf
# DOFs: 7
Joints: ['lwr_0_joint', 'lwr_1_joint', 'lwr_2_joint', 'lwr_3_joint', 'lwr_4_joint', 'lwr_5_joint', 'lwr_6_joint']
# regressor outputs: 7
# links: 8 (+ 0 fake)
{0: 'lwr_base_link', 1: 'lwr_1_link', 2: 'lwr_2_link', 3: 'lwr_3_link', 4: 'lwr_4_link', 5: 'lwr_5_link', 6: 'lwr_6_link', 7: 'lwr_7_link'}
# params: 80 (94 will be identified)
loaded random structural regressor from model/kuka_lwr4.urdf.regressor.npz
loaded model model/kuka_lwr4.urdf
# DOFs: 7
Joints: ['lwr_0_joint', 'lwr_1_joint', 'lwr_2_joint', 'lwr_3_joint', 'lwr_4_joint', 'lwr_5_joint', 'lwr_6_joint']
# regressor outputs: 7
# links: 8 (+ 0 fake)
{0: 'lwr_base_link', 1: 'lwr_1_link', 2: 'lwr_2_link', 3: 'lwr_3_link', 4: 'lwr_4_link', 5: 'lwr_5_link', 6: 'lwr_6_link', 7: 'lwr_7_link'}
# params: 80 (94 will be identified)
loaded random structural regressor from model/kuka_lwr4.urdf.regressor.npz
World links: ['ground_link']
Running global optimization with ALPSO
call #1/612
wf 0.5
a [[0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3]]
b [[0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3]]
q [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
Traceback (most recent call last):
  File "./trajectory.py", line 91, in <module>
    main()
  File "./trajectory.py", line 68, in main
    trajectory = trajectoryOptimizer.optimizeTrajectory()
  File "/home/geekayman/robot_iden/FloBaRoID/excitation/trajectoryOptimizer.py", line 390, in optimizeTrajectory
    sol_vec = self.runOptimizer(opt_prob)
  File "/home/geekayman/robot_iden/FloBaRoID/excitation/optimizer.py", line 504, in runOptimizer
    opt(opt_prob, store_hst=False) #, xstart=initial)
  File "/usr/local/lib/python2.7/dist-packages/pyOpt/pyOpt_optimizer.py", line 146, in __call__
    return self.__solve__(opt_problem, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pyOpt/pyALPSO/pyALPSO.py", line 442, in __solve__
    hos_file, seed, scale, nhs, objconfunc)
  File "/usr/local/lib/python2.7/dist-packages/pyOpt/pyALPSO/alpso.py", line 253, in alpso
    [f[i], g[i, :]] = objfunc(xtmp)
  File "/usr/local/lib/python2.7/dist-packages/pyOpt/pyALPSO/pyALPSO.py", line 293, in objconfunc
    [ff, gg, fail] = opt_problem.obj_fun(xn, *args, **kwargs)
  File "/home/geekayman/robot_iden/FloBaRoID/excitation/trajectoryOptimizer.py", line 256, in objectiveFunc
    d = self.getLinkDistance(l0_name, l1_name, q)
  File "/home/geekayman/robot_iden/FloBaRoID/excitation/optimizer.py", line 245, in getLinkDistance
    from fcl import fcl, collision_data, transform
ImportError: cannot import name transform
kjyv commented 4 years ago

Did you install fcl and bindings as written in the readme?

fcl 0.5.0 and python-fcl (from https://github.com/jf---/python-fcl) (possibly disable octomap if there are errors)

geekayman commented 4 years ago

Hi, thank you for your response. I followed all the steps in the readme, but I wasn't able to import directly transform module from fcl. So I put the transform module directly into the exitation file and imported it.

from fcl import fcl, collision_data
import transform

After executing the code to find the optimal trajectory. I ended up with a segmentation error.

geekayman@geekayman-Lenovo-ideapad-330-15ICH:~/FloBaRoID$ sudo python trajectory.py --config configs/kuka_lwr4.yaml --model model/kuka_lwr4.urdf --world model/world_kuka.urdf
Error: IPOPT shared library failed to import
trajectory.py:30: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  config = yaml.load(stream)
loaded model model/kuka_lwr4.urdf
# DOFs: 7
Joints: ['lwr_0_joint', 'lwr_1_joint', 'lwr_2_joint', 'lwr_3_joint', 'lwr_4_joint', 'lwr_5_joint', 'lwr_6_joint']
# regressor outputs: 7
# links: 8 (+ 0 fake)
{0: 'lwr_base_link', 1: 'lwr_1_link', 2: 'lwr_2_link', 3: 'lwr_3_link', 4: 'lwr_4_link', 5: 'lwr_5_link', 6: 'lwr_6_link', 7: 'lwr_7_link'}
# params: 80 (94 will be identified)
loaded random structural regressor from model/kuka_lwr4.urdf.regressor.npz
loaded model model/kuka_lwr4.urdf
# DOFs: 7
Joints: ['lwr_0_joint', 'lwr_1_joint', 'lwr_2_joint', 'lwr_3_joint', 'lwr_4_joint', 'lwr_5_joint', 'lwr_6_joint']
# regressor outputs: 7
# links: 8 (+ 0 fake)
{0: 'lwr_base_link', 1: 'lwr_1_link', 2: 'lwr_2_link', 3: 'lwr_3_link', 4: 'lwr_4_link', 5: 'lwr_5_link', 6: 'lwr_6_link', 7: 'lwr_7_link'}
# params: 80 (94 will be identified)
loaded random structural regressor from model/kuka_lwr4.urdf.regressor.npz
World links: ['ground_link']
Running global optimization with NSGA2
call #1/120
wf 0.5
a [[0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3]]
b [[0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3], [0.3, 0.3, 0.3, 0.3]]
q [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[geekayman-Lenovo-ideapad-330-15ICH:06055] *** Process received signal ***
[geekayman-Lenovo-ideapad-330-15ICH:06055] Signal: Segmentation fault (11)
[geekayman-Lenovo-ideapad-330-15ICH:06055] Signal code: Address not mapped (1)
[geekayman-Lenovo-ideapad-330-15ICH:06055] Failing at address: (nil)
[geekayman-Lenovo-ideapad-330-15ICH:06055] [ 0] /lib/x86_64-linux-gnu/libc.so.6(+0x3ef20)[0x7f91f23ecf20]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [ 1] /home/geekayman/.local/lib/python2.7/site-packages/fcl/fcl.so(+0x13906)[0x7f91843ac906]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [ 2] /home/geekayman/.local/lib/python2.7/site-packages/fcl/fcl.so(+0x33358)[0x7f91843cc358]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [ 3] python(+0xe2fd5)[0x55994a366fd5]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [ 4] python(PyEval_EvalFrameEx+0x54b0)[0x55994a37db20]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [ 5] python(PyEval_EvalCodeEx+0x58a)[0x55994a3762aa]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [ 6] python(PyEval_EvalFrameEx+0x5d2e)[0x55994a37e39e]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [ 7] python(PyEval_EvalCodeEx+0x58a)[0x55994a3762aa]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [ 8] python(+0x10e1cc)[0x55994a3921cc]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [ 9] python(PyObject_Call+0x3e)[0x55994a361e6e]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [10] python(PyEval_EvalFrameEx+0x2a22)[0x55994a37b092]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [11] python(PyEval_EvalCodeEx+0x58a)[0x55994a3762aa]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [12] python(+0x10df29)[0x55994a391f29]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [13] python(PyObject_Call+0x3e)[0x55994a361e6e]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [14] python(PyEval_CallObjectWithKeywords+0x30)[0x55994a382140]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [15] /usr/local/lib/python2.7/dist-packages/pyOpt/pyNSGA2/nsga2.so(nsga2func+0x257)[0x7f919e1c025c]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [16] /usr/local/lib/python2.7/dist-packages/pyOpt/pyNSGA2/nsga2.so(evaluate_ind+0x5b)[0x7f919e1d2c4f]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [17] /usr/local/lib/python2.7/dist-packages/pyOpt/pyNSGA2/nsga2.so(evaluate_pop+0x73)[0x7f919e1d2bde]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [18] /usr/local/lib/python2.7/dist-packages/pyOpt/pyNSGA2/nsga2.so(nsga2+0xcc5)[0x7f919e1d4bbf]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [19] /usr/local/lib/python2.7/dist-packages/pyOpt/pyNSGA2/nsga2.so(+0x10ec8)[0x7f919e1c7ec8]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [20] python(PyEval_EvalFrameEx+0x54a)[0x55994a378bba]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [21] python(PyEval_EvalCodeEx+0x58a)[0x55994a3762aa]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [22] python(+0x10e1cc)[0x55994a3921cc]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [23] python(PyObject_Call+0x3e)[0x55994a361e6e]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [24] python(PyEval_EvalFrameEx+0x2a22)[0x55994a37b092]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [25] python(PyEval_EvalCodeEx+0x58a)[0x55994a3762aa]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [26] python(+0x10e1cc)[0x55994a3921cc]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [27] python(+0x12670e)[0x55994a3aa70e]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [28] python(PyObject_Call+0x3e)[0x55994a361e6e]
[geekayman-Lenovo-ideapad-330-15ICH:06055] [29] python(+0x183be3)[0x55994a407be3]
[geekayman-Lenovo-ideapad-330-15ICH:06055] *** End of error message ***
Erreur de segmentation

I tried to find the source of the error and I found that the problem came from pyOpt. Because when I run the test "tp037.py"provided by pyopt I end up with the same error.

usr/local/lib/python2.7/site-packages/pyOpt/examples$ sudo python2 tp037.py 
[sudo] Mot de passe de geekayman : 
Error: IPOPT shared library failed to import

Optimization Problem -- TP37 Constrained Problem
================================================================================

        Objective Function: objfunc

    Objectives:
        Name        Value        Optimum
         f               0             0

    Variables (c - continuous, i - integer, d - discrete):
        Name    Type       Value       Lower Bound  Upper Bound
         x1       c      10.000000       0.00e+00     4.20e+01 
         x2       c      10.000000       0.00e+00     4.20e+01 
         x3       c      10.000000       0.00e+00     4.20e+01 

    Constraints (i - inequality, e - equality):
        Name    Type                    Bounds
         g1       i       -1.00e+21 <= 0.000000 <= 0.00e+00
         g2       i       -1.00e+21 <= 0.000000 <= 0.00e+00

PSQP Solution to TP37 Constrained Problem
================================================================================

        Objective Function: objfunc

    Solution: 
--------------------------------------------------------------------------------
    Total Time:                    0.0173
    Total Function Evaluations:        42
    Sensitivities:        FD

    Objectives:
        Name        Value        Optimum
         f           -3456             0

    Variables (c - continuous, i - integer, d - discrete):
        Name    Type       Value       Lower Bound  Upper Bound
         x1       c      24.000000       0.00e+00     4.20e+01 
         x2       c      12.000000       0.00e+00     4.20e+01 
         x3       c      12.000000       0.00e+00     4.20e+01 

    Constraints (i - inequality, e - equality):
        Name    Type                    Bounds
         g1       i       -1.00e+21 <= 0.000000 <= 0.00e+00
         g2       i       -1.00e+21 <= -72.000000 <= 0.00e+00

--------------------------------------------------------------------------------

SLSQP Solution to TP37 Constrained Problem
================================================================================

        Objective Function: objfunc

    Solution: 
--------------------------------------------------------------------------------
    Total Time:                    0.0006
    Total Function Evaluations:          
    Sensitivities:        FD

    Objectives:
        Name        Value        Optimum
         f           -3456             0

    Variables (c - continuous, i - integer, d - discrete):
        Name    Type       Value       Lower Bound  Upper Bound
         x1       c      24.000000       0.00e+00     4.20e+01 
         x2       c      12.000000       0.00e+00     4.20e+01 
         x3       c      12.000000       0.00e+00     4.20e+01 

    Constraints (i - inequality, e - equality):
        Name    Type                    Bounds
         g1       i       -1.00e+21 <= 0.000000 <= 0.00e+00
         g2       i       -1.00e+21 <= -72.000000 <= 0.00e+00

--------------------------------------------------------------------------------

CONMIN Solution to TP37 Constrained Problem
================================================================================

        Objective Function: objfunc

    Solution: 
--------------------------------------------------------------------------------
    Total Time:                    0.0112
    Total Function Evaluations:        88
    Sensitivities:        CS

    Objectives:
        Name        Value        Optimum
         f           -3456             0

    Variables (c - continuous, i - integer, d - discrete):
        Name    Type       Value       Lower Bound  Upper Bound
         x1       c      23.989921       0.00e+00     4.20e+01 
         x2       c      12.002518       0.00e+00     4.20e+01 
         x3       c      12.002518       0.00e+00     4.20e+01 

    Constraints (i - inequality, e - equality):
        Name    Type                    Bounds
         g1       i       -1.00e+21 <= -0.000006 <= 0.00e+00
         g2       i       -1.00e+21 <= -71.999994 <= 0.00e+00

--------------------------------------------------------------------------------

COBYLA Solution to TP37 Constrained Problem
================================================================================

        Objective Function: objfunc

    Solution: 
--------------------------------------------------------------------------------
    Total Time:                    0.0141
    Total Function Evaluations:       112

    Objectives:
        Name        Value        Optimum
         f           -3456             0

    Variables (c - continuous, i - integer, d - discrete):
        Name    Type       Value       Lower Bound  Upper Bound
         x1       c      24.000000       0.00e+00     4.20e+01 
         x2       c      11.999999       0.00e+00     4.20e+01 
         x3       c      12.000000       0.00e+00     4.20e+01 

    Constraints (i - inequality, e - equality):
        Name    Type                    Bounds
         g1       i       -1.00e+21 <= 0.000000 <= 0.00e+00
         g2       i       -1.00e+21 <= -72.000000 <= 0.00e+00

--------------------------------------------------------------------------------

SOLVOPT Solution to TP37 Constrained Problem
================================================================================

        Objective Function: objfunc

    Solution: 
--------------------------------------------------------------------------------
    Total Time:                    0.0239
    Total Function Evaluations:       201
    Sensitivities:        FD

    Objectives:
        Name        Value        Optimum
         f           -3456             0

    Variables (c - continuous, i - integer, d - discrete):
        Name    Type       Value       Lower Bound  Upper Bound
         x1       c      23.999011       0.00e+00     4.20e+01 
         x2       c      12.000860       0.00e+00     4.20e+01 
         x3       c      11.999634       0.00e+00     4.20e+01 

    Constraints (i - inequality, e - equality):
        Name    Type                    Bounds
         g1       i       -1.00e+21 <= -0.000000 <= 0.00e+00
         g2       i       -1.00e+21 <= -72.000000 <= 0.00e+00

--------------------------------------------------------------------------------

KSOPT Solution to TP37 Constrained Problem
================================================================================

        Objective Function: objfunc

    Solution: 
--------------------------------------------------------------------------------
    Total Time:                    0.0302
    Total Function Evaluations:      2210
    Sensitivities:        FD

    Objectives:
        Name        Value        Optimum
         f        -3453.76             0

    Variables (c - continuous, i - integer, d - discrete):
        Name    Type       Value       Lower Bound  Upper Bound
         x1       c      23.994597       0.00e+00     4.20e+01 
         x2       c      11.997383       0.00e+00     4.20e+01 
         x3       c      11.997531       0.00e+00     4.20e+01 

    Constraints (i - inequality, e - equality):
        Name    Type                    Bounds
         g1       i       -1.00e+21 <= -0.015575 <= 0.00e+00
         g2       i       -1.00e+21 <= -71.984425 <= 0.00e+00

--------------------------------------------------------------------------------

NSGA-II Solution to TP37 Constrained Problem
================================================================================

        Objective Function: objfunc

    Solution: 
--------------------------------------------------------------------------------
    Total Time:                    0.1167
    Total Function Evaluations:          

    Objectives:
        Name        Value        Optimum
         f        -3450.18             0

    Variables (c - continuous, i - integer, d - discrete):
        Name    Type       Value       Lower Bound  Upper Bound
         x1       c      24.523723       0.00e+00     4.20e+01 
         x2       c      11.437983       0.00e+00     4.20e+01 
         x3       c      12.300033       0.00e+00     4.20e+01 

    Constraints (i - inequality, e - equality):
        Name    Type                    Bounds
         g1       i       -1.00e+21 <= -0.000245 <= 0.00e+00
         g2       i       -1.00e+21 <= -71.999755 <= 0.00e+00

--------------------------------------------------------------------------------

ALGENCAN Solution to TP37 Constrained Problem
================================================================================

        Objective Function: objfunc

    Solution: 
--------------------------------------------------------------------------------
    Total Time:                    0.0291
    Total Function Evaluations:          
    Lambda: [144.00000063   0.        ]
    Sensitivities:        FD

    Objectives:
        Name        Value        Optimum
         f           -3456             0

    Variables (c - continuous, i - integer, d - discrete):
        Name    Type       Value       Lower Bound  Upper Bound
         x1       c      24.000000       0.00e+00     4.20e+01 
         x2       c      12.000000       0.00e+00     4.20e+01 
         x3       c      12.000000       0.00e+00     4.20e+01 

    Constraints (i - inequality, e - equality):
        Name    Type                    Bounds
         g1       i       -1.00e+21 <= 0.000000 <= 0.00e+00
         g2       i       -1.00e+21 <= -72.000000 <= 0.00e+00

--------------------------------------------------------------------------------

Erreur de segmentation

I've been stuck in this problem for a week. can you tell me how to solve the problem?

kjyv commented 4 years ago

It's possible that pyOpt has some issues in the ALGENCAN solver (which is not really good for the problems here anyway) that let it crash but the crash is in fcl looking at the stack trace. You might still have a more recent or different version installed but it might also be another problem with fcl. You might have to run a debugger on that part of the code and check what is happening. Please be aware that this framework is not maintained anymore. It did mostly work fine though when I wrote it. Consider it as a starting point with lots of code rather than a black box solution that just does the job for you. I don't have the environment installed for it anywhere to test run it.