stack-of-tasks / pinocchio

A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
http://stack-of-tasks.github.io/pinocchio/
BSD 2-Clause "Simplified" License
1.92k stars 395 forks source link

Loading pinocchio model fails #1107

Closed cmastalli closed 4 years ago

cmastalli commented 4 years ago

After updating Pinocchio to the latest devel branch, I found a problem in the loading of a Pinocchio model. For instance, if I run the following code

import pinocchio
from pinocchio.robot_wrapper import RobotWrapper

URDF_FILENAME = "anymal.urdf"
URDF_SUBPATH = "/anymal_b_simple_description/robots/" + URDF_FILENAME
modelPath = "/home/cmastalli/devel/example-robot-data/robots"
robot = RobotWrapper.BuildFromURDF(modelPath + URDF_SUBPATH, [modelPath], pinocchio.JointModelFreeFlyer())

it fails and says:

*** stack smashing detected ***: /usr/bin/python terminated
Aborted (core dumped)

Then I run the unittest code in Pinocchio, and I found the follows:

Running tests...
/usr/bin/ctest --force-new-ctest-process 
Test project /home/cmastalli/devel/pinocchio/build
      Start  1: test-cpp-eigen-basic-op
 1/91 Test  #1: test-cpp-eigen-basic-op .....................   Passed    0.01 sec
      Start  2: test-cpp-eigen-tensor
 2/91 Test  #2: test-cpp-eigen-tensor .......................   Passed    0.00 sec
      Start  3: test-cpp-sincos
 3/91 Test  #3: test-cpp-sincos .............................   Passed    0.01 sec
      Start  4: test-cpp-quaternion
 4/91 Test  #4: test-cpp-quaternion .........................   Passed    0.43 sec
      Start  5: test-cpp-rpy
 5/91 Test  #5: test-cpp-rpy ................................   Passed    0.01 sec
      Start  6: test-cpp-rotation
 6/91 Test  #6: test-cpp-rotation ...........................   Passed    1.06 sec
      Start  7: test-cpp-spatial
 7/91 Test  #7: test-cpp-spatial ............................   Passed    0.04 sec
      Start  8: test-cpp-symmetric
 8/91 Test  #8: test-cpp-symmetric ..........................   Passed    3.62 sec
      Start  9: test-cpp-aba
 9/91 Test  #9: test-cpp-aba ................................   Passed    0.27 sec
      Start 10: test-cpp-rnea
10/91 Test #10: test-cpp-rnea ...............................   Passed    0.17 sec
      Start 11: test-cpp-crba
11/91 Test #11: test-cpp-crba ...............................   Passed    0.14 sec
      Start 12: test-cpp-centroidal
12/91 Test #12: test-cpp-centroidal .........................   Passed    0.32 sec
      Start 13: test-cpp-com
13/91 Test #13: test-cpp-com ................................   Passed    1.29 sec
      Start 14: test-cpp-joint-jacobian
14/91 Test #14: test-cpp-joint-jacobian .....................   Passed    0.08 sec
      Start 15: test-cpp-cholesky
15/91 Test #15: test-cpp-cholesky ...........................   Passed    0.20 sec
      Start 16: test-cpp-contact-dynamics
16/91 Test #16: test-cpp-contact-dynamics ...................   Passed    0.15 sec
      Start 17: test-cpp-sample-models
17/91 Test #17: test-cpp-sample-models ......................   Passed    0.02 sec
      Start 18: test-cpp-kinematics
18/91 Test #18: test-cpp-kinematics .........................   Passed    0.06 sec
      Start 19: test-cpp-urdf
19/91 Test #19: test-cpp-urdf ...............................   Passed    0.14 sec
      Start 20: test-cpp-value
20/91 Test #20: test-cpp-value ..............................   Passed    0.07 sec
      Start 21: test-cpp-python_parser
21/91 Test #21: test-cpp-python_parser ......................   Passed    0.85 sec
      Start 22: test-cpp-model
22/91 Test #22: test-cpp-model ..............................   Passed    0.07 sec
      Start 23: test-cpp-data
