HowTo: Connect pypot to your simulated version of a Poppy humanoid in V-REP

In this documentation, I’ve written an IPython Notebook on how you can control a simulated Poppy Humanoid using a robot simulator.

In more detail, in this tutorial you will:

  • see how we can create a poppy humanoid in the V-REP simulator
  • learn how we can read/send values to the motors
  • track one or several Poppy’s parts 3D position and orientation (e.g. its head)
  • write a simple primitive to design higher level behaviors (e.g. a dance motion)
  • see how we can reset and tune the simulation

As for all Notebooks Tutorial, you can refer to this documentation to see how you can view, install and run them. A list of the most important Notebook is available in this pinned topic:

Please share your comments, contributions here!

2 Likes

I tried to connect to v-rep. So I followed your tutorial. I built the poppy_config.json file. Then, I use your script :

import json
with open('poppy_config.json') as f:
    poppy_config = json.load(f)
from pypot.vrep import from_vrep
scene_path = 'C:\\users\\julien\\documents\\travail\\poppy\\poppy-standing2.ttt'
poppy = from_vrep(poppy_config, '127.0.0.1', 19997, scene_path)

Poppy_standing appears in V-Rep but just after pypot returns an error message

I made test out of pypot to connect to V-rep and I have no problem with function SimxStart or simxGetObject on poppy scene.

Could you help me to understand what is wrong with io.py ?
Thanks.

I found the solution. V-REP is too slow to answer. I disable undo/redo functionnality in V-Rep and now it works. Poppy fall down correctly with the walk() function…

Hi @juju,

Unfortunately v-rep could be really slow (especially if you don’t have good 3D driver).
Currently, in pypot there is already a five seconds timeout. But it’s still not enough on some computer. You can increase it even more, but the communication will be very slow.

For the walk behaviour, this is what is “expected”. We still need a balance behavior :slight_smile:

Hi Pierre,

Balance Behavior…ok How can I access to the sensor on Poppy in V-Rep ? I can see that there are accelerometer and gyrosensor in Poppy’s Head but I can’t see them in the config file poppy_config.json ?

Ok what I understand :
To access the sensor (like an IMU) I have to track dummy object in V-REP. To do that I add (Tracked Object=[accelorometer] in the call to from_vrep() function.

poppy = from_vrep(poppy_config, '127.0.0.1', 19997, scene_path, tracked_objects=[accelerometer_reference_head])

I’m a little bit surprise by the result of speed control in V-REP. I Have no difference with the 2 commands :

poppy.r_shoulder_x.goal_speed = -50

or

 poppy.r_shoulder_x.goal_speed = -1 

Is speed control implemented with V-REP ?

Yes exactly. I wish this will be better integrated in the future but unfortunately I don’t have much time to work on this at the moment. A better integration of sensors would definitely be a useful contribution!

No there is no simple way (or at least we did not find it) to do speed control in v-rep. We can either use the motor in speed mode but then there is no angle limit or use position only.

To circumvent this, we have updated the goto_position method which can now use the minimum jerk trajectory. Depending on what you are trying to do this may be helpful.

Useful link to the notebook ! New class PoppyHumanoid to instantiate the robot and what I understand is that there is a new Goto method supported by V-REP and a beautiful min_jerk argument to minimize the acceleration.
But I have an error message : … from_vrep got an unexpected keyword argument 'sync’
Line 66 in abstractcreature.py there is a call to the from_vrep function :

 poppy_creature = from_vrep(config, host, port, scene, sync=sync) 

and the argument sync is not define in pypot.vrep :

 def from_vrep(config, vrep_host='127.0.0.1', vrep_port=19997, scene=None,
                  tracked_objects=[], tracked_collisions=[]):

I check on GitHub but I think I have the latest version of pypot.vrep, something I misunderstand ?

After some test on my computer, There is no difference between :

poppy.l_shoulder_x.goto_position(120, 5)

and

poppy.l_shoulder_x.goto_position(120, 200)

even in minjerk behavior.
Because the duration is used to calculate the moving_speed and the moving_speed do nothing in V-REP (impossible to use simxjointargetvelocity ??)

Curiosly, it works better running the scripts with the notebook of Ipython ( I really don’t know why). But the results are not really what is expected

it sounds like my computer is really too slow… right ?

This feature has been added to the 2.1.2 version of pypot, so just a few days ago.

If you look at the minimum jerk code, you will see it’s only setting the goal_position not changing the speed. My guess would be that you was still in dummy goto mode.

From what I can see from the plot, your connection with v-rep is extremely slow (there is like 3 update per seconds). V-rep can be really CPU consuming if you do not have good 3D driver.

Ok,with minjerk the overall movement is separated into small movement (goal_position) so it works on VREP.
I wonder about the time… I guess pypot time is about similar to real time but vrep time could be very different. In fact, the simulation is not in real time.
In goto method, is the duration scale on pypot time or vrep time ?
On the graph, you can see that this 5 seconds movement…

poppy.l_shoulder_x.goto_behavior = 'minjerk'

poppy.l_shoulder_x.goto_position(120, 5)

pos = []
t0 = time.time()

while time.time() - t0 < 30:
    pos.append(poppy.l_shoulder_x.present_position)
    
    time.sleep(0.01)
    
t = linspace(0, 30, len(pos))
plot(t, pos)

… takes in reality about 30 seconds :

but if I plot the movement with the simulation time…

poppy.l_shoulder_x.goto_behavior = 'minjerk'

poppy.l_shoulder_x.goto_position(120, 5)

pos = []
t= []
t0 = time.time()

while time.time() - t0 < 30:
    pos.append(poppy.l_shoulder_x.present_position)
    t.append(poppy.current_simulation_time)
    time.sleep(0.01)
    
#print poppy.current_simulation_time
    
#t = linspace(0, 30, len(pos))
plot(t, pos)

It takes about 9 seconds…

Not really 5 seconds but not so far…

Just a new benchmark about V-REP simulation time. On my computer (notebook core i3), impossible to have real time simulation in V-REP, I guess not enough powerful for 3D calculation…

The script I wrote this we (in french…) In this notebook,

1 Like

Thx @juju, interesting bench!

For info, on my laptop (really powerful i7 + good GPU) I’m only barely better than real time…

We should soon try to provide a simpler model of Poppy for V-REP by simplifying the mesh. This may hopefully improve the performance. You can also try to run V-REP in headless mode and see if it works better. Of course you’ll loose the visualisation…

Hi Pierre,

I had already tried in headless mode, it is a little bit better but not a big difference. In your tutorial you wrote that it is possible to have position and orientation :
" track one or several Poppy’s parts 3D position and orientation (e.g. its head) "
But I don’t find the method get_object_orientation() ? (in the same way that you define the get_object position() ) ?

I just proposed a pull request. Can you test it and tell me if it’s work?

I just proposed the same few minutes after you, so it works.

Just merged! Thanks!

Hi,

We are studying a project with poppy. We are already connected to poppy_humanoid on Vrep.
But we have a little problem.
We have made the HTTPServer and the get request works. We tried to make a post request to change the value of a motor but it failed.
We sended this request on navigator :
http://127.0.0.1:19997/motor/head_y/register/goal_position/20
and the navigator response is : "Not found '/motor/head_y/register/goal_position/20"
Can you help us to resolve this problem?
Thanks

Hello,

I don’t know well the way you are using to access Poppy, but the port19997 you use is a little bit surprising. Normally This is the V-REP port and in the notebook I just read ( http://nbviewer.ipython.org/github/poppy-project/pypot/blob/REST-API-2.0/samples/notebooks/Accessing%20pypot%20REST%20API%20through%20HTTP%20requests.ipynb) the port 8080 is used to access pypot ?

1 Like