loco-3d / sl1m

Implementation of the sl1m solver for multi contact planning
BSD 2-Clause "Simplified" License
15 stars 15 forks source link

How to setup the project #6

Closed ferrolho closed 4 years ago

ferrolho commented 4 years ago

After installing the project dependencies, I am trying to run:

cd ~/git/sl1m                   (project root folder)
python ./sl1m/planner.py

but this throws the following error:

Traceback (most recent call last):
  File "./sl1m/planner.py", line 3, in <module>
    from sl1m.problem_definition import *
ModuleNotFoundError: No module named 'sl1m'

So I added the project folder to my PYTHONPATH:

export PYTHONPATH=$PYTHONPATH:`pwd`

(Is this the right thing to do?)

After that, trying to run python ./sl1m/planner.py throws a different error:

Traceback (most recent call last):
  File "./sl1m/planner.py", line 196, in <module>
    from sl1m.stand_alone_scenarios.escaliers import gen_stair_pb, draw_scene
  File "/home/henrique/git/sl1m/sl1m/stand_alone_scenarios/escaliers.py", line 13, in <module>
    from constraints import *
ModuleNotFoundError: No module named 'constraints'

which can be fixed by editing the line https://github.com/loco-3d/sl1m/blob/0508d282baf1eb019a4da8e6d955ba5d220ca0d3/sl1m/stand_alone_scenarios/escaliers.py#L13 to

from sl1m.stand_alone_scenarios.constraints import *

After all these changes, the program runs as expected. It prints

time to set up problem 0.44170899491291493
time to solve problem 1.3390590029302984
total time 1.7807679978432134

and displays

Screenshot from 2020-07-17 10-25-41

I am questioning myself: is this the right way to do it? Or were these changes only required because I did not setup the project as intended? Thank you in advance!

nim65s commented 4 years ago

Hi @ferrolho,

your export PYTHONPATH=$PYTHONPATH:$(pwd) is correct, but you could also use export PYTHONPATH=$PYTHONPATH:.. You can also launch the module: python -m sl1m.planner, which doesn't require a PYTHONPATH change.

And for escaliers.py, I'm sorry I didn't finish my job packaging this project. I'll open a PR to fix this issue.