23/91 Test #23: test-cpp-data ...............................   Passed    0.04 sec
      Start 24: test-cpp-constraint
24/91 Test #24: test-cpp-constraint .........................   Passed    0.05 sec
      Start 25: test-cpp-joints
25/91 Test #25: test-cpp-joints .............................   Passed    0.09 sec
      Start 26: test-cpp-compute-all-terms
26/91 Test #26: test-cpp-compute-all-terms ..................   Passed    0.12 sec
      Start 27: test-cpp-energy
27/91 Test #27: test-cpp-energy .............................   Passed    0.04 sec
      Start 28: test-cpp-frames
28/91 Test #28: test-cpp-frames .............................   Passed    0.11 sec
      Start 29: test-cpp-joint-configurations
29/91 Test #29: test-cpp-joint-configurations ...............   Passed    0.08 sec
      Start 30: test-cpp-joint-generic
30/91 Test #30: test-cpp-joint-generic ......................   Passed    0.04 sec
      Start 31: test-cpp-explog
31/91 Test #31: test-cpp-explog .............................   Passed    0.05 sec
      Start 32: test-cpp-finite-differences
32/91 Test #32: test-cpp-finite-differences .................   Passed    0.11 sec
      Start 33: test-cpp-visitor
33/91 Test #33: test-cpp-visitor ............................   Passed    0.08 sec
      Start 34: test-cpp-algo-check
34/91 Test #34: test-cpp-algo-check .........................   Passed    0.02 sec
      Start 35: test-cpp-joint-composite
35/91 Test #35: test-cpp-joint-composite ....................   Passed    0.04 sec
      Start 36: test-cpp-joint-mimic
36/91 Test #36: test-cpp-joint-mimic ........................   Passed    0.02 sec
      Start 37: test-cpp-liegroups
37/91 Test #37: test-cpp-liegroups ..........................   Passed    0.24 sec
      Start 38: test-cpp-regressor
38/91 Test #38: test-cpp-regressor ..........................   Passed    0.06 sec
      Start 39: test-cpp-version
39/91 Test #39: test-cpp-version ............................   Passed    0.00 sec
      Start 40: test-cpp-copy
40/91 Test #40: test-cpp-copy ...............................   Passed    0.03 sec
      Start 41: test-cpp-serialization
41/91 Test #41: test-cpp-serialization ......................   Passed    0.72 sec
      Start 42: test-cpp-kinematics-derivatives
42/91 Test #42: test-cpp-kinematics-derivatives .............   Passed    0.55 sec
      Start 43: test-cpp-rnea-derivatives
43/91 Test #43: test-cpp-rnea-derivatives ...................   Passed    1.38 sec
      Start 44: test-cpp-aba-derivatives
44/91 Test #44: test-cpp-aba-derivatives ....................   Passed    1.89 sec
      Start 45: test-cpp-centroidal-derivatives
45/91 Test #45: test-cpp-centroidal-derivatives .............   Passed    0.48 sec
      Start 46: test-cpp-center-of-mass-derivatives
46/91 Test #46: test-cpp-center-of-mass-derivatives .........   Passed    0.11 sec
      Start 47: test-cpp-contact-dynamics-derivatives
47/91 Test #47: test-cpp-contact-dynamics-derivatives .......   Passed    2.33 sec
      Start 48: test-py-bindings
48/91 Test #48: test-py-bindings ............................   Passed    0.44 sec
      Start 49: test-py-bindings_model
49/91 Test #49: test-py-bindings_model ......................   Passed    0.44 sec
      Start 50: test-py-bindings_data
50/91 Test #50: test-py-bindings_data .......................   Passed    0.56 sec
      Start 51: test-py-bindings_com
51/91 Test #51: test-py-bindings_com ........................   Passed    0.61 sec
      Start 52: test-py-bindings_com_velocity_derivatives
52/91 Test #52: test-py-bindings_com_velocity_derivatives ...   Passed    0.62 sec
      Start 53: test-py-bindings_regressor
53/91 Test #53: test-py-bindings_regressor ..................   Passed    0.45 sec
      Start 54: test-py-bindings_dynamics
54/91 Test #54: test-py-bindings_dynamics ...................   Passed    1.05 sec
      Start 55: test-py-bindings_force
55/91 Test #55: test-py-bindings_force ......................   Passed    0.35 sec
      Start 56: test-py-bindings_frame
56/91 Test #56: test-py-bindings_frame ......................   Passed    0.36 sec
      Start 57: test-py-bindings_inertia
57/91 Test #57: test-py-bindings_inertia ....................   Passed    0.39 sec
      Start 58: test-py-bindings_spatial
58/91 Test #58: test-py-bindings_spatial ....................   Passed    0.33 sec
      Start 59: test-py-bindings_joint_composite
59/91 Test #59: test-py-bindings_joint_composite ............   Passed    0.33 sec
      Start 60: test-py-bindings_motion
60/91 Test #60: test-py-bindings_motion .....................   Passed    0.35 sec
      Start 61: test-py-bindings_SE3
61/91 Test #61: test-py-bindings_SE3 ........................   Passed    0.35 sec
      Start 62: test-py-bindings_geometry_model
62/91 Test #62: test-py-bindings_geometry_model .............   Passed    0.33 sec
      Start 63: test-py-bindings_rnea
63/91 Test #63: test-py-bindings_rnea .......................   Passed    0.38 sec
      Start 64: test-py-explog
64/91 Test #64: test-py-explog ..............................   Passed    0.34 sec
      Start 65: test-py-rpy
65/91 Test #65: test-py-rpy .................................   Passed    0.34 sec
      Start 66: test-py-utils
66/91 Test #66: test-py-utils ...............................   Passed    0.34 sec
      Start 67: test-py-serialization
67/91 Test #67: test-py-serialization .......................   Passed    0.39 sec
      Start 68: test-py-bindings_urdf
*** stack smashing detected ***: /usr/bin/python terminated
68/91 Test #68: test-py-bindings_urdf .......................***Exception: Other  0.48 sec
      Start 69: test-py-bindings_geometry_model_urdf
*** stack smashing detected ***: /usr/bin/python terminated
69/91 Test #69: test-py-bindings_geometry_model_urdf ........***Exception: Other  0.48 sec
      Start 70: example-cpp-inverse-kinematics
70/91 Test #70: example-cpp-inverse-kinematics ..............   Passed    0.09 sec
      Start 71: example-cpp-overview-simple
71/91 Test #71: example-cpp-overview-simple .................   Passed    0.02 sec
      Start 72: example-cpp-overview-lie
72/91 Test #72: example-cpp-overview-lie ....................   Passed    0.01 sec
      Start 73: example-cpp-overview-SE3
73/91 Test #73: example-cpp-overview-SE3 ....................   Passed    0.01 sec
      Start 74: example-cpp-overview-urdf
74/91 Test #74: example-cpp-overview-urdf ...................   Passed    0.02 sec
      Start 75: example-cpp-interpolation-SE3
75/91 Test #75: example-cpp-interpolation-SE3 ...............   Passed    0.01 sec
      Start 76: example-cpp-build-reduced-model
76/91 Test #76: example-cpp-build-reduced-model .............   Passed    0.02 sec
      Start 77: example-cpp-geometry-models
77/91 Test #77: example-cpp-geometry-models .................   Passed    0.04 sec
      Start 78: example-cpp-kinematics-derivatives
78/91 Test #78: example-cpp-kinematics-derivatives ..........   Passed    0.03 sec
      Start 79: example-cpp-forward-dynamics-derivatives
79/91 Test #79: example-cpp-forward-dynamics-derivatives ....   Passed    0.04 sec
      Start 80: example-cpp-inverse-dynamics-derivatives
80/91 Test #80: example-cpp-inverse-dynamics-derivatives ....   Passed    0.03 sec
      Start 81: example-py-inverse-kinematics
81/91 Test #81: example-py-inverse-kinematics ...............   Passed    0.51 sec
      Start 82: example-py-overview-simple
82/91 Test #82: example-py-overview-simple ..................   Passed    0.34 sec
      Start 83: example-py-overview-urdf
*** stack smashing detected ***: /usr/bin/python terminated
83/91 Test #83: example-py-overview-urdf ....................***Exception: Other  0.46 sec
      Start 84: example-py-kinematics-derivatives
84/91 Test #84: example-py-kinematics-derivatives ...........   Passed    0.36 sec
      Start 85: example-py-forward-dynamics-derivatives
85/91 Test #85: example-py-forward-dynamics-derivatives .....   Passed    0.43 sec
      Start 86: example-py-inverse-dynamics-derivatives
86/91 Test #86: example-py-inverse-dynamics-derivatives .....   Passed    0.40 sec
      Start 87: example-py-gepetto-viewer
*** stack smashing detected ***: /usr/bin/python terminated
87/91 Test #87: example-py-gepetto-viewer ...................***Exception: Other  0.48 sec
      Start 88: example-py-meshcat-viewer
*** stack smashing detected ***: /usr/bin/python terminated
88/91 Test #88: example-py-meshcat-viewer ...................***Exception: Other  0.48 sec
      Start 89: example-py-meshcat-viewer-dae
*** stack smashing detected ***: /usr/bin/python terminated
89/91 Test #89: example-py-meshcat-viewer-dae ...............***Exception: Other  0.47 sec
      Start 90: example-py-robot-wrapper-viewer
*** stack smashing detected ***: /usr/bin/python terminated
90/91 Test #90: example-py-robot-wrapper-viewer .............***Exception: Other  0.47 sec
      Start 91: example-py-geometry-models
*** stack smashing detected ***: /usr/bin/python terminated
91/91 Test #91: example-py-geometry-models ..................***Exception: Other  0.46 sec

91% tests passed, 8 tests failed out of 91

Total Test time (real) =  32.62 sec

The following tests FAILED:
     68 - test-py-bindings_urdf (OTHER_FAULT)
     69 - test-py-bindings_geometry_model_urdf (OTHER_FAULT)
     83 - example-py-overview-urdf (OTHER_FAULT)
     87 - example-py-gepetto-viewer (OTHER_FAULT)
     88 - example-py-meshcat-viewer (OTHER_FAULT)
     89 - example-py-meshcat-viewer-dae (OTHER_FAULT)
     90 - example-py-robot-wrapper-viewer (OTHER_FAULT)
     91 - example-py-geometry-models (OTHER_FAULT)
Errors while running CTest
Makefile:85: recipe for target 'test' failed
make: *** [test] Error 8

This code is reported in Ubuntu 16.04 with all required dependencies installed from binaries.

jmirabel commented 4 years ago

On 18.04, your snippet works.

cmastalli commented 4 years ago

On 18.04, your snippet works.

Yes, it works on 18.04

jmirabel commented 4 years ago

Can you run it with gdb and provide the backtrace ?

jcarpent commented 4 years ago

Are you working from a clean installation? Could you also provide the ldd output related to Pinocchio pywrap lib.

cmastalli commented 4 years ago

Can you run it with gdb and provide the backtrace ?

I will run it as soon as Pinocchio finish to compile (in my old laptop takes easily 30 minutes)

Are you working from a clean installation? Could you also provide the ldd output related to Pinocchio pywrap lib.

No, I don't; just make clean then make install. But note that it was working before However, I am trying now to clean my PC, to be sure that it is not installation related.

I will report you as soon as I have tested both things

jmirabel commented 4 years ago

make clean is not always sufficient. You may have run into a CMake caching issue.

jcarpent commented 4 years ago

@cmastalli Just to mention that everything is running well on the CI. So, the issue seems to come from your side. As mentionned by @jmirabel or me, working with a clean build directory should solve your issue.

jcarpent commented 4 years ago

In addition, remove any installed library. Because the new thing with the current devel branch is that we have moved the URDF parser back to the libpinocchio.so file in order to avoid the managment of borring compilation flags that were only related to URDF, which is a compiled lib.

cmastalli commented 4 years ago

I fixed this issue in my installation by doing:

 cd ${build}
 rm -rf *
 cmake ../
 make install

So @jmirabel was right, cmake did a mess in my PC.

Thank you for the support!