Add new sensor in VREP scene and working with Pypot library

Hello everybody,

I’m starting to work with python and a Poppy robot in the VREP, PoppyTorso or PoppyHumanoid, anyone . I can load a Poppy robot in the simulator and work with it and the pypot library without problem.
Now, I want to modified the Poppy predefined scene to add a vision sensor for simulated a real camera. There’s no problem to add a vision on the scene, but my problem is:
How can I use a new vision sensor (or another sensor that I could add in the future) with the pypot library added into the VREP scene?

I’ve loaded the scene and added a “tracked_object” as is shown in this link:

and modified the configuration file “poppy_humanoid.json” as it’s shown in this link:

On the other hand, in the previous post it is suggested that create a new class for the sensor in the pypot sensor folder could be needed. But in the pypot directory “…\pypot\sensors\camera” there are already some classes created for a camera.

At this point, I am still not able to control a vision sensor (or any other sensor) added into the scene by the pypot library.
Could anyone help me with this and tell me what I need to have a simulated robot with new sensors? I supposed that It shouldn’t be so hard, but…here I am hehe

Thanks in advance.

What you want to do is not easy, but possible. You need to create the sensor and to attach it to the robot. The sensor you can find in pypot.sensor are real sensor and are not able to work with vrep.

First you can try to manage your sensor out of the robot class and if you are succesfull you can add your sensor at instanciation in for exemple. You will need to subclass the sensor class and eventually to add a controller to retrieve the data faster.

Here an example with a force sensor (you can add a vision sensor in a same way) :

from import VrepIO
vrep_io = VrepIO('',19997)
scene_path ='yourscene.ttt'
vrep_io.call_remote_api('simxLoadScene', scene_path, True)
vrep_io.call_remote_api('simxReadForceSensor', vrep_io.get_object_handle('f1'), streaming=True)

As you can see, you need to call the call_remote_api function to extract the data from vrep and you need to call the right simxFunction. The vrep documentation api is quite good and you can find a detailled description of all functions.:

If you are succesfull with a low level access, post another message and I will show you a example of how to add your sensor to your robot.

1 Like

Hello Julien,

Many thanks for your support.

That’s what I supposed, this would be easier in a real robot than in the simulator. Thanks for confirm hehe

Now, after changing a little your code (I couldn’t load the scene usign the external API and I use the VrepIO class) I’ve been able to get the information of the vision sensor through the external API. I get the image very well. Here, I post my code if someone could need it in the future

from import VrepIO
import pypot.vrep

vrep_host = '’
vrep_port = 19997
vrep_scene = 'C:\Users\martin\AppData\Roaming\Python\Python27\site-packages\poppy_humanoid\vrep-scene\poppy_humanoid.ttt’
vrep_io = VrepIO(vrep_host, vrep_port, vrep_scene, start=True)

cameraHandler = vrep_io.get_object_handle(‘camera’)
resolution, imagen = vrep_io.call_remote_api(‘simxGetVisionSensorImage’, cameraHandler, 0, streaming = True)

To avoid double post, I edit my message.

To follow this post as you said:

I think I’ve post my reply with low level access. Is this correct? if there is something that I misunderstand please, tell me, because I am waiting for your help :wink:

1 Like