Pycharm, Poppy Humanoid and V-REP

Hi.

I’ve jusy installed everything needed, but I meet one strange problem.
I can create Poppy, but I can’t use primitives from code (e.g. dance) in IDE.
But I can activate “dance” through command line.

Example code:
from poppy_humanoid import PoppyHumanoid
from poppy_humanoid.primitives.dance import SimpleBodyBeatMotion

poppy = PoppyHumanoid(simulator=‘vrep’)
dance = SimpleBodyBeatMotion(poppy, 128, 10)
dance.start()

Thanks for yout support.

Hi

What’s happening exactly, is poppy-humanoid just not moving or do you have an error message when lauching the dance primitive ? What is your IDE ?

I use Pycharm.
Yes, nothing happens and poppy-humanoid still stands.

The connection with V-REP is freezed when there is a popup (look at the doc for screenshots), are you sure you closed it ?

What do you mean by:

But I can activate “dance” through command line.

Yeah. I’m sure (closed it).

I can activate through Juputer / IPython, but can’t through Pycharm.

I don’t use PyCharm but I suppose it just execute the script and close the Python Interpreter just after the dance.start().
Add at the end of your code something like

import time
while True:
    try:
        time.sleep(0.1)
    except KeyboardInterrupt:
        break

It is just an infinite loop to avoid quitting the Python interpreter. The time.sleep is to avoid using all the available CPU in the loop.

1 Like

Nice. Thanks.
It helped.
Do I always have to add something like this at the end?

This is just to avoid the closing of python by pycharm at the end of your script. Depend on what you want after the end of your script (quit python or not ?). Anyway, Jupyter is really a good way to talk to Poppy.

Jupyter is good, but not comfortable as Pycharm or another IDE.
Anyway, thanks for help.

It is not a Poppy thing. dance.start() is a not blocking operation (it start a new thread), so you have to do something at the end of the script to avoid closing it immediately. You have to do these things in every programming languages when you manage threads.

Yes, I know how threads work.
But I think it’ll not close thread immediately. And I’ve never met it in C++ or Java.