loco-3d / multicontact-api

This package install a python module used to define, store and use ContactSequence objects.
Other
5 stars 5 forks source link

Unable to run `display_gepetto_gui` python script #24

Open GiulioRomualdi opened 2 years ago

GiulioRomualdi commented 2 years ago

Hi all, I'm trying to visualize the motions stored in the example folder with the following command

python3 display_gepetto_gui.py walk_20cm_quasistatic_WB.cs

Unfortunately, I have some problems, First of all, the following line https://github.com/loco-3d/multicontact-api/blob/3ff225a2a114044dda07ee9d933dc060a96cc359/examples/display_gepetto_gui.py#L1

should be substituted with

import ndcurves

However, after this modification, the code crashes with

terminate called after throwing an instance of 'boost::archive::archive_exception'
  what():  unregistered class
Aborted (core dumped)

The following code replicates the same error

import ndcurves
from multicontact_api import ContactSequence
cs = ContactSequence()
cs.loadFromBinary("./walk_20cm_quasistatic_WB.cs")

I installed multicontact-api project from sources with robotpkg as explained here

cc @pFernbach and @nim65s

GiulioRomualdi commented 2 years ago

I found a workaround 😃 . If you import multicontact_api before ndcurves the code works as expected

from multicontact_api import ContactSequence
import ndcurves
cs = ContactSequence()
cs.loadFromBinary("./walk_20cm_quasistatic_WB.cs")

This is really strange

nim65s commented 2 years ago

Hi @GiulioRomualdi,

Your issue is a duplicate of #23. I still have to fix this, sorry for the inconvenience.

As your report is way better than my quick notes, I'll let this one open and close the other.

GiulioRomualdi commented 2 years ago

Hi @nim65s!

Actually, the issue is a bit different. In #23 it is only reported that import ndcurves has to be added in order to have the multicontact_api working. What I noticed here is that import ndcurves should be added after from multicontact_api import ContactSequence, indeed if the order is the other way around the loadFromBinary segfault. Assuming that ndcurves must be imported manually the following two snippets should give the same result

from multicontact_api import ContactSequence
import ndcurves
cs = ContactSequence()
cs.loadFromBinary("./walk_20cm_quasistatic_WB.cs")
import ndcurves
from multicontact_api import ContactSequence
cs = ContactSequence()
cs.loadFromBinary("./walk_20cm_quasistatic_WB.cs")

Am I missing something?

nim65s commented 2 years ago

To me, the issue is that imports are broken. The different things you are talking about are multiple symptoms of the same issue. I mean… Things should just work. The end user shouldn't have to import a library he doesn't intend to use directly, or shouldn't have to fiddle with import order to make his code work as expected.