Library, available at https://github.com/nikhil3456/VrepLibrary (Reference), that could correctly handle the following routine:
- Start a V-REP instance from Python
- Connect to the instance you've started
- Load the scene file (the scene we are about to simulate)
- Start the simulation
- Step the simulation
- Read/Write something from/to V-REP to control the simulation and record data
- Goto 5 several times
- Stop the simulation
- Check to see if the simulation actually stopped.
- Goto 4 several times
- Kill the V-REP instance from python if no longer needed.
A python script to start the simulation (following above routine) in headless mode, can be written using following functions:
from vrepper.core import vrepper
# create a vrepper object using the following command:
# dir_vrep is the path to vrep directory.
# port_num denotes the port on which to start vrep(if port_num=None then a random port will be assigned)
venv = vrepper(port_num=None, dir_vrep='/home/nikhil/V-REP_PRO_EDU_V3_5_0_Linux/', headless=True)
# Start a V-REP instance
venv.start()
# To load a scene after creating V-REP instance:
venv.load_scene(current_dir + '/scenes/scene.ttt')
# start simulation in realtime mode to set initial position
venv.start_simulation(is_sync=False)
- In above, instead of passing dir_vrep, one can also declare a env-variable like this (for Linux):
$ export PATH="/home/USERNAME/V-REP_PRO_EDU_V3_4_0_Linux":$PATH
- Refer the following example files:
Nikhil Bansal