Autostart experiment in fastforward mode

Requests regarding how to set up experiments in ARGoS.
pawel-jakubowski
Posts: 6
Joined: Mon Nov 30, 2015 10:11 pm

Autostart experiment in fastforward mode

Postby pawel-jakubowski » Wed Jan 06, 2016 10:52 pm

Hi,

I want to play my experiment 100 times and gather results. I guess that I cannot set that inside *.argos file so I determine three basic things:
- automatically start experiments
- closing application when my experiments is done (and it's not a time constraint)
- storing results somewhere

And I have problems with automatic start. I can turn on autostart by using

Code: Select all

<qt-opengl autoplay="true">
but my experiments can last long. Therefore I would like to run it (automatically) in fastforward mode (let's say 100x). Can I do this with argos?


P.S.
I've managed to solve last two problems (closing application & storing results) - however not in a "pretty" way. Maybe there is easier way to to this?

Closing application when goal is achieved - I used following instruction in qt loop function:

Code: Select all

if (aggregation.isAggregationFinished()) dynamic_cast<QMainWindow*>(GetOpenGLWidget().window())->close();
Storing results was more tricky, because

Code: Select all

--log-file
and

Code: Select all

--logerr-file
don't work as I expected. I mean - they gathered logs from start like:
[INFO] Loaded library "/usr/lib/argos3/libargos3plugin_simulator_footbot.so"
...
[INFO] Not using threads
[INFO] Using random seed = 896746
[INFO] Using simulation clock tick = 0.0166667
[INFO] Total experiment length in clock ticks = unlimited
but logs that appear in application window weren't stored in given files.

So (since std::cout is redirected to argos global logger) I used printf before closing application and parse results with python script.

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

Re: Autostart experiment in fastforward mode

Postby pincy » Thu Jan 07, 2016 6:50 am

Hi,

If you want to run your experiment N times, using the visualization is not a good idea. To avoid using it altogether put this in your .argos file:

Code: Select all

<visualization />
When ARGoS is run without visualization, it goes very fast.

To close ARGoS with a custom condition, implement the method CLoopFunctions::IsExperimentFinished(). Refer to the examples that use the loop functions.

To store the results of your experiment, again use the loop functions and implement either the method CLoopFunctions::PreStep(), or CLoopFunctions::PostStep(), or both, depending on what you need to achieve. You might want to implement the method CLoopFunctions::Init() to configure your experiment and open files, and CLoopFunctions::Destroy() to close files. It's also a good idea to implement CLoopFunctions::Reset(), so, when you press the reset button in the graphical visualization, you get correct results.

In short: have a look at the examples that use the loop functions, and you'll solve everything. ARGoS is explicitly designed for the kind of use case that you describe.

Cheers,
Carlo
I made ARGoS.

pawel-jakubowski
Posts: 6
Joined: Mon Nov 30, 2015 10:11 pm

Re: Autostart experiment in fastforward mode

Postby pawel-jakubowski » Thu Jan 07, 2016 9:03 am

Thanks a lot for your help! This is exactly what I wanted.

I didn't thought about no visualization at all, but this is what I need (I should have read examples more carefully ;))

I looked on given examples again, but I still cannot found information about CLoopFunctions::IsExperimentFinished().

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

Re: Autostart experiment in fastforward mode

Postby pincy » Thu Jan 07, 2016 3:38 pm

It's very simple: return true when you want the experiment to finish, and false when you want it to continue.

Have a look at the header file, too: https://github.com/ilpincy/argos3/blob/ ... unctions.h
I made ARGoS.

pawel-jakubowski
Posts: 6
Joined: Mon Nov 30, 2015 10:11 pm

Re: Autostart experiment in fastforward mode

Postby pawel-jakubowski » Thu Jan 07, 2016 6:40 pm

Please don't get me wrong - I know how to use it :)

I just think it is important feature and it should be described somewhere ;)

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

Re: Autostart experiment in fastforward mode

Postby pincy » Thu Jan 07, 2016 6:59 pm

Do you think this page is not sufficient?

http://www.argos-sim.info/api/a00119.php
I made ARGoS.

pawel-jakubowski
Posts: 6
Joined: Mon Nov 30, 2015 10:11 pm

Re: Autostart experiment in fastforward mode

Postby pawel-jakubowski » Fri Jan 08, 2016 2:59 pm

You're right - it is sufficient. Sorry, my bad.

I think I need more time to learn my way around argos.

Ryan
Posts: 42
Joined: Wed Oct 23, 2019 3:26 am

Re: Autostart experiment in fastforward mode

Postby Ryan » Wed Oct 23, 2019 4:18 am

So I want to ask if I use Lua to programming, how can I closing application when my experiments is done (and it's not a time constraint)

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

Re: Autostart experiment in fastforward mode

Postby pincy » Wed Oct 23, 2019 4:37 am

Use the loop functions in C++. Lua is only for robot controllers. You can't affect the simulation from within a controller.
I made ARGoS.

Ryan
Posts: 42
Joined: Wed Oct 23, 2019 3:26 am

Re: Autostart experiment in fastforward mode

Postby Ryan » Wed Oct 23, 2019 4:49 am

But my all code are programed by Lua. So is there any other ways to solve it?


Return to “How to... ?”