Add new sensor in VREP scene and working with Pypot library

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 poppy-humanoid.py 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 pypot.vrep.io import VrepIO
vrep_io = VrepIO('127.0.0.1',19997)
scene_path ='yourscene.ttt'
vrep_io.call_remote_api('simxLoadScene', scene_path, True)
vrep_io.start_simulation()
vrep_io.get_motor_force('m13')
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.: http://www.coppeliarobotics.com/helpFiles/en/remoteApiFunctionsPython.htm

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