Reset Simulation

Requests regarding how to set up experiments in ARGoS.
jtrautmann
Posts: 9
Joined: Thu Jan 30, 2020 11:29 am

Reset Simulation

Postby jtrautmann » Mon Jan 11, 2021 1:57 pm

Hello,

I want to run a Simulation experiment multiple times, until it is told by a ROS service call to stop. One experiment does not have a fixed length. It is also told by a ROS service call that it ended.

I know that I can reset everything that was set in my LoopFunctions class. For this, I can save the configuration node of the call of Init and use it once again when resetting. But I didn't find any way to reset the elements which were not declared in the configuration for the loop functions in the argos file. For example, if I declared boxes in the arena element with random positions, this way does not work to change their positions.
I also tried calling GetSimulator().Reset() in my LoopFunctions class (and defining the reset behaviour of the LoopFunctions class in its Reset() function), but this call results in an error.

Another way I tried was based on the galib example (https://github.com/ilpincy/argos3-examp ... b/main.cpp): I started the Simulator and executed and reset it in a loop basically like this:

Code: Select all

CSimulator& cSimulator = CSimulator::GetInstance(); cSimulator.SetExperimentFileName(file); cSimulator.LoadExperiment(); while (run) { cSimulator.Execute(); cSimulator.Reset(); }
To end one experiment execution, I implemented the IsExperimentFinished method of the LoopFunctions class and let it return true when one experiment instance should be stopped because a corresponding ROS service was called.
The problem is that the the call of cSimulator.Execute() keeps blocking even after IsExperimentFinished returns true. So the call of cSimulator.Reset() is only reached when closing the ARGoS window, which can not be done by a ROS service call.

Thank you in advance!

pincy
Site Admin
Posts: 632
Joined: Thu Mar 08, 2012 8:04 pm
Location: Boston, MA
Contact:

Re: Reset Simulation

Postby pincy » Fri Jan 15, 2021 6:45 am

The correct approach is to use the galib example. If you don't need the GUI, you can run ARGoS headless by simply commenting out the <qt-opengl/> section. If you need to reset from a node and, at the same time, keep the GUI open, try and use the Qt user functions.

https://github.com/ilpincy/argos3/blob/ ... unctions.h
I made ARGoS.


Return to “How to... ?”