VREP crashes after a time

Report crashes, strange behaviour, or apparent bugs
Post Reply
ferty
Posts: 2
Joined: 28 May 2014, 17:38

VREP crashes after a time

Post by ferty »

Hi!
I'm using VREP with QT to control the walking of robot NAO with reinforcement learning. This method demands a lot of trials to converge, so I'm trying 10000 trials. But, when the program is about 2000 trials (18 hours), VREP crashes. I tried a lot of times, in different computers, with the most actual version, and I don't have any ideia what is the problem. In the screen of VREp don't appears any error or something like this. Is this a bug or am I doing something wrong?

This is the main script that I'm using to simulate and communicate with QT.

Code: Select all

-- Initialization part (executed just once, at simulation start) ---------
if (simGetSimulationState()==sim_simulation_advancing_firstafterstop) then
	newPortNb = 25000
	simExtRemoteApiStart(newPortNb,250,true)
	simOpenModule(sim_handle_all)
	simHandleMechanism(sim_handle_all_except_explicit)
	simHandleIkGroup(sim_handle_all_except_explicit)
	simHandleMill(sim_handle_all_except_explicit)
	simHandleCollision(sim_handle_all_except_explicit)
	simHandleDistance(sim_handle_all_except_explicit)
	simHandleProximitySensor(sim_handle_all_except_explicit)
	simHandleVisionSensor(sim_handle_all_except_explicit)
	simHandleGraph(sim_handle_all_except_explicit,simGetSimulationTime())
end
--------------------------------------------------------------------------
-- "Actuation"-part ------------------------------------------------------
simResumeThreads(1)
-- Following code line will execute all "regular" child scripts that
-- appear as first child scripts in the scene hierarchy, and only those
-- that are not marked as "explicit handling":
simHandleChildScript(sim_handle_all_except_explicit)
simHandleModule(sim_handle_all,false)
simResumeThreads(2)
simHandleJoint(sim_handle_all_except_explicit,simGetSimulationTimeStep())
simHandlePath(sim_handle_all_except_explicit,simGetSimulationTimeStep())
simHandleMechanism(sim_handle_all_except_explicit)
simHandleIkGroup(sim_handle_all_except_explicit)
simHandleDynamics(simGetSimulationTimeStep())
simHandleVarious()
simHandleMill(sim_handle_all_except_explicit)
--------------------------------------------------------------------------

-- "Sensing"-part --------------------------------------------------------
workThreadCount=simGetIntegerParameter(sim_intparam_work_thread_count)
coreCount=simGetIntegerParameter(sim_intparam_core_count)
if (workThreadCount<0) then
	workThreadCount=coreCount -- auto setting: thread count=core count
	if (workThreadCount<2) then
		workThreadCount=0 -- turn work threads off if less than 2 cores
	end
end
simEnableWorkThreads(workThreadCount) -- thread count can be changed on-the-fly.
startTime1=simGetSystemTimeInMilliseconds()
simHandleCollision(sim_handle_all_except_explicit)
simHandleDistance(sim_handle_all_except_explicit)
simHandleProximitySensor(sim_handle_all_except_explicit)
startTime2=simGetSystemTimeInMilliseconds()
simHandleVisionSensor(sim_handle_all_except_explicit)
timeDiff2=simGetSystemTimeInMilliseconds(startTime2)
simWaitForWorkThreads()
timeDiff=simGetSystemTimeInMilliseconds(startTime1)-timeDiff2
if (workThreadCount==0) then
	timeDiff=0
end
simSetIntegerParameter(sim_intparam_work_thread_calc_time_ms,timeDiff)
simResumeThreads(3)
-- Following code line will execute all "sensing" child scripts that
-- appear as first child scripts in the scene hierarchy, and only those
-- that are not marked as "explicit handling":
simHandleSensingChildScripts()
simHandleModule(sim_handle_all,true)
simResumeThreads(4)
simHandleGraph(sim_handle_all_except_explicit,simGetSimulationTime()+simGetSimulationTimeStep())
--------------------------------------------------------------------------

-- Clean-up part (executed just once, before simulation ends) ------------
if (simGetSimulationState()==sim_simulation_advancing_lastbeforestop) then
	simEnableWorkThreads(0)
	simResetMilling(sim_handle_all)
	simResetMill(sim_handle_all)
	simResetCollision(sim_handle_all)
	simResetDistance(sim_handle_all)
	simResetProximitySensor(sim_handle_all)
	simResetVisionSensor(sim_handle_all)
	simCloseModule(sim_handle_all)
end

coppelia
Site Admin
Posts: 10375
Joined: 14 Dec 2012, 00:25

Re: VREP crashes after a time

Post by coppelia »

Hello,

how to you execute your trials? Are you loading again and again the same scene? Or are you simply restarting the simulation after having adjusted some parameters?

Is it possible that you are running low on memory? (i.e. this could be a memory leak). Can you check if after a few hours the memory footprint of V-REP has much increased?

You can try to turn on a few debugging messages [Menu bar --> Help --> Debug --> ..], but since you are running 18 hours of simulation, I wouldn't send the debug info to a file, since it might get huge.

Cheers

ferty
Posts: 2
Joined: 28 May 2014, 17:38

Re: VREP crashes after a time

Post by ferty »

I'm trying to "teach" NAO how to walk. So, when it falls, I reset the positions of all motors, and I move the robot to the initial position and the program starts a new trial.

About the memory, I'm using a lot of memory in the reinforcement learning, but is a little far from the limit. I'll run again and check if the memory footprint of V-REP increases much.

Thanks

Rodrigo
Posts: 29
Joined: 25 Aug 2014, 16:33

Re: VREP crashes after a time

Post by Rodrigo »

Hi,

I have a similar problem. I am trying to run evolutionary algorithms with distributed evaluation so I have 3 v-rep simulators running in headless mode that I control using the remoteAPI in java. In each individual evaluation of the evolutionary algorithm each simulator loads and closes four scenes consecutively since I have to test the same parameters in different mazes/environments.

After nearly 1000 evaluations (approximately 300 evaluations per simulator) one of the 3 simulators crashes and any command that I try to send to it using the remoteAPI returns error code 3, the remoteAPI server is still running since I can connect to it to send commands.

I have been reading in:
viewtopic.php?f=5&t=1577&hilit=return+3&start=10
that it could be a problem of loading and closing several scenes hundreds of times without closing streaming data so I am going to try that, but in the meantime is there a way of switching between scenes without closing them to prevent this?

Thanks in advance!

coppelia
Site Admin
Posts: 10375
Joined: 14 Dec 2012, 00:25

Re: VREP crashes after a time

Post by coppelia »

Hello Rodrigo,

in next release (i.e. the one after 3.1.3) you will be able to switch the scene via following function:

Code: Select all

i=simGetIntegerParameter(sim_intparam_scene_index)
simSetIntegerParameter(sim_intparam_scene_index,i+1) -- switch to the next scene
The second command will only succeed if the simulation is not running, and will happen in a delayed manner. Because of this, you will have to wait until the scene has effectively switched by periodically calling the first function.
You can obtain a beta version if you contact us here.

Cheers

Rodrigo
Posts: 29
Joined: 25 Aug 2014, 16:33

Re: VREP crashes after a time

Post by Rodrigo »

Hi,


I tried closing any streaming data that I started but it still fails around the same number of evaluations.

However I have also tried separating the 3 simulators by running each of them from its own folder, at the beginning I was running all of them from the same folder by simply rewriting the remoteApiConnections.txt file to give each simulator different remote API server port numbers. Separating the simulator folders seems to help as the simulators have not crashed until now and have been able to complete the 1500 evaluations. Also I have run a single simulator test by running more than 3600 evaluations for about 15 hours and it completed without problem.

Thanks

Post Reply