I need to run a simulation repeatedly for 3 times and collect data from each simulation, thus I am trying to use the simxLoadScene() and simxCloseScene() functions to do so.
Here is what I am doing:
1. Create a clean, brand new scene in VREP.
Code: Select all
function sysCall_init() simRemoteApi.start(19999) end
to the new scene in a remoteApiCommandServer.
3. Start the simulation for the brand new scene.
4. Run this Python API script:
However, I am not able to load the scene. I was looking at the VREP GUI and the desired scene was never loaded up on there.
Code: Select all
print ('Program started') vrep.simxFinish(-1) # just in case, close all opened connections clientID=vrep.simxStart('127.0.0.1',19999,True,True,5000,5) # Connect to V-REP if clientID!=-1: print ('Connected to remote API server') for _ in range(0, 3): # Loading the scene ret = vrep.simxLoadScene(clientID, "PATH TO THE DESIRED SCENE", 0, vrep.simx_opmode_blocking) print (ret) # Returns 8 right now, which means there is a server error. # Start the simulation for the desired scene ret = vrep.simxStartSimulation(clientID, vrep.simx_opmode_oneshot) print (ret) # Returns 1 right now ######### Collect data in the current simulation. ########## # Stop simulation and close the scene vrep.simxStopSimulation(clientID, vrep.simx_opmode_oneshot) vrep.simxCloseScene(clientID, vrep.simx_opmode_blocking) # Before closing the connection to V-REP, make sure that the last command sent out had time to arrive. You can guarantee this with (for example): vrep.simxGetPingTime(clientID) # Now close the connection to V-REP: vrep.simxFinish(clientID) else: print ('Failed connecting to remote API server') print ('Program ended')
Also, no data was collected in the process, thus I am sure the scene wasn't loaded (the script for the collecting of data worked well when I just opened the desired scene and ran it).
Any idea why this didn't work? I am not very familiar with the remote API yet so any help will be appreciated!