{1.1} Customize Log File Output - BCLab-UNM/iAnt-ARGoS GitHub Wiki
In the XML configuration file, you can turn on data collection such that it creates and appends log data to a file named "iAntTagData.txt". The default setup generates a log file that provides essential information from the results of an experiment, but you can customize it to produce different or more detailed information.
The log file generated by the iAnt-ARGoS plugin can be customized by making changes to the following code in the iAnt_loop_functions class:
void iAnt_loop_functions::PostExperiment() {
// This variable is set in XML, set to true to create/append to a log file
if(outputData == false) return;
// This file is created in the directory where you run ARGoS
// it is always created and/or appended to, never overwritten, i.e. ios::app
ofstream dataOutput("iAntTagData.txt", ios::app);
size_t time_in_minutes = floor(floor(simTime / ticks_per_second) / 60);
/*****
* If you would like to display the simulation time in seconds instead of
* minutes, you can replace the time_in_minutes variable with this:
*
* size_t time_in_seconds = floor(simTime / ticks_per_second);
*
* Where:
*
* "ticks_per_second" is set in the ARGoS XML file under <framework>
*
* "simTime" is the number of ticks elapsed during the simulation
*****/
// output to file
if(dataOutput.tellp() == 0) {
dataOutput << "tags_collected, time_in_minutes, random_seed\n";
}
dataOutput << foodItemCount - foodPositions.size() << ", ";
dataOutput << time_in_minutes << ", " << random_seed << endl;
dataOutput.close();
// output to ARGoS GUI
if(simCounter == 0) {
LOG << "\ntags_collected, time_in_minutes, random_seed\n";
LOG << foodItemCount - foodPositions.size() << ", ";
LOG << time_in_minutes << ", " << random_seed << endl;
} else {
ifstream dataInput("iAntTagData.txt");
string s;
while(getline(dataInput, s)) {
LOG << s << endl;
}
dataInput.close();
}
simCounter++;
